it just ignored and play previous hit animation
I'm assuming you mean that the animation continues playing from its current position rather than resetting to the beginning.
How do I stop the animation and play again immediately?
By stopping it and playing it again:
animation_player.stop()
animation_player.play("my_animation")
The docs on stop
say:
Stops the currently playing animation. If reset is true, the animation position is reset to 0 and the playback speed is reset to 1.0.
If reset is false, then calling play without arguments or play("same_as_before") will resume the animation.
As reset
defaults to false
, calling stop()
is sufficient.