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

[4.0] AnimationTree transition to sub-state machine node is erratic, e.g. repeats last animation at new animation speed #73648

Closed
Tracked by #73534
hsandt opened this issue Feb 20, 2023 · 0 comments · Fixed by #75759
Assignees
Milestone

Comments

@hsandt
Copy link
Contributor

hsandt commented Feb 20, 2023

Godot version

v4.0.rc2.official [d2699dc]

System information

Linux Ubuntu 20.04 with Unity desktop

Issue description

I'm trying an Animation Tree mixing simple animation nodes and sub-state machine nodes:

  • a sub-state node Stand containing sub-states Idle and Run
  • simple nodes like Attack (one-time) and Crouch (looping)

I have a transition from Stand to Crouch and Crouch to Stand (the top-level node, but could also be with Stand/Idle), with an expression condition. When the condition is true, I switch from Stand/Idle to Crouch immediately, as expected. When the condition is false, I go back to Stand/Idle, but visually the character plays yet another cycle of Crouch before actually switching.

I tested the same with a one-time Attack animation and got the same issue, except when the Attack animation is already over when I switch back to Stand/Idle. It also allowed me to see that Attack plays at an abnormal slow speed when that happens, as if it was mimicking the speed of the Idle animation (AnimationPlayer doesn't have a concept of speed, only keyframes, so I suspect it's more that it's changing sprite frames at around the same pacing, except the AnimatedSprite2D Animation is not properly updated).

The issue looks some some kind of bad blending between the old and new animation where we keep the old AnimatedSprite2D Animation but somewhat still uses the new animations frame number.

To simplify, I removed transition conditions and the Crouch node, so we just have an Attack node that immediately switches back to the sub-state machine node when it can. So basically when clicking on that node, we should never see the Attack animation, but we do see a slow one.

The duplicate Attack node below connected to nothing is just to demonstrate a normal, fast Attack animation. But even this one is not reliable, sometimes when you click, it doesn't play or plays slowly.

Below, I demonstrate the Attack animation once directly from the AnimationPlayer, then I test the AnimationTree, and play the Attack animation one last time from the isolated node.

AnimationTree transition to sub-state machine node is erratic

Pixel Slime by rvros (CC0 1.0)

Finally, the animation played in the sub-state machine is not always Idle, the one pointed by the sub-machine Start node. If you test-ran sub-node Run first, then Attack will transition to that one, not respecting sub-machine Start. In my real game it's okay because there is an instant transition between Idle and Run, but in some cases you may want the character to always enter from Start.

Steps to reproduce

  1. Open minimal repro project in the demo scene with the animated Slime
  2. You can test some animations in the Animation Player directly to observe the speed of Idle and Attack in particular. Make sure to stop preview at the end to avoid conflict with the Animation Tree.
  3. Select the Animation Tree and click play button on the Attack node connected to the sub-state machine. Repeat several times observing the slime => sometimes you'll see no Attack (correct), sometimes a very slow one (incorrect). If the animation is not slow, just repeated, try again after preview playing StateMachine > Idle to make sure it gets priority.
  4. You can try to play other animation nodes to compare.
  5. Bonus: Play StateMachine / Run node and repeat 3: note how Attack transitions into Run this time, although StateMachine Start connects to Idle

Minimal reproduction project

v4.0.rc2 - AnimationTree transition to sub-state machine with much slower animation repeats last animation slowly.zip

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.

3 participants