Tour Preview

Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!

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.