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.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support