Identifying the colliding clone

If object A collides with object B, then obviously object B collides with object A. So collision detection should be checked only on one of the two objects, not in both.

So, let's say A checks for collisions, finds it collided with an object and needs to identify the objects it collided with (B in this example).

If A and B are sprites this is trivial, but what if A and B are clones (possibily of different sprites, think about targets and bullets)?

I'm aware of the technique of identifying the colliding clone described in Collision detection with clones (ID recognition), which basically runs a full scan of the clones (or neighbors) list checking each element for collision, which surely does work but it seems quite inelegant.

I was wondering if there is a more direct way for a sprite/clone to find the clone it just collided with. Ideally, there should be a reporter block that returns the clone that collides with the caller object, if any.

Any suggestion is welcome.

Welcome to the forums! This block below reports a list of all the clones that are currently being touched. You can use a for each block to do something with all the clones that are being touched.

Oh I mistakenly pressed "result pic" instead of "script pic"...

Clones are sprites! When you get a list of clones, it's a list of sprites, and you can ask one for its ID number (when you create a clone, increment a sprite-local variable ID) or whatever. So I would do Pumpkinhead's expression but with MY NEIGHBORS instead of MY CLONES.

Thank you both, I'm going to experiment with that block.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.