Attention
Topic was automatically imported from the old Question2Answer platform.
Asked By
AbDevTM
I’m trying to fix my player animation in such a way that Every time an animation is triggered, the RESET animation is played before that animation to fix any errors with my animation. Please I really need help on this
It looks like the RESET option is mainly (if not only) for the editor. Have you tried anything else to fix your issue? What I’ll do is have animations where the initial values in the animation track are the same as the final values. Not the best answer, but it’s worked for me before.
Ertain | 2023-06-02 23:31
Reply From:
ShatteredReality
You could just transfer all the keys from the reset animation to your other animations. Or just call play(“RESET)” before you call the animation.
1 Like
hsandt
April 23, 2024, 1:43pm
3
See this issue:
opened 07:05PM - 03 Mar 23 UTC
topic:animation
### Describe the project you are working on
A platformer with 2D sprite anima… tions
### Describe the problem or limitation you are having in your project
Extra track properties not present in all my animations, such as brightness value, are not reset to their default values set in scene nor to RESET animation values when switching from an animation using them to a new animation not using them.
This causes leftover properties as in the GIF below where the character keeps their Hurt animation brightness after restart to Fall and Idle animation:

When Hurt animation overrides brightness:

but Fall and Idle do not:

I added the tracks to RESET animation, to no avail:

According to the documentation, this is by design as RESET is only used when Saving in editor.
### Describe the feature / enhancement and how it helps to overcome the problem or limitation
Adding an option to AnimationPlayer to reuse RESET property values as default track animations would make runtime benefit from this nice editor feature.
This is similar to Unity's "Write Defaults" property (https://docs.unity3d.com/Manual/class-State.html), which is very convenient to avoid defining the same extra properties on every animation when only a minority of them really need to animate them.
### Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
- Add AnimationPlayer exposed property `use_reset_animation_as_default` or something like this.
- If checked:
- on start, any property present in RESET but not set in the first animation uses the RESET animation value
- on animation change, any property set in RESET but not the new animation is reverted to the value in RESET animation (we could also only set it if it was actually set by the previous animation; but it won't reset it if we changed said property as runtime via code, which may be desired or not depending on design)
Note: for blended transitions we'd need to think a little more how to work. I suggest to use the RESET animation value as if it was actually defined in the target animation not having it, and blend toward it.
### If this enhancement will not be used often, can it be worked around with a few lines of script?
It can be worked around via code by switching to RESET animation, forcing properties refresh then switching to wanted animation. I tested the following code below and it works:
```gd
animation_player.play(&"RESET")
animation_player.advance(0)
animation_player.play(animation_name)
# extra advance required if you do this at the end of the frame,
# e.g. in _on_animation_player_animation_finished callback,
# to avoid showing default state for 1 frame
animation_player.advance(0)
```
Alternatively, if you know which extra properties are missing from some animations, you can manually reset them in code.
It can be worked around by changing data, but you need to add missing properties to every animation.
### Is there a reason why this should be core and not an add-on in the asset library?
Yes, it's adding a field to built-in AnimationPlayer.
Currently my workaround is to play RESET manually as suggested by @shatteredreality but adding extra advance to ensure the first frame is immediately used:
animation_player.play(&"RESET")
animation_player.advance(0)
animation_player.play(animation_name)
# extra advance required if you do this at the end of the frame,
# e.g. in _on_animation_player_animation_finished callback,
# to avoid showing default state for 1 frame
animation_player.advance(0)
3 Likes