public void ChangeState(AIState newstate) { if (AIState == newstate) { return; } Debug.Log(newstate); if (_currentBehaviour) { _currentBehaviour.ExitBehaviour(); } AIState = newstate; switch (newstate) { case AIState.Calm: _currentBehaviour = GetNextBehaviour(CalmBehaviours, _usedCalmBehaviours); break; case AIState.Sense: _currentBehaviour = GetNextBehaviour(SenseBehaviours, _usedSenseBehaviours); break; case AIState.Agessive: _currentBehaviour = GetNextBehaviour(AggressiveBehaviours, _usedAggressiveBehaviours); break; case AIState.Dead: _currentBehaviour = null; break; default: break; } if (_currentBehaviour) { _currentBehaviour.EnterBehaviour(); } }