AnimationTree, Animation Looping via code

Godot Version

4.1.3 stable


How to enable animation looping via code? I have faced an annoying problem: after full cycle of animation playback, it stops, maybe on the last frame (running character becomes to standing still visually). It solves really eazy, just with Animation Looping button in AnimationPlayer.


I want to inplement this setting in my logic (not necessarily exactly the same method). My thoughts was: stop animation at the end and play it again (sucks), queue two animations one after another and clear queue on state exit (I think it also sucks), using signals (that complicated yet). I haven’t tried them, just sugessions.

Animation tree (all nodes are BlendSpace2D):


Move animation methods.

You can use the get_animation function, and after getting the reference to the animation, you can set it’s looping state with animation.loop_mode

1 Like

I will commit this to memory. For now I decided to use button.