animation_finished signal instantly returning?

Godot Version

4.2.2

Question

Hey guys! New here so any help would be well appreciated! I have an animation tree linked up to my state machine and have it set so that it triggers the following code when the “attack” animation finishes playing:

1 func _on_animation_tree_animation_finished(anim_name):
2   if (anim_name == attack_anim_name):
3     if (character.is_on_floor()):
4		 next_state = ground_state
5	     playback.travel(return_anim)
6	     print("idle2")
7     else:
8	     next_state = air_state
9	     playback.travel(return_anim)
10	     print("idle3")

(sorry about the formatting I don’t know how blockquotes work…)

Now, the issue is sometimes when I’m hit while attacking my state machine gets confused and immedieatly switches back to the ground state (line 4) when I attack. This should only happen when the signal from the animation tree (which is the animation_finished signal from AnimationTree) triggers.

My qustion is if an animation is oneshot and done then does the animation_finished signal get continually triggered? Alternatively, are there situations where an animation can trigger this signal prematurely?

1 Like

your return anim isn’t in quotation marks…is that intended (you have a higher level var not showing?)? If not, that’s your issue. If you did intend it, I’m having same issue 4.3…my character either freezes or skips the animation altogether. I cannot figure out what I’m doing wrong!