can i play animation once?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By vania23

i wanted to do the animation only one time, the fact of auto replay is very annoying,is there any easy way to disable auto replay? thank you

:bust_in_silhouette: Reply From: GrandeHolt

I am guessing its the looping? If so, you can turn that off in the right most part where you add seconds or fps. If not, maybe try to turn it off to the right where your animation names is.

:bust_in_silhouette: Reply From: Gluon

There are several possibilities depending on what you want to do exactly.

If you just want it to stop looping if you go into your animated sprite, if you go to the screen where you add the animations themselves you will see under the names of the animations the option to loop or not loop. If you turn that to not loop it will stop but it will stop on the last frame.

If you want it to show a different frame you will need some code;

$AnimatedSprite.frame = number

and what you can do is link the animation finished signal to this code. So if you go to the node on the main screen you will see an option to connect an animation finished signal. Here you can link it to either the signal above or if you want to make sure you only run it when a certain animation was playing you can use this

if $AnimationPlayer.current_animation == "name of animation"

to check if the animation is the one you want to freeze on a particular frame.

You could also use a boolean guard but I think in most cases this isnt the best option and you havent specified what you want to do exactly above so hopefully this will give you some pointers at least.