Example #1
0
        /// <summary>Finds the Main Animal used as Player on the Active Scene</summary>
        void FindMainAnimal()
        {
            activeAnimal = MAnimal.MainAnimal;
            if (player != null)
            {
                if (player.IsPrefab())
                {
                    InstantiateNewPlayer();
                }
                else
                {
                    activeAnimal = player.GetComponent <MAnimal>();
                }


                if (activeAnimal)
                {
                    activeAnimal.OnStateChange.AddListener(OnCharacterDead);  //Listen to the Animal changes of states
                    activeAnimal.TeleportRot(RespawnPoint.Value);             //Move the Animal to is Start Position
                    RespawnState = RespawnState ?? activeAnimal.OverrideStartState;
                    activeAnimal.OverrideStartState = RespawnState;
                }
            }
            else
            {
                activeAnimal = MAnimal.MainAnimal;

                if (activeAnimal != null)
                {
                    player = activeAnimal.gameObject;
                    FindMainAnimal();
                }
            }
        }