Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CanvasItem-parameters set to unexpected defaults on RESET/AnimationTree's state transition unless explicitly set in RESET #73571

Closed
opgjoh opened this issue Feb 18, 2023 · 3 comments · Fixed by #80813

Comments

@opgjoh
Copy link

opgjoh commented Feb 18, 2023

Godot version

4.0rc2

System information

Windows 10

Issue description

When using the AnimationTree with AnimationTreeStateMachine, and transitioning from an Animation that set a Canvas-Item's color via "self_modulate" to the next Animation, the "self_modulate" - parameter is set to black.
If the "self_modulate"-parameter has been explicitly set to any other color in the "RESET"-track, then this color is chosen instead.
This is not only true for "self_modulate", I have also observed this issue with e.g. "scale" (which is set to 0), but haven't tested all parameters.

In Godot 3, it was possible to simply not set this parameter in the following animation. That allowed me to have two animations setting an elements color to, say, red or blue, and have a follow-up animation play that is the same between both.
Now, it seems that the "RESET"-animation is played inbetween, but unlike before, it seems to set a default color (black) to the self_modulate-parameter if it is not explicitly set? (Or a default scale, etc.)

This may be intended behaviour, in which case I have not found anything suggesting this in the documentation, but I may have missed it. :) I certainly would be able to understand if any "RESET"-track setting is used before switching to the next animation, then the issue becomes how to handle parameters not specified in the "RESET"-track.

Also, if it is intended, then importing such AnimationTree's into Godot 4 from Godot 3 breaks the animation.

Steps to reproduce

I have attached a Minimal Reproduction Project below, which includes two scenes: One for "self_modulate", and one for "scale".
To use, open one of the scenes, select the AnimationTree and click "Play" on the first animation (called "ToYellow" or "Grow", respectively). You should see that once the animation changes to the "Move"-animation, any change in color or size is reset to black or zero.

Alternatively, you can setup the demo yourself:

  • Create any Canvas Item (I used "Label"), an AnimationPlayer and an AnimationTree
  • Add an Animation that changes "Scale" or "Self_modulate" from default to any other obvious parameter
  • Add a new Animation that changes something else, e.g. the Position
  • Connect the AnimationTree to your Animation Player, then add a StateMachine
  • Add your animations and connect your first to your second (I use Transition "At End" with "Auto"). Remember to connect Start and End
  • Play the Animation: Once you transition to your second animation, the change from your first is lost.
  • In the RESET-track, add a new default for your parameter, and try it again: At the transition point, the reset-value is chosen.
  • If you remove the newly added setting from your RESET-track, the old behaviour is observed.

Minimal reproduction project

AnimationTreeReset.zip

@TokageItLab
Copy link
Member

It has been documented in https://docs.godotengine.org/en/latest/tutorials/animation/animation_tree.html#for-better-blending. Well, I guess we need to find a better solution for those initial values when we eventually implement godotengine/godot-proposals#5972.

@opgjoh
Copy link
Author

opgjoh commented Feb 21, 2023

Ah, you're absolutely right! I didn't think to check the Tutorial again. This change (resetting on node switching) does make sense to me after reading through #70207.

In that sense, I suppose this might be considered some kind of documentation issue?
Adding the info to AnimationNodeStateMachine and AnimationNodeStateMachinePlayback that a change during "travel" sets up the next animation via "RESET", and how unspecified parameters are handled. (And maybe link these two nodes somewhere on the AnimationTree-documentation!)

I might try my hand on creating a pull request for the documentation on that.

In any case, thanks for the links and the info!

How is the procedure now? Should I close this issue or should this be done by someone else? :)

@TokageItLab
Copy link
Member

It can be opened as a documentation issue for the StateMachine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants