godotengine / godot

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

A Grouped AnimationNodeStateMachine throws warnings and errors but seems to work fine otherwise #88878

Open mrcdk opened 8 months ago

mrcdk commented 8 months ago

Tested versions

Reproducible in: v4.2.1.stable.arch_linux, v4.3.dev3.official [36e943b6b]

System information

Godot v4.3.dev3 - Manjaro Linux #1 SMP PREEMPT_DYNAMIC Sat Feb 10 09:40:02 UTC 2024 - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 Laptop GPU () - AMD Ryzen 9 5900HX with Radeon Graphics (16 Threads)

Issue description

When traveling into a node in an AnimationNodeStateMachine which type is Grouped using the root state machine's AnimationNodeStateMachinePlayback a couple of warnings and errors will appear in the Debugger tab.

Root state machine:

image

Inner state machine attack (set as Grouped):

image

Steps to reproduce

In a script, using the AnimationNodeStateMachinePlayback of the root state machine, try traveling to a node in the inner state machine. In the Debugger the following warnings and errors will appear:

W 0:00:02:0772   _set_current: There are two or more transitions from the Start of Grouped AnimationNodeStateMachine in AnimationNodeStateMachine: parameters/attack, which may result in unintended transitions.
  <C++ Source>   scene/animation/animation_node_state_machine.cpp:226 @ _set_current()
W 0:00:02:0772   _set_current: There are two or more transitions to the End of Grouped AnimationNodeStateMachine in AnimationNodeStateMachine: parameters/attack, which may result in unintended transitions.
  <C++ Source>   scene/animation/animation_node_state_machine.cpp:229 @ _set_current()
E 0:00:02:0772   _set_current: There is a mismatch in the number of start transitions in and out of the Grouped AnimationNodeStateMachine on AnimationNodeStateMachine: parameters/attack.
  <C++ Source>   scene/animation/animation_node_state_machine.cpp:232 @ _set_current()
E 0:00:02:0772   _set_current: There is a mismatch in the number of end transitions in and out of the Grouped AnimationNodeStateMachine on AnimationNodeStateMachine: parameters/attack.
  <C++ Source>   scene/animation/animation_node_state_machine.cpp:235 @ _set_current()

But it seems to work fine otherwise.

Minimal reproduction project (MRP)

test_grouped_state_machine.zip

It's just a tscn file. Press ui_accept to toggle from idle to attack/cut or attack/slash and back.

TokageItLab commented 8 months ago

This is the intended behavior: the Transitions to Start and End in a GroupedStateMachine refer to the Transitions of the parent, so correctness for the behavior is not guaranteed if their numbers do not match. To solve this problem correctly, an implementation such as indexes to tie between ports and transitions together is required. See also https://github.com/godotengine/godot/pull/75759 description.

If the parent has only one Transition and the GroupedStateMachine has more Transitions than the parent, some consistency is guaranteed, but that would be the only exception.

If the parent has no Transitions and the GroupedStateMachine has Transitions, it will be broken because there is nothing to reference. Also, if the parent has more Transitions than GroupedStateMachine, the user cannot decide neither know which Transition will be referenced.

mrcdk commented 8 months ago

Uhm, I see. I think I get what you mean. So the transitions that go to and from a GroupedStateMachine need extra information like to which node to go when starting and which transition to use when ending, right? Makes sense. Right now, in my example, if I were to do travel("attack") it wouldn't know to which node in the grouped state machine to go.