Exemplo n.º 1
0
        /// <summary>Set all the correct atributes and variables to Start Mounted on the next frame</summary>
        public void Start_Mounted()
        {
            if (MountStored)
            {
                Montura   = MountStored;
                MonturaAI = Montura.GetComponent <IAIControl>();

                StopMountAI();

                Montura.Rider = this;

                if (MountTrigger == null)
                {
                    Montura.transform.GetComponentInChildren <MountTriggers>(); //Save the first Mount trigger you found
                }
                Start_Mounting();
                End_Mounting();

                Anim?.Play(Montura.MountIdle, MountLayerIndex);               //Play Mount Idle Animation Directly

                Montura.Mounted = Mounted = true;                             //Send to the animalMount that mounted is active

                OnAlreadyMounted.Invoke();

                UpdateRiderTransform();
            }
        }
Exemplo n.º 2
0
        /// <summary>CallBack at the Start of the Mount Animations</summary>
        public virtual void Start_Mounting()
        {
            Montura.Rider   = this;                                  //Send to the Montura that it has a rider
            Montura.Mounted = Mounted = true;                        //Sync Mounted Values in Animal and Rider
            MountInput      = Montura.GetComponent <IInputSource>(); //Get the Input of the controller

            StopMountAI();

            if (RB)                                                 //Deactivate stuffs for the Rider's Rigid Body
            {
                RB.useGravity = false;
                // RB.isKinematic = true;
                DefaultConstraints = RB.constraints;                //Store the Contraints before mounting
                RB.constraints     = RigidbodyConstraints.FreezeAll;
            }

            ToogleColliders(false);                         //Deactivate All Colliders on the Rider IMPORTANT ... or the Rider will try to push the animal

            ToggleCall = false;                             //Set the Call to Stop Animal
            CallAnimal(false);                              //If is there an animal following us stop him

            MountStored = Montura;                          //Store the last animal you mounted

            if (Parent)
            {
                transform.parent = Montura.MountPoint;
            }

            if (!MountTrigger)
            {
                MountTrigger = Montura.GetComponentInChildren <MountTriggers>();         //If null add the first mount trigger found
            }
            if (DisableComponents)
            {
                ToggleComponents(false);                                                //Disable all Monobehaviours breaking the Riding System
            }

            OnStartMounting.Invoke();                                                   //Invoke UnityEvent for  Start Mounting

            Anim?.SetLayerWeight(MountLayerIndex, 1);                                   //Enable Mount Layer set the weight to 1

            if (!Anim)
            {
                End_Mounting();                                                         //If is there no Animator  execute the End_Dismounting part
            }
            UpdateCanMountDismount();
        }