0 votes

Hello, idk what is causing this problem, but in this platform, when the player going up activate my "falling" state, but when goes down the player stay 1 pixel abode the collision shape of the platform.

Here's my code:

func state_fall(delta):
    vel.y = vel.y + grav * delta
    var dir = Input.get_action_strength("direita") - Input.get_action_strength("esquerda")
    if abs(dir) > 0:
        dir_sprite = sign(dir)
        vel.x = speed * sign(dir)
    else:
        vel.x = 0
    $anims.play(anim + str(dir_sprite))
    vel = move_and_slide(vel, Vector2.UP)

    if Input.is_action_just_pressed("mouse"):
        init_attack()

    if Input.is_action_just_pressed("jump") and jumps < 1:
        jumps += 1
        init_jump()

    if is_on_floor():
        jumps = 0
        if abs(vel.x) > 0:
            init_run()
        else:
            init_idle()

And here the image:
enter image description here

in Engine by (171 points)

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.