0 votes

Video of the Glitch

Been following a couple video tutorials on YouTube, but my character slowly slides down any walls that he comes in contact with if you're holding the direction towards the wall.

if !global.on_ice:
    if global.left and !global.right:
        x_speed = -MAX_RUN_SPEED
    elif !global.left and global.right:
        x_speed = MAX_RUN_SPEED
    else:
        x_speed = 0
else:
    if global.left and !global.right and x_speed > -MAX_RUN_SPEED:
        x_speed -= ICE_ACCEL
    elif !global.left and global.right and x_speed < MAX_RUN_SPEED:
        x_speed += ICE_ACCEL
    else:
        if x_speed > 0:
            x_speed -= ICE_ACCEL
        if x_speed < 0:
            x_speed += ICE_ACCEL
    x_speed = clamp(x_speed, -MAX_RUN_SPEED, MAX_RUN_SPEED)

    y_speed += GRAVITY * delta

    if y_speed > MAX_GRAV:
        y_speed = MAX_GRAV

    velocity.x = x_speed * delta
    velocity.y = y_speed * delta
    #Move the sprite and handle collisions
    var motion = move(velocity)
    #Check for collision
    if is_colliding():
        var n = get_collision_normal()
        var final_motion = n.slide(motion)
        velocity = n.slide(velocity)
        #Reset Y Speed
        y_speed = 0
        #Move the player.
        move(final_motion)
in Engine by (197 points)

Not sure what is causing the problem, but I think that you don't need to multiply yspeed with delta in velocity.y, becasue you are already adding delta in yspeed above.

I require your move_and_slide code to see if it could be the problem

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.