godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.18k stars 19.97k forks source link

`RootStateMachine` does not calculate the remaining time until the transiton to `End` state actually occurs #79537

Closed nagasawamaki closed 1 month ago

nagasawamaki commented 1 year ago

Godot version

4.1.stable

System information

Godot v4.1.stable - Windows 10.0.19045 - Vulkan (Forward+)

Issue description

I found that, the fade out in one shot node is not working with a State Machine. I made two node, one for animation node and one for state machine as below:

圖片

And made two character scene as below: 圖片

The left one use pure animation node, while the right one is using state machine node.

You can see when blend out, they play different behaviour

圖片 The above is the internal of the state machine

I have attached a minimal reproduction project. When you hit play, you can press "z" key to see how the animation is blending out for the two nodes.

The bug is, there is no blending out when connecting state machine with one shot, even I have set blend out time in one shot node.

Thanks

Steps to reproduce

Open the minimal project, hit play, press z key.

The two character using the same anim tree, except one connecting a animation node with one shot node; the another one connecting a state machine node with the one shot node.

It may related to this issue: #66495

Minimal reproduction project

SM_Blending_Test_upload.zip

TokageItLab commented 1 year ago

Setting a fade to EndTransiton in the StateMachine will process fadeing correctly.

This behavior depends on the fact that the remaining time in the StateMachine is not "determined" until the transition to EndState is initiated. If the transition to EndState is branching, it cannot be determined if the StateMachine is really finished.

Alternatively, the fade can be done by setting the StateMachine type to Nested and disconnecting to the EndState. This is because NestedStateMachine considers a dead end to be an end. However, in this case, the resetting to StartState is not performed.

In this case, there are two possible improvements:

The latter is probably preferred for consistency of RootStateMachine.