override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            animator.SetInteger(Hash.MountSide, 0);               //Remove the side of the mounted ****IMPORTANT
            rider = animator.GetComponent <MRider>();             //Get the Rider

            alignTime    = rider.AlingMountTrigger;               //Get the Mount Trigger Time
            transform    = animator.transform;                    //Get the transform
            MountTrigger = rider.MountTrigger.transform;          //Get the MountTrigger for the Position

            AnimalScaleFactor = rider.Montura.Animal.ScaleFactor; //Get the Scale Factor on the Mount

            MalbersTools.ResetFloatParameters(animator);          //Set All Float values to their defaut (For all the Float Values on the Controller  while is not riding)

            Fix = rider.MountTrigger.Adjustment;                  //Get the Fix for the Mount Trigger

            rider.Start_Mounting();                               //Call Start Mounting
        }
Exemple #2
0
        /// <summary>CallBack at the End of the Dismount Animations</summary>
        public virtual void End_Dismounting()
        {
            IsOnHorse = false;                                                              //Is no longer on the Animal

            if (Montura)
            {
                Montura.EnableInput(false);                                              //Disable Montura Controls
                Montura.Rider = null;
                Montura       = null;                                                    //Reset the Montura
                MonturaAI     = null;
            }

            ToggleCall = false;                                                             //Reset the Call Animal

            if (RB)                                                                         //Reactivate stuffs for the Rider's Rigid Body
            {
                RB.useGravity = true;
                // RB.isKinematic = false;
                RB.constraints = DefaultConstraints;
            }

            if (Anim)
            {
                if (MountLayerIndex != -1)
                {
                    Anim.SetLayerWeight(MountLayerIndex, 0);                                //Reset the Layer Weight to 0 when end dismounting
                }
                Anim.speed = 1;                                                             //Reset AnimatorSpeed

                MalbersTools.ResetFloatParameters(Anim);
            }

            t.rotation = Quaternion.FromToRotation(t.up, -Physics.gravity) * t.rotation;    //Reset the Up Vector; ****IMPORTANT when  CHANGE THE GRAVIY

            ToogleColliders(true);                                                          //Enabled colliders

            if (DisableComponents)
            {
                ToggleComponents(true);                                                     //Enable all Monobehaviours breaking the Mount System
            }
            OnEndDismounting.Invoke();                                                      //Invoke UnityEvent when is off Animal

            UpdateCanMountDismount();
        }
        override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            animator.SetInteger(Hash.MountSide, 0);                 //Remove the side of the mounted **IMPORTANT*** otherwise it will keep trying to dismount

            rider       = animator.GetComponent <MRider>();
            ScaleFactor = rider.Montura.Animal.ScaleFactor;         //Get the scale Factor from the Montura

            MountPoint = rider.Montura.MountPoint;

            Fix = rider.MountTrigger.Adjustment;                    //Get the Fix fo the Dismount

            transform = animator.transform;
            rider.Start_Dismounting();

            transform.position = rider.Montura.MountPoint.position;
            transform.rotation = rider.Montura.MountPoint.rotation;

            LastRelativeRiderPosition = MountPoint.InverseTransformPoint(transform.position);

            MalbersTools.ResetFloatParameters(animator);
        }