0 votes

I'm trying to make functional moving platforms with one way collisions enabled. Both the player and the platform are kinematic2d. Horizontal moving platforms? No problem. But if I try to move the platform vertically, two problems occur:

  1. Moving down, the player "floats" 1 pixel above the platform.
  2. Moving up, the player "sinks" 1 pixel below the platform, and falls through.

Has anyone encountered this before? Are there any tricks to avoid this behavior? I can avoid falling through by disabling one way collisions, but that still leaves the floating/sinking behavior and doesn't meet my design goals.

in Engine by (74 points)

This should be fixed in ver. 3.1 (with "Sync to Physics" option). Read more: https://godotengine.org/article/godot-31-will-get-many-improvements-kinematicbody

Yeah, I know. But with no release date, I don't want to wait around for something that may or may not come soon. Looking for a work-around.

Hi, as you know, it's a known bug... according to this link the fix will also be included in next 3.0 release (i suppose earlier than 3.1).

I've seen a work arround for angled one way surfaces in this video with ray cast. I think the same should work with platforms moving up. For platforms moving down, perhaps getfloorvelocity ( ) can help you update the velocity of your player (if it's a kinematicbody2d) so it does not float. If you can share the code, may be we can try some workarround.

I tested a solution where A. I disabled onewaycollision when the platform was moving up and B. adjusted the offset of the sprite when it was floating. It looked "okay", was somewhat unreliable (only worked maybe 90% of the time). It could probably work great with a bit more refinement... But it seems like a lot of effort when the horizontal platforms work perfect with no code at all. I might just hold off until 3.1 unless I can figure out a more elegant solution.

Hi, you coud also build godot from source yourself.. it's really easy and the solution is implemented there. I've tested it.

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.