Fix infinity loop state can't break

(cherry picked from commit fc40ba21cd)
This commit is contained in:
Silc Lizard (Tokage) Renew 2023-07-07 14:33:08 +09:00 committed by Yuri Sizov
parent f5addd583d
commit ed9c091a92
1 changed files with 6 additions and 4 deletions

View File

@ -901,18 +901,20 @@ bool AnimationNodeStateMachinePlayback::_transition_to_next_recursive(AnimationT
bool is_state_changed = false; bool is_state_changed = false;
NextInfo next; NextInfo next;
StringName transition_start = current; Vector<StringName> transition_path;
transition_path.push_back(current);
while (true) { while (true) {
next = _find_next(p_tree, p_state_machine); next = _find_next(p_tree, p_state_machine);
if (next.node == transition_start) { if (transition_path.has(next.node)) {
is_state_changed = false; 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 noting more. break; // Maybe infinity loop, do nothing more.
} }
if (!_can_transition_to_next(p_tree, p_state_machine, next, p_test_only)) { if (!_can_transition_to_next(p_tree, p_state_machine, next, p_test_only)) {
break; // Finish transition. break; // Finish transition.
} }
transition_path.push_back(next.node);
is_state_changed = true; is_state_changed = true;
// Setting for fading. // Setting for fading.