public void PerformTransition(Transition transition) { if (transition == Transition.NullTransition) { Debug.LogError("StateManager PerformTransition(): NullTransition not allowed"); return; } StateID id = currentState.GetOutputState(transition); if (id == StateID.NullStateID) { Debug.LogError("StateManager PerformTransition(): " + currentStateID.ToString() + " does not have a next state for transition " + transition.ToString()); return; } currentStateID = id; foreach (NPCState state in states) { if (state.ID == currentStateID) { currentState.OnStateExit(); currentState = state; currentState.OnStateEntered(); break; } } }