Godot Version
4.6
Question
Hello! I noticed that my animation gets stuck in one frame when I spam an Input and enter repeatedly into the same States, I am using an animation tree and an State Machine based on Nodes for the character animation. But when I spam an Input it get’s stuck in the first frame until it changes states. It happens with all of them, so I’m guessing that the problem is the same in all. Here is the code for the dashing forward state for example:
extends StateBaseChar
@onready var animation_tree: AnimationTree = $"../../Sprite3D/AnimationTree"
@warning_ignore("unused_parameter")
func on_process(delta):
char.state_machine.travel("dash_f")
char.velocity.x = char.DASHSPEED
char.move_and_slide()
animation_tree.animation_finished.connect(_on_AnimationPlayer_animation_finished)
func _on_AnimationPlayer_animation_finished(anim_name):
match(anim_name):
"dash_f":
if Input.is_action_pressed("derecha"):
state_machine.change_to("PlayerStateWalkf")
elif Input.is_action_pressed("izquierda"):
state_machine.change_to("PlayerStateWalkb")
elif Input.is_action_pressed("agacharse"):
state_machine.change_to("PlayerStateCrouch")
else:
state_machine.change_to("PlayerStateIdle")
I believe that I should check if the animation is already playing, but I’m not sure how to do it with how i’ve made the code so far, if any of you have an idea on how I could do it or another possible solution I would appreciate the help greatly