#AnimationPlayer and finished() Signal issue.

14 messages · Page 1 of 1 (latest)

hallow gulch
#

if Input.is_action_just_pressed("ui_a_button"):
isAttacking = true
print("attacking")
$AnimationPlayer.play("Attack" + currentDirection)
print("attackingover")
func _on_animation_finished():
print("doneattacking")
if isAttacking:
isAttacking = false
print("doneattacking")

added info, currentDirection is a string.
signal is in place.
So im running into two issues, first the attack animation isnt playing for what ever reason, my movement animations which are set up the same way work fine. Second the on animation finished isnt being called. i set up prints to helpout. Attacking, Attackingover are being printed. Both doneattacking are not printing. All i wish to do here is set isAttacking to true so my character cannot do movement inputs while the character isAttacking, then when the animation is finished, it will set isAttacking back to false so i can move again.

limpid ridge
#

could the movement animations be overriding the attack animations?

hallow gulch
#

no when i hit the ui_a_button it sets attacking to true, and i have movement check that, so if true then you cannot move. Everyone i talk to says it looks right. i get no errors or even warnings. When i remove the signal, the attack animation plays, but if i throw an await in the mix to use that to continue the code after the animation it doesnt come out of the await.
I also made sure that the animations for attacking were not looping.

frank smelt
#

Hey, @hallow gulch try using the animation name in your signal-handling method _on_animation_finished(anim_name).

IIRC that signal will trigger every time an animation finishes, including your movement animations. They might be finishing and turning off isAttacking right before/during your attack animation? That is my hunch. Or you can even just have that method print the name of the animation that just finished. I handled this like this in my 3.4 game; I think it would work similarly in 4.x:

func _on_AnimationPlayer_animation_finished(anim_name):
    if anim_name == "title":
        is_dead = true
        if anim_name == "landing":
        has_landed = true
        # Reset fall damage state
        fall_damage = false

etc.

hallow gulch
#

I have tried this, the issue i was having is the func was not being called at all, either way.

#

func _on_animation_finished(): is not being called no matter what.

#

when i delete the signal then the animation plays, but the await function gets stuck

#

await $AnimationPlayer.animation_finished

#

i could hop into a channel for realtime replies as well if you want

hallow gulch
#

So after some trouble shooting, i did an on animation start and finish, the start fires off, but the finish doesnt. I think the issue might be that my animations are looping even though they arnt told to do so.

limpid ridge
#

yes, looping animations do not fire animation_finished

hallow gulch
#

yea they are not looping, at least if they are its not looping anywhere else. This seems to be super bizare

hallow gulch
#

omg i figured it out, so i have an animationplayer.pause() function that was being called, since when im attacking im not moving is how i pause it so. Super frustrating on my part, to waste so many days to figure it was somethign so simple.

#

thanks to Gwiss helped me figure it out.