How to play a non-looping animation until it is finished and otherwise play a looping animation?

I am using an AnimatedSprite2D node and don’t want to use await. I want to have a looping animation, then when a condition is met play a non-looping animation until it is finished, then move back to a looping animation. I cant seem to find the method to do this so help would be appreciated, thanks in advance!

You can connect the signal animation_finished()

In the handling function you can check / match self.animation and play the relevant animation.

Not sure if you want to avoid signals or just avoid an await in a particular function.

Edit: if you want it to be generic, like you play any animation and go back to the last one when it’s done, you can have a var _last_anim: String = "idle" and save the current anim before you change to a looping one, and then in the handler function change to the last anim if it’s not blank.

1 Like

I’ll be honest I didn’t know signals were a thing, so I’m glad to have had this problem to force me to learn. Thanks lol : D

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.