godot

How do I loop an animation in a Godot animation player?


I'm trying to loop an idle animation that I have in an AnimationPlayer, but it keeps on only playing once. Is there any way for me to make it loop?


Solution

  • For Godot 4, to set the animation loop mode use Animation.loop_mode

    https://docs.godotengine.org/en/stable/classes/class_animation.html#enum-animation-loopmode

    var anim : Animation = $AnimationPlayer.get_animation(anim_name)
    anim.loop_mode = (Animation.LOOP_LINEAR)