浏览代码

Fix AnimationNodeStateMachinePlayback start() on nonexistent node

Florian Kothmeier 4 年之前
父节点
当前提交
b6e7df56cb
共有 1 个文件被更改,包括 11 次插入5 次删除
  1. 11 5
      scene/animation/animation_node_state_machine.cpp

+ 11 - 5
scene/animation/animation_node_state_machine.cpp

@@ -334,11 +334,17 @@ float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_st
 			}
 			}
 		} else {
 		} else {
 			// teleport to start
 			// teleport to start
-			path.clear();
-			current = start_request;
-			playing = true;
-			play_start = true;
-			start_request = StringName(); //clear start request
+			if (p_state_machine->states.has(start_request)) {
+				path.clear();
+				current = start_request;
+				playing = true;
+				play_start = true;
+				start_request = StringName(); //clear start request
+			} else {
+				StringName node = start_request;
+				start_request = StringName(); //clear start request
+				ERR_FAIL_V_MSG(0, "No such node: '" + node + "'");
+			}
 		}
 		}
 	}
 	}