I have tried checking if it is already playing, stopping animations before and putting it in a separate function. Whenever I jump it should play 4 Frames of my animated sprite. But it only plays first.

const FLOOR = Vector2(0,-1)
const SPEED = 500
const GRAVITY = 20
const JUMP = -600

func _physics_process(delta):
    pos.y += GRAVITY
    if Input.is_action_pressed("ui_right"):
        pos.x = SPEED
        $Sprite.flip_h = false
    elif Input.is_action_pressed("ui_left"):
        pos.x = -SPEED
        $Sprite.flip_h = true
        pos.x = 0
    if is_on_floor():
        if Input.is_action_just_pressed("ui_up"):
            pos.y = JUMP
        if pos.y < 0:
    pos = move_and_slide(pos,FLOOR)

1 Answer 1


You're telling your sprite to switch animations every frame while jumping, so it never gets past the first frame. Take a look at what code executes when is_on_floor() is true and pos.y < 0. You first try to play "Idle" (or "Run", if a direction key is pressed). Then you try to play "Jump", which starts at the first frame. On the next loop, you switch to "Idle" again, then back to "Jump" (resetting to the first frame).

Try to restructure your code so you are only calling play on one animation each loop.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .