How to tweak animations (in AnimationPlayer) without messing with default values?

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

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.

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!

Hapiel | 2021-08-28 12:43

:bust_in_silhouette: Reply From: Surtarso

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

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.

PapaSolidus | 2020-11-24 05:16

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"myanimation")
    yield(animation_node, "animation_finished")

    than do this
    than do that

Surtarso | 2020-11-24 09:31