// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { //animatorListener = animator.GetComponent<IAnimatorBehaviour>(); //if (animatorListener != null) animatorListener.OnStateEnter(Hash.Tag_Unmounting, stateInfo, layerIndex); #region OldWay animator.SetInteger(Hash.MountSide, 0); //remove the side of the mounted **IMPORTANT*** otherwise it will keep trying to dismount rider = animator.GetComponent <Rider3rdPerson>(); ScaleFactor = rider.Montura.Animal.ScaleFactor; //Get the scale Factor from the Montura LeftFoot = animator.GetBoneTransform(HumanBodyBones.LeftFoot); RightFoot = animator.GetBoneTransform(HumanBodyBones.RightFoot); MountPoint = rider.Montura.MountPoint; BottomPosition = MountPoint.InverseTransformPoint((LeftFoot.position + RightFoot.position) / 2); //Convert it to Local Space HipPosition = MountPoint.InverseTransformPoint(animator.rootPosition); //Convert it to Local Space Fix = rider.MountTrigger.Adjustment; //Store the Fix transform = animator.transform; rider.Start_Dismounting(); transform.position = rider.Montura.MountPoint.position; transform.rotation = rider.Montura.MountPoint.rotation; LastRelativeRiderPosition = MountPoint.InverseTransformPoint(transform.position); #endregion }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 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 <Rider3rdPerson>(); ScaleFactor = rider.Montura.Animal.ScaleFactor; //Get the scale Factor from the Montura Vector3 LeftFoot = animator.GetBoneTransform(HumanBodyBones.LeftFoot).position; Vector3 RightFoot = animator.GetBoneTransform(HumanBodyBones.RightFoot).position; laspos = (LeftFoot + RightFoot) / 2; MountPosition = animator.rootPosition; Fix = rider.MountTrigger.Adjustment; //Store the Fix transform = animator.transform; rider.Start_Dismounting(); hip = animator.GetBoneTransform(HumanBodyBones.Hips); //Get the Hip Bone }