1
\$\begingroup\$

When the player hit something, I'm playing hit animation from animation_player. However when player hit something while hit animation is playing, it just ignored and play previous hit animation.

I need to stop the animation, but couldn't find any related information. How do I stop the animation and play again immediately?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .