Animation does not loop

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Eduardo_Soares

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")

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

Eduardo_Soares | 2020-10-03 03:10

:bust_in_silhouette: Reply From: Siddharth Pushkar

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

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.

Eduardo_Soares | 2020-10-03 03:44

I was having this problem but i found that the “loop” button has 4 different settings.

white ping-pong,
white loop,
blue ping-pong,
blue loop.

It seems to loop properly when the icon is blue. I thought the animation would loop
when I saw the loop icon but it has to be high-lighted in blue for it to work.
A new user would find this confusing, I’ve seen a lot of people confused by this.
Suggestions from naming my looping animation to end in “-loop” to adding code.

There’s probably a dozen threads on this.