+1 vote

Hello, I have recorded an output log that shows move-and-slide-with-snap failing when the player jumps from a platform with a slight slope upward. The player is a KinematicBody2D node. The platform is a StaticBody2D node. The base floor is a StaticBody2D node.

The log shows the following record info:
[platform beneath player]
[is player on floor]
[linear velocity passed into move-and-slide-with-snap]
[snap value passed into move-and-slide-with-snap]
[resulting linear velocity from move-and-slide-with-snap]

There are also lines indicating when the player starts jumping and when the jumping is completed. Here is the recorded output log summary:

body beneath player -> FloorBody
player on floor
jump start
linearvelocity.y in -> -780
snap -> (0, 0)
linearvelocity.y out -> -780

body beneath player -> StaticBody2D
player on floor
jump start
linearvelocity.y in -> -780
snap -> (0, 0)
linearvelocity.y out -> -5.005988

in Engine by (62 points)

1 Answer

0 votes

I have the same issue.

To prevent the player from sliding down, i just do

velocity.x = 0

under certain conditions (like no movement key is pressed). The player is then just sliding 1 px down and stops. I tried a lot because of this bug but nothing worked, so this was the only way to prevent it.

by (122 points)

Thanks for your reply, I will set velocity.x to 0. They kept telling me to use move-and-slide-with-snap but didnt tell me it was broken.

Np. Using "moveandslidewithsnap" is useful in general, but keep in mind that both "moveandslide" and "moveandslidewithsnap" come with some tricky things. For example: If you set the "stoponslope" parameter in the moveandslide methods "true", then you could have problems using platforms that are moving sideways.

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.