0 votes

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..

in Engine by (112 points)

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

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

No, that didn't help :/ 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.

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

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.

1 Answer

+2 votes

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()
by (30 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.