play AnimationPlayer in loop

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By socheat.khauv
:warning: Old Version Published before Godot 3 was released.

I would to play an animation of AnimationPlayer in repeated mode.

get_node(“AnimationPlayer”).play(“idle”)

the idle animation play, but it will stop at last the last key frame.

I would like to have it play repeatedly

:bust_in_silhouette: Reply From: volzhs

There is a button for looping.

Is there a way to change it from the code ?

socheat.khauv | 2016-07-29 02:31

var anim = get_node("AnimationPlayer").get_animation("idle")
anim.set_loop(true)
get_node("AnimationPlayer").play("idle")

volzhs | 2016-07-29 07:29

This worked perfectly! Thank you! I’ve spent more time on this than I’d like to admit.

tailgunner90 | 2019-06-11 00:15

thanks, that helped me.

morningkingdom | 2022-05-11 18:52