how to make that when my animation finishes another one starts?

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

hello everyone! I would like to know how it is that I can make that when an animatedsprite 2d animation ends, another one begins and that it makes a loop or that if I have a key pressed and an animation is playing and as soon as I stop pressing the key another animation without loop begins and as soon as it finishes, the idle animation starts

:bust_in_silhouette: Reply From: Gluon

In the animated sprite if you go to the signals section you will see a signal “Animation_Finished”.

This signal will happen when that animated sprite finishes its animation so you can link this to a function in a script to restart a new animated sprite immediately. when you click on the signal it will prompt you to link it to a function in a script so it isnt too difficult.

You can just link it to a function which restarts a given animation or you could manually emit a signal with the animation name in if you wish, this requires a bit more setup but basically you can do it as below.

For a signal named animation_finished inside an object named anim.

Objects tell anim that they are interested to know when animation_finished happens.

anim.connect("animation_finished", interested_object, "function_to_call")

Anim eventually notifies everyone.

 emit_signal("animation_finished", animation_name)
(default nodes emit their signals automatically)

THANKS!!! It Helped Me a Lot

MegamanXfangamer | 2022-04-02 00:29