Only pick one of 2 or more instances on collision

  • I thought I solved this long ago...

    But when an object collide with 2 instances simultaneously they are both affected..

    I try to avoid this by including : pick random "object" instance.

    But it seems not to work.

    An exaple file

    Help would be much appreciated.

  • Just change form "On collision" to "Is overlapping" and keep the "Pick a random instance".

  • On not sure exactly what's going on here but it seems like when you say;

    A On Collision with B

    It resolves one at a time rather than resolving all the collisions then applying actions to the affected instances.

    You can see this in action by simply adding "Sprite2 | Set position(0, 0)" to the action list.

    You'll notice only one instance of Sprite is affected. As if the first collision resolves, then Sprite2 moves causing the second collision to fail.

  • Triggers are different from events. On Collision will only report one at a time. I had a recent example of dealing with this, but I can't find it at the moment. You either have to manage this yourself, or see if Overlap will do what you want.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Overlap works fine. Thanks.

    I don't understand why. but it works.

  • On collision occurs when on the first tick an object overlaps another, and picks those objects. Even if it overlaps two objects at the same tick, it triggers on collision with only one object, picks that object and proceeds with the actions. After that it triggers on overlapping the other one.

    It basically picked one object, destroyed it, picked the other one and destroyed that one.

    With "Is overlapping" it checks whether each instance of an object is overlapping another one and picks all instances that do.

  • Thanks KFC. Nice to know why things works as they do.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)