How to make moving platforms with one-way collision

Godot Version

Godot 4.2

Question

I have a moving platform which is an AnimatableBody2D with one-way collision enabled and a CharacterBody2D as the player. When the player lands on the moving platform while the platform is moving downwards, jittery behavior will occur where is_on_floor() for the player switches between true and false every frame. This only happens when landing on the platform after being in midair, standing on the platform as it begins to move down behaves fine. What might I be doing wrong? Let me know if more info should be provided.

Ok I solved this immediately after posting this, embarrassing but typical for me. I’ll leave my fix here anyway for anyone else who might have a similar problem.

Change the “One Way Collision Margin” of the CollisionShape2D of your one way moving platform to be much larger. Its 1px by default, I set mine to 5px and it fixes it for a high-speed moving platform without being noticeable in normal scenarios.

1 Like