I’m testing out a mechanic where multiple moving objects are going to the same target. I’m trying to have the objects separate and pause whenever a collision is detected (like lining up for a queue).
It seems to work well for the first collision, and then they just start overlapping and blinking without pausing.
There isn’t an easy way around this - it’s a challenge that’s been bugging many a GDeveloper for a long time. You can’t test for collisions between 2 objects of the same type and then separate them - I don’t think GDevelop will know which one to move and which to keep steady, and it may end up using just one of them for both actions. And this is even worse if there are multiple collisions
You may want to try (and this is a untested idea) to initially set the path for each object and then stop them before they head off on their merry way. As soon as you stop the object, get all of its path node positions and store them in an instance array.
Then use physics forces to push the object towards the first point stored in the array. Once the point is inside the object (and not that the object is at the point, as this may never happen with floating point precision), remove the first element of the array and repeat the process.
I think the physics engine should handle collisions between 2 physics objects for you, and not allow the overlapping of objects.
But, as I said, this is untested. It seems nice in theory, but there could be a snag that I’ve overlooked.
If using pathfinding, the way I’ve done this in the past is to check if Ball is in Collision with Ball, pick the one that is nearest to the destination (inverted, so it picks the furthest), then set the speed to 0.