Move_and_Slide_With_Snap Failing When Jump From Slope

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bribat123

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:

{{Correct}}
body beneath player → FloorBody
player on floor
jump start
linearvelocity.y in → -780
snap → (0, 0)
move_and_slide_with_snap
linearvelocity.y out → -780

{{Wrong}}
body beneath player → StaticBody2D
player on floor
jump start
linearvelocity.y in → -780
snap → (0, 0)
move_and_slide_with_snap
linearvelocity.y out → -5.005988

:bust_in_silhouette: Reply From: DiMiMi

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.

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.

bribat123 | 2020-03-03 15:53

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

DiMiMi | 2020-03-04 08:32