Example #1
0
        void OnTriggerExit(Collider other)
        {
            if (other.isTrigger)
            {
                return;
            }
            if (HeadOnly && !other.name.Contains(HeadName))
            {
                return;                                                     //if is only set to head and there's no head SKIP
            }
            MAnimal existing_animal = other.GetComponentInParent <MAnimal>();

            if (!existing_animal)
            {
                return;                                                              //If there's no animal script found skip all
            }
            if (existing_animal != CurrentAnimal)
            {
                return;                                                             //If is another animal exiting the zone SKIP
            }
            if (animal_Colliders.Find(item => item == other))                       //Remove the collider from the list that is exiting the zone.
            {
                animal_Colliders.Remove(other);
            }

            if (animal_Colliders.Count == 0)                                       //When all the collides are removed from the list..
            {
                OnExit.Invoke();                                                   //Invoke On Exit when all animal's colliders has exited the Zone

                if (zoneType == ZoneType.Stance && stanceAction == StanceAction.Stay && CurrentAnimal.Stance == stanceID.ID)
                {
                    CurrentAnimal.Stance_Reset();
                }

                ResetStoredAnimal();
            }
        }