#How to see when animation finishes?

13 messages · Page 1 of 1 (latest)

tight monolith
#

This is probably very easy question, but I just cannot find the answer anywhere. I have an AnimatedSprite2D with a lot of animations in it. How do print("yes") for example when "animation1" finishes?

daring hound
#

func _ready():
gun_animation.animation_finished.connect(on_animation_finished)

func on_animation_finished(_arg):

#

where the _arg is the name of the animation that was finished. So if you have an animation called "shoot" and animation called "reload" it will be called for both so you might want to do a check if you only want logic to happen for one or the other

tight monolith
#

patientSprite.animation_finished.connect(on_animation_finished) func on_animation_finished(_arg):
if _arg == "animation1":
print("yes")
else:
print("no")

#

is this how? bcuz nothing is happening

mortal berry
#

Maybe 🤔

patientSprite.connect(on_animation_finished)                                                                                                                                                        func on_animation_finished(_arg):
           if _arg == "animation1":
                 print("yes")
             else:
                  print("no")
narrow viper
#
@onready var animated_sprite: AnimatedSprite2D = $AnimatedSprite2D

func _ready() -> void:
    animated_sprite.animation_finished.connect(func():
        if animated_sprite.animation == &"animation1":
            print("yes")
    )
narrow viper
narrow viper
narrow viper
#

If it doesn't work, it is because you did bad your animation config. You must disable loop. If loop is enable, then animation doesn't finish. godot

tight monolith
#

holy shit you're right thank you so much

narrow viper
#

No problem