This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+2 votes

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 (63 points)
edited by

1 Answer

+2 votes

Use seek

anim_player.seek(0, true) 
by (3,259 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 Frequently asked questions and 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 [email protected] with your username.