I would recommend having a boolean called something like animation_locked
. Then when you play an attack animation, you set the boolean to true
. If the boolean is true, then you let the animation play by adding conditions that check if animation_locked == false
before changing the animation. That should prevent another animation from overriding the currently playing animation.
To unlock the animation, I would suggest connecting the animation_finished
signal from the AnimationPlayer node and in the function the signal is connected to, set animation_locked
to false when the animation is finished.
Its perhaps not the best solution, but I have used this method several times without too much difficulty.
You could also look into using a state machine for your player and let each state in the machine handle its animations. Then with a state machine, you would just stay in the attack state until the animation is finished. It is a bit more complicated to setup though.