The engine processes objects with the Platform behavior one by one. When Player #1 is standing on top of Player #2 and both are falling, the engine handles it like this:
- Player #1 is standing on a solid object → don't move it.
- Player #2 doesn't have a solid below → move it down a few pixels.
That’s why a gap appears between them.
Now, when Player #2 is on top of Player #1:
- Player #1 doesn’t have a solid below → move it down.
- Player #2 also doesn’t have a solid below → move it down.
So both fall at the same speed, and no gap appears.
I believe the processing order is based on the objects' Z-index. A simple fix could be:
If Player1.Y < Player2.Y → Move Player1 in front of Player2
Else → Move Player2 in front of Player1