0 votes

My Player keeps sliding to the right. I can move and jump just fine, but it keeps sliding to the right. It doesn't show in the code but I did extends KinematicBody2D.

const UP = Vector2(0, -1)
var motion = Vector2()

func _physics_process(delta):
      motion.y += 10

if Input.is_action_pressed("ui_right"):

    motion.x = 100

elif Input.is_action_pressed("ui_left"):

    motion.x = -100


else:

    motion.x = 0

if is_on_floor():
    if Input.is_action_just_pressed("ui_up"):
        motion.y = -400

move_and_slide(motion, UP)


pass
in Engine by (19 points)

1 Answer

0 votes

Hi,

Seems to work OK for me.

But take a look at this: PLATFORM CHARACTER

"Note that we’re checking isonfloor() after using moveandslide(). The moveandslide() function sets the value of this method, so it’s important not to check it before, or you’ll be getting the value from the previous frame."

by (1,865 points)
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.