public override void OnUpdate(MyStateMachine stateMachine) { if (m_instance == null) { foreach (var transitionNamesToVariableStorage in m_transitionNamesToVariableStorages.Values) { transitionNamesToVariableStorage.SetValue(MyStringId.GetOrCompute("Left"), true); } return; } if (string.IsNullOrEmpty(m_instance.TransitionTo)) { m_instance.Update(); } // trigger transition when script triggers complete method if (!string.IsNullOrEmpty(m_instance.TransitionTo)) { // Correct way to clear a cursor if (OutTransitions.Count == 0) { // Read the first cursor member var enumerator = Cursors.GetEnumerator(); enumerator.MoveNext(); var cursor = enumerator.Current; stateMachine.DeleteCursor(cursor.Id); } else { bool found = false; var sId = MyStringId.GetOrCompute(m_instance.TransitionTo); foreach (var outTransition in OutTransitions) { if (outTransition.Name == sId) { found = true; break; } } Debug.Assert(found, "State with outgoing transitions triggered non existent transition! Fix your scripts (or mission machines)!"); IMyVariableStorage <bool> storage; // unblock one of the transitions if (m_transitionNamesToVariableStorages.TryGetValue(MyStringId.GetOrCompute(m_instance.TransitionTo), out storage)) { storage.SetValue(MyStringId.GetOrCompute("Left"), true); } else { Debug.Fail("Transition was not found."); } } } }