From fc40ba21cd3f26609065122c625fbe470c8a6c20 Mon Sep 17 00:00:00 2001 From: "Silc Lizard (Tokage) Renew" <61938263+TokageItLab@users.noreply.github.com> Date: Fri, 7 Jul 2023 14:33:08 +0900 Subject: [PATCH] Fix infinity loop state can't break --- scene/animation/animation_node_state_machine.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index 071e2e7f37ae..0254419d228e 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -901,18 +901,20 @@ bool AnimationNodeStateMachinePlayback::_transition_to_next_recursive(AnimationT bool is_state_changed = false; NextInfo next; - StringName transition_start = current; + Vector transition_path; + transition_path.push_back(current); while (true) { next = _find_next(p_tree, p_state_machine); - if (next.node == transition_start) { - is_state_changed = false; - break; // Maybe infinity loop, do noting more. + if (transition_path.has(next.node)) { + WARN_PRINT_ONCE_ED("AnimationNodeStateMachinePlayback: " + base_path + "playback aborts the transition by detecting one or more looped transitions in the same frame to prevent to infinity loop. You may need to check the transition settings."); + break; // Maybe infinity loop, do nothing more. } if (!_can_transition_to_next(p_tree, p_state_machine, next, p_test_only)) { break; // Finish transition. } + transition_path.push_back(next.node); is_state_changed = true; // Setting for fading.