0 votes

I am working on vertical moving platforms which are KinematicBody2Ds with rectangular CollisionShape2Ds. The collision shapes have one_way_collision = true and a snap threshold of 1 pixel.

I move the platforms with a Tween, and both the tween and the KinematicBody2D are synced_to_physics.

Sometimes when my player lands on platforms that are moving upwards, he lands briefly before falling through the platform on the next frame.

I think what happens is that the player lands on the platform (changing his state to idle) and in the same frame the platform is moved a few pixels up, which puts the bottom of the player below the top of the platform causing the player to fall.

It only happens periodically when jumping onto the platforms, and happens when the player has very low y-velocity.

I though syncing everything to physics would avoid this, but it still happens periodically.

What gives, and is there a way to avoid this?

Ideally, I don't want to increase the collision shape's snap threshold, since I don't like the feeling of snapping up one-ways.

My player is a KinematicBody2D and I move him with move_and_slide_with_snap().

in Engine by (1,567 points)
edited by

You could make the player a child of the platform using an area with body_entered.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.