public void Update(BehaviourStateMachine stateMachine) { for (int i = 1; i <= memoryInterruptions.Count; ++i) { var it = memoryInterruptions[i - 1]; MemoryEvent ev = stateMachine.memory.SearchInMemory(it.eventType); if (ev != null && ev.GetState() == it.eventState) { //Debug.Log(i + "; " + it.eventType + "; " + it.eventState); stateMachine.target = ev; if (lastInterruptionType != i) { lastInterruptionType = i; stateMachine.SetCurrentBehaviour(it.entry); } return; } } { //Debug.Log("neutral"); stateMachine.target = null; if (lastInterruptionType != 0) { lastInterruptionType = 0; stateMachine.SetCurrentBehaviour(neutralEntry); } } }