Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 2 Support (Qt 5) › The ID of the collided box

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #17075

    Asaad

    Hello,

    I have a project where it contains some entities that collide with each other and one of them should be deleted.

    for example, A wall and a box (like the boxes example) and when a box hits the wall it should be deleted. I know I can set the collision in the ball, not on the wall but I have other objects when they hit the wall they also should be deleted. So, is it possible to get the id of the box so I can delete it with ( entityManager.removeEntityById(“Ball ID”) ).

    #17085

    Günther
    Felgo Team

    Hi Asaad!

    When creating entities with e.g. EntityManager::createEntityFromUrl you get the entityId of the created entity as return value of the function.

    If you like to access the entity of a collision, you can do so like this:

    BoxCollider {
      // ...
        fixture.onBeginContact: {
          var collidedEntity = other.getBody().target
          console.log("entityId: "+collidedEntity.entityId)
        }
    }

    Hope this helps!

    Best,
    Günther

     

    #17089

    Asaad

    Hi Günther!

    Thanks a lot. This fixes my problem.

     

Viewing 3 posts - 1 through 3 (of 3 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded