+1 vote

I'm constantly tweaking an sprite and properties animation to create "invincible frames"/"hurt frames". The animation player is so fun to mess with!

I'm having trouble figuring out if I can lock default properties values outside of code, as to not change everything every time I open an animation. My enemy scene is too simple, so there's no call for those properties on script.

My workaround was to create a "default values" animation just so I could reset upon finishing tweaking the others. But as I never actually has to play this animation, doesn't seem the most elegant solution.

in Engine by (16 points)
edited by

This is a great question, and I'm also looking for an elegant solution. Setting default values is really not great for scalability, especially if you later decide to change these default values..

I'm hoping someone comes up with a good fix!

1 Answer

+1 vote

add keyframe to all the defaults you want to keep on the very 1st keyframe and when you want to "reset" it on the same timeline you can click them on the beginning, drag the timeline to the point where you want them reset and click "duplicate keyframe"... might be tedious but works

another way is to create multiple animations inside the same animation player, being one of them "default" so you can duplicate and work with

a simple way to call for them in order on code is to yeild() one to finish before the other is called

also remember to drag the timeline to 0 when you switch animation coz the values will be kept if you switch animation in the middle of a tween timeline

by (363 points)

Thank you for being so thorough!

The solutions you offered are what I was doing before, I really expected that there were a more streamlined way to do that. I mean, given the nature of the node, there should be dedicated button on the animation player to "back to default" (being an animation you choose beforehand).

But now I'm intrigued by the "yeild()". I'm still green, so while I understood the implications of such method, not finding any mention of it on the online documentation is throwing me off.

to yield you need to point WHAT node you want to yield and what SIGNAL will yield() wait for from that node.

animation_node = $AnimationPlayer

func _whatever():
    do this
    do that

    animation_node.play("myanimation")
    yield(animation_node, "animation_finished")

    than do this
    than do that
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.