0 votes

I have an animated sprite with an animation set as a loop, and it doesn't loop in game. The code is below.

Ps: "$Sprite" is an animated sprite.

func _physics_process(delta):
if Input.is_action_pressed("right"):
    velocity.x = lerp(velocity.x, MAXSPEED, ACCELERATION)
    $Sprite.flip_h = false
    if velocity.x != MAXSPEED:
        $Sprite.play("start_walking")
    else:
        $Sprite.play("walking")
elif Input.is_action_pressed("left"):
    velocity.x = lerp(velocity.x, - MAXSPEED, ACCELERATION)
    $Sprite.flip_h = true
    if velocity.x != MAXSPEED:
        $Sprite.play("start_walking")
    else:
        $Sprite.play("walking")
else:
    velocity.x = lerp(velocity.x, 0, 0.2)
    $Sprite.play("idle")
in Engine by (14 points)

I forgot to mention, the animation that does not loop is the "walking" animation.

1 Answer

–1 vote

if you want to loop your animation

first:- If you see where the animation duration is (where the seconds of the animation is) to the right side of the animation UI and there you can see a double arrow loop Symbol just click that you animation will loop

if you want your animation to start as soon as the scene starts then to the right to the animation UI you can see the "edit" text and to the left side of the "edit" text there is an arrow-like symbol which is pointing to the "edit" text click that and when you play the scene the animation will start automatically

by (39 points)

I already clicked the loop button, and I want the animation to play after the "start_walking" animation, which is not a loop, but the "walking" one is, and it doesn't play again.

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 Frequently asked questions and 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 [email protected] with your username.