You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When animations in an AnimationTree are fired with a OneShot node with the "shot" being the output of a StateMachine the "End" state causes a frame of another animation to be played prior to returning to the "in" animation. This can be somewhat mitigated by not transitioning the StateMachine to the "End" state but then the OneShot stays "Active" and can cause issues elsewhere.
2024-07-12.14-08-51.mp4
Expected behavior is that there is no "twitch" to another animation when firing animations this way.
Steps to reproduce
Create an asset with 3 animations. I used a character from Blender with
"default" - t-pose, single frame
"idle" - hands to the sides, relaxed, single frame
"wave" - 16 frame animation of the character raising the right arm then lowering it
In a scene containing the asset, add an AnimationTree. Use AnimationNodeBlendTree as the tree root. Link it to the AnimationPlayer on the asset and ensure it's set to Active.
In the AnimationTree add 3 nodes
Animation - set this to the idle animation
OneShot - feed the previous Idle animation into the "In" socket and feed the output to the "Output" node
StateMachine - Create a state machine.
In the state machine, add an animation state with the action to be performed (in my case, "Wave"). From "Start" to "Wave" create a transition. Immediate switch, Auto mode, Note: In my video example above I used a "Wave" variable condition but removed it for these steps as it is not needed to reproduce.
From "Wave" to "End" add a transition. "At End" switch, Auto mode.
Back out to the Root of the AnimationTree. In the OneShot node, use the dropdown to fire the animation. The action animation will play, then it will play one frame of the "default" animation then return to the "idle" animation. The "default" animation is not even explicitly used yet it still somehow gets triggered.
This problem is not actually caused by the StateMachine performing a Reset at End, but rather by the StateMachine not performing a Reset (and don't apply any animation) at End. StateMachine has a Reset Ends option to control this. The default is false, so that the Reset process is not performed.
In the end, the reason for this is that the end of the StateMachine is determined "after" the End is reached, since there is nothing to play when the End is reached, so the Deterministic option is used to apply Reset when "there is nothing to play". Setting the Deterministic option to false solves this problem, but it causes another problem.
So, we may need to make the StateMachine end decision one frame earlier. Perhaps the correct fix is to start calculating the remaining time when _find_next detects that the next state is the End state. Related: #91215
For now, a workaround which may be a hack, but you can handle it by setting a very small fading duration (like 0.01) for the Transition to Ends.
TokageItLab
changed the title
Animation Tree's OneShot animations from a StateMachine cause a "twitch" to occur at the end of playback
To detect the end of the state machine, one frame is required after moving the End state
Jul 13, 2024
TokageItLab
changed the title
To detect the end of the state machine, one frame is required after moving the End state
To detect the end of the state machine, one frame is required after moving to the End state
Jul 13, 2024
Tested versions
System information
Godot v4.3.beta3.mono - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2080 (NVIDIA; 32.0.15.5612) - AMD Ryzen 7 3700X 8-Core Processor (16 Threads)
Issue description
When animations in an AnimationTree are fired with a OneShot node with the "shot" being the output of a StateMachine the "End" state causes a frame of another animation to be played prior to returning to the "in" animation. This can be somewhat mitigated by not transitioning the StateMachine to the "End" state but then the OneShot stays "Active" and can cause issues elsewhere.
2024-07-12.14-08-51.mp4
Expected behavior is that there is no "twitch" to another animation when firing animations this way.
Steps to reproduce
Create an asset with 3 animations. I used a character from Blender with
In a scene containing the asset, add an AnimationTree. Use AnimationNodeBlendTree as the tree root. Link it to the AnimationPlayer on the asset and ensure it's set to Active.
In the AnimationTree add 3 nodes
In the state machine, add an animation state with the action to be performed (in my case, "Wave"). From "Start" to "Wave" create a transition. Immediate switch, Auto mode, Note: In my video example above I used a "Wave" variable condition but removed it for these steps as it is not needed to reproduce.
From "Wave" to "End" add a transition. "At End" switch, Auto mode.
Back out to the Root of the AnimationTree. In the OneShot node, use the dropdown to fire the animation. The action animation will play, then it will play one frame of the "default" animation then return to the "idle" animation. The "default" animation is not even explicitly used yet it still somehow gets triggered.
Minimal reproduction project (MRP)
animtwitchtest.zip
The text was updated successfully, but these errors were encountered: