How to stop AnimationPlayer when finishing playing an animation?

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

I have a few animation clips, namely “idle”, “run”, “jumpUp”, “jumpDown”. idle and run are looping, and jump{Up,Down} are not.

Somehow the jump animations got played once only when triggered, and then it turns back to the “idle” animation, which is wrong.

What should I do to keep the animation stays at the last frame of the animation when play finished? I tried adding a “Call Func Track” to the animation and at the end key frame calling, but that does not seem to be called at all…

Did you call stop() on the AnimationPlayer before calling play() to start one of the none looping animations? Don’t know if this helps, I’m just guessing

atze | 2016-06-01 19:20

No, there is no stop() calls in my code. I assume theplay() should include that. Lemme try later. Thanks atze.

azurvii | 2016-06-01 23:10

No, that didn’t help :confused: It still turns to idle animation after playing the jump animations. And what’s interesting is that there is no transition from the jump to idle state, not like the other animation transitions having a blend time.

azurvii | 2016-06-02 13:55

Check on the animation track of your jumping animations if the loop option is enabled (circular arrows to the side of Step (s))

mafious | 2016-06-07 02:18

Thanks, but that was the first thing I checked, and the looping is off, which is correct – the issue is that the animation ends and continues to a different anim clip, not looping itself.

azurvii | 2016-06-07 02:23

:bust_in_silhouette: Reply From: pheryx

You could use the AnimationPlayer finished() signal. You’ll need to connect the AnimationPlayer node to the script that runs it. Something like this:

var anim = get_node('AnimationPlayer')

func jumpUp():
    anim.play('jumpUp')

func _on_AnimationPlayer_finished():
    anim.stop()