How to check when a specific animation has finished?

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

Hi! So, I have this little contraption here, where once a button is clicked an animation plays and when it is clicked again the animation is played in reverse. What I needed it to do would be for it to send a signal for another object in the tree to move when the first animation is finished (the one before its version on reverse, the one that plays when you click the button for the first time)

Now, I’ve tried to just send the signal when the button is pressed for the first time, but that causes an anticipation, where the object starts moving before the first animation finishes playing.

here is the code:

extends AnimatedSprite

var playtime = 0

func _ready():
pass

func _on_ScrollButton_pressed():
print(“mango”)
self.play(“scroll”)
playtime += 1
print(playtime) #-> used to check if playtime is working

if playtime == 2:
	#print("paint") 
	self.play("scroll",true)
	playtime = 0
:bust_in_silhouette: Reply From: Wakatta

Try this