Say you have two enemies coming at you from the right on a 2D platformer. With the collision mask on, the first will engage properly but the second will get hung up walking behind the first enemy. With the collision mask off, they will simply overlap and occupy the exact same space. Using something like the
distance_to function, what is a good method to prevent this "bunching" behavior? I would like to turn off the collision mask as well, making their separation purely logic driven. Is it possible to "queue" enemies in such a way that the following might be possible? -
1st enemy: approaches and attacks.
2nd enemy: approaches and attacks from the opposite side.
3rd enemy: approaches and gets behind the 1st enemy (idle).
4th enemy: approaches and gets behind the 2nd enemy (idle).
Can someone give me some pseudo code for what that might look like? I've tried simple
RayCast2D detection, but the results are always buggy and not what is expected.