KinematicBody2D move_and_slide makes the player jump when on slopes

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

Hi there Godot community!

I’m playing around with the move_and_slide method on the KintematicBody2D node, and have stumbled upon some weird behavior. I made a Tilemap with a slope in it. The collision is a ConvexPolygonShape2D. When my player, which is a KinematicBody2D, moves up a slope, it kind of jumps up in the air. Here is a video to show it:

Here is what I think what happens: the player gets a horizontal and a vertical speed, because it has to move up the slope. When you stop moving, velocity.x becomes 0 but the velocity.y remains so the player seems to jump.
Code for the player is this:

Thank you in advance for helping me! It’s been fun toying with this engine.

I may not know a lot about the engine, and I may be crazy, but what if, when your character is on a part of the slope, jump and is_on_floor() (line 19 on the pastebin) gets fired off?

Ertain | 2018-04-16 17:56

Thanks for replying!

It shouldn’t fire because jump is only true if the jump button is pressed, which I’m not doing.

pizzapim | 2018-04-17 07:50

same behavior in 2.1 and same for a RigidBody2d. They just jump.

MrMonk | 2018-04-18 07:33