Multiple collisions

  • Is it possible if obeject A and after Object B hits object C a action happens, but both needs to hit obeject C otherwise nothing happens. I‘m looking for something like a „and“ function.
    Thx very much for helpibg me.

  • @Bryan have an attribute or box container for each collided behaviour and set them to 0 to start with and then each collided behaviour sets their respective value to 1, and checks whether the other collided is set to 1. This is essentially your AND; if collided1 AND collided2 is true when the collided1 value is 1 and then the collided2 is activated, or vice versa. Here's a screenshot:
    The change input fields both set the value to 1.
    If you want it to be while they are colliding at the same time, use stopped colliding that sets the box container back to 0.

  • @Jack8680 thank you very much. I didn't expect such a fast answer.

    The bad think is, I've tried it out and it hasn't worked.


    Do you know what's wrong? Thank you very much!

  • found it!

  • @Jack8680 And what would you suggest, if the amount of object is higher than 3?

  • @Bryan put all the objects in a tag (including object detecting the collisions), use a loop to count the number of objects in the tag (subtract 1 to exclude self), if number of objects colliding is equal to number of objects in tag except self ( can't collide with self), then the object is currently colliding with all objects in the tag. This is shown in the first screenshot:

    To detect whether the object has ever collided with each object instead of detecting whether the object is colliding with all at the same time is similar, but the object detecting the collision is instead given a unique ID based on a global variable (so you can have multiple detecting objects that don't interfere with each other). A dynamic attribute is applied to all objects in the tag that it collides with so it only counts each object once. This is shown in the second screenshot:
    The behaviours in both screenshots should work with spawned object and multiple detectors too, but if you don't have this they can be simplified down a bit (you don't need to count objects if you know how many there are and don't need and ID if there is only one object anyway.

    EDIT: to clarify, "set attribute" is the global variable, with a value equal to "ID (Add Values)", and "set attribute2" is a dynamic attribute with a value of 1 and the key "combine text".

Log in to reply