void OnAnimalStateChange(int state)
        {
            currentState.OnAnimalStateEnter(this, Animal.ActiveState);
            currentState.OnAnimalStateExit(this, Animal.LastState);

            if (RemoveAIOnDeath && state == StateEnum.Death)        //meaning this animal has died
            {
                for (int i = 0; i < currentState.tasks.Length; i++) //Exit the Current Tasks
                {
                    currentState.tasks[i].ExitTask(this, i);
                }

                Destroy(AIMovement.Agent.gameObject);
                Destroy(AIMovement);
                Destroy(this);
            }
        }
Beispiel #2
0
        void OnAnimalStateChange(int state)
        {
            currentState?.OnAnimalStateEnter(this, Animal.ActiveState);
            currentState?.OnAnimalStateExit(this, Animal.LastState);

            if (state == StateEnum.Death)                           //meaning this animal has died
            {
                for (int i = 0; i < currentState.tasks.Length; i++) //Exit the Current Tasks
                {
                    currentState.tasks[i].ExitAIState(this, i);
                }

                enabled = false;

                if (RemoveAIOnDeath)
                {
                    Destroy(AIMovement.Agent);
                    // AIMovement.enabled = false;
                    Destroy(AIMovement);
                    Destroy(this);
                }
            }
        }