Moving platforms, how to make a sprite stay on another sprite

So I’m making a game with moving platforms. I figured out how to
make a sprite sit on another. But it only works on the first moving platform
and not the rest. Help would be greatly appreciated. Thanks.

Only the last generated platform is checked, should check against all platforms using for-each loop

btw, the sprite should be above the platform instead of overlapping (consider when player jumping under a platform), thus additional condition is needed, say player.y < platform.y ( more precise: (platform.y - player.y) - (player.height + platform.height) / 2 < epsilon )

1 Like