animation_finished signal instantly returning?

Godot Version



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
6	     print("idle2")
7     else:
8	     next_state = air_state
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?