Restart Animation

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ville

How can I restart the same animation while it is currently playing? In Godot 3.0.6 I could just call play and the animation would start again. As a workaround I use the following code (but sadly it breaks the blending)

if anim_player.current_animation == "attack":
	anim_player.stop(true)
anim_player.play("attack", 0.2, 1.0)
:bust_in_silhouette: Reply From: Magso

Use seek

anim_player.seek(0, true) 

i get this error when i used seek

E 0:05:36.942 seek: Condition “!playback.current.from” is true.
<C++ Source> scene/animation/animation_player.cpp:1331 @ seek()
GameRules.gd:20 @ stop_wiggles()
GameRules.gd:40 @ _on_button_pressed()

mcroni | 2021-01-05 22:21

This happens if you’re not playing the animation before seeking. Calling play() before sets current_animation. If the animation isn’t set to play automatically current_animation defaults to ‘[Stop]’

Magso | 2021-01-06 21:20