Forums

OverviewV-Play 2 Support (Qt 5) › Question about entityManager

Tagged: 

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #13744

    Wilfred

    Hi Friends,

    I am new to coding so sorry if this is a super simple question. I am trying to remove only one entity when collision occurs. However I can’t seem to remove one without removing all of the same type.

    Ex:
    onCollidedWithBox:{
    entityManager.removeEntitiesByFilter([“box”]);
    }

    I know I can use entityManager.removeLastAddedEntity() but this will not work in my case because it may grab another entity that just spawned.

    Any help is appreciated, and again sorry for my noobness.
    Thanks

    #13745

    Alex
    V-Play Team

    Hi Wilfred,

    just call the removeEntity() function of the specific entitiy that you want to remove.

    Cheers,
    Alex

    #13746

    G√ľnther
    V-Play Team

    Hi Wilfred!
    Don’t worry, everyone has to start somewhere ūüėČ

    As an alternative to Alex’s suggestion, you can also¬†use¬†the EntityManager::removeEntityById function.¬†Each entity has a unique entityId, which¬†you can use to retrieve the entity object or remove the entity.

    Cheers,
    G√ľnther

    • This reply was modified 2 years, 5 months ago by  GT.
    #13751

    Wilfred

    Thanks for the info guys! Will try this when i get home :)

    #13752

    Wilfred

    Hey Guys,

    I found success using the EntityManager::removeEntityById function. But I am having an issue where an entity of the same type will spawn before the first entity object is removed which causes the second entity object to have a different entityId. I am unsure how to retrieve this entityId or even set it. Therefore I cannot remove the second entity object because it is using a different entityId.

    I wish to keep the entity objects spawning one after the other before the first object collides and gets removed.

    Any suggestions on how to solve this?

    Thanks again,
    Wilfred

    #13776

    Lorenz
    #13861

    Wilfred

    Thanks for all the help guys I appreciate it. :)

    Cheers,
    Wilfred

Viewing 7 posts - 1 through 7 (of 7 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