diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-11-30 17:05:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-30 17:05:17 +0100 |
commit | 5bf04d16f0720087df45539d1857cbdc239a4249 (patch) | |
tree | 71eb5f11ed41995d8ecc99a951a0c5d50cec8100 | |
parent | fc034be033bc6dce9f7db99ef5eaf47aa4331939 (diff) | |
parent | 598d769804f61d780e4fa48691c2ec7a842a46d4 (diff) |
Merge pull request #34011 from nekomatata/state-machine-travel-on-ready
Handle state machine travel before the start node is processed
-rw-r--r-- | scene/animation/animation_node_state_machine.cpp | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index 65bf1e0134..a37b75d428 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -312,27 +312,36 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st bool play_start = false; if (start_request != StringName()) { - if (start_request_travel) { if (!playing) { - String node_name = start_request; - start_request = StringName(); - ERR_FAIL_V_MSG(0, "Can't travel to '" + node_name + "' if state machine is not playing."); - } - - if (!_travel(p_state_machine, start_request)) { - //can't travel, then teleport - path.clear(); - current = start_request; + if (!stop_request && p_state_machine->start_node) { + // can restart, just postpone traveling + path.clear(); + current = p_state_machine->start_node; + playing = true; + play_start = true; + } else { + // stopped, invalid state + String node_name = start_request; + start_request = StringName(); //clear start request + ERR_FAIL_V_MSG(0, "Can't travel to '" + node_name + "' if state machine is not playing."); + } + } else { + if (!_travel(p_state_machine, start_request)) { + // can't travel, then teleport + path.clear(); + current = start_request; + } + start_request = StringName(); //clear start request } } else { + // teleport to start path.clear(); current = start_request; playing = true; play_start = true; + start_request = StringName(); //clear start request } - - start_request = StringName(); //clear start request } bool do_start = (p_seek && p_time == 0) || play_start || current == StringName(); |