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

Forums

OverviewFelgo 1 Support › Hello

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5897

    omescroll

    Hi there, I have a situation, kindly help me out.

    I am creating instances of an entity randomly, and would want to remove one at a time as they make contact with another wall entity object. The problem is that I have looked at all the functions to remove entities, but I can’t figure out a way to remove one at a time; ONLY when that particular one makes contact with the wall, and not remove all the others that are being created even when they are not yet used. Is there a function I don’t know about to help achieve this?

     

    By the way, I am following the sample tutorials to create something similar, and I am using “mousejoint” to drag these entities that are created at run time around. Unlike the Balloon example where U can pop using the “multitouch”, I am trying to achieve almost something similar, but this time, when it comes in contact with the wall.

     

    Thanks

    #5898

    Alex
    Felgo Team

    Hi,

    you can do something like this in your entity:

    // the collider of your entity
    BoxCollider {
      // properties and stuff...
    
      fixture.onBeginContact: {
        // determine the entityType of the collided entity
        var fixture = other;
        var body = fixture.parent;
        var component = body.parent;
        var collidedEntity = component.owningEntity;
        var collidedEntityType = collidedEntity.entityType;
        // replace "wall" with the entityType of your walls
        if(collidedEntityType === "wall") {        
          // remove the entity
          removeEntity();
        }
      }
    }

    Is this what you are looking for?

    Cheers,
    Alex

    Ps: giving the forum thread a more meaningful name helps other developers find answers if they have similar questions 😉

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