+1 vote

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)
in Engine by (50 points)
edited by

1 Answer

+1 vote

Use seek

anim_player.seek(0, true) 
by (3,225 points)

i get this error when i used seek

E 0:05:36.942 seek: Condition "!playback.current.from" is true.
<C++ Source> scene/animation/animationplayer.cpp:1331 @ seek()
GameRules.gd:20 @ stop
wiggles()
GameRules.gd:40 @ onbutton_pressed()

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]'

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.