public void Mounting() { base.Start_Mounting(); IsOnHorse = true; Montura.EnableControls(true); //Enable Animal Controls if (CreateColliderMounted) { MountingCollider(true); } Montura.ActiveRider = this; Vector3 AnimalForward = Montura.transform.forward; AnimalForward.y = 0; AnimalForward.Normalize(); transform.rotation = Quaternion.LookRotation(AnimalForward, -Physics.gravity); OnMount.Invoke(); }
/// <summary> CallBack at the Start of the Dismount Animations</summary> public virtual void Start_Dismounting() { if (CreateColliderMounted) { MountingCollider(false); //Remove MountCollider } transform.parent = null; Montura.Mounted = Mounted = false; //Disable Mounted on everyone Montura.EnableInput(false); //Disable Montura Controls OnStartDismounting.Invoke(); if (Anim) { Anim.updateMode = Default_Anim_UpdateMode; //Restore Update mode to its original DisconectRiderAnims(); } else { End_Dismounting(); } UpdateCanMountDismount(); }
/// <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(); } }
///────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── /// <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.EnableControls(false); //Disable Montura Controls } Montura = null; //Reset the Montura toogleCall = false; //Reset the Call Animal // isInMountTrigger = false; //Reset the CanMount if (_rigidbody) //Reactivate stuffs for the Rider's Rigid Body { _rigidbody.useGravity = true; // _rigidbody.isKinematic = false; _rigidbody.constraints = DefaultConstraints; } if (Anim) { Anim.speed = 1; //Reset AnimatorSpeed } _transform.rotation = Quaternion.FromToRotation(_transform.up, -Physics.gravity) * _transform.rotation; //Reset the Up Vector; ToogleColliders(true); //Enabled colliders }
/// <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(); }
///────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── /// <summary> /// CallBack at the End of the Mount Animations /// </summary> public virtual void End_Mounting() { IsOnHorse = true; Montura.Mounted = Mounted = true; //Sync Mounted Values in Animal and Rider again Double Check transform.localPosition = Vector3.zero; //Reset Position transform.localRotation = Quaternion.identity; //Reset Rotation Montura.EnableControls(true); //Enable Animal Controls if (CreateColliderMounted) { MountingCollider(true); } //Montura.ActiveRider = this; }
public virtual void MountTriggerExit() { MountTrigger = null; if (Montura) { Montura.EnableInput(false); Montura.OnCanBeMounted.Invoke(false); Montura.NearbyRider = false; } Montura = null; MonturaAI = null; MountInput = null; OnFindMount.Invoke(null); UpdateCanMountDismount(); }
/// <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(); }
///────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── /// <summary> /// CallBack at the Start of the Dismount Animations /// </summary> public virtual void Start_Dismounting() { LinkToMount(false); //Unlink From Animal MountingCollider(false); //Remove the Mount Collider //Invoke UnityEvent when is off Animal if (CreateColliderMounted) { MountingCollider(false); //Remove MountCollider } Montura.EnableControls(false); //Disable Montura Controls Montura.ActiveRider = null; Montura.Mounted = mounted = false; //Disable Mounted on everyone if (!Anim) { End_Dismounting(); } }
/// <summary>CallBack at the End of the Mount Animations </summary> public virtual void End_Mounting() { Montura.Mounted = Mounted = IsOnHorse = true; //Sync Mounted Values in Animal and Rider again Double Check if (Parent) { transform.localPosition = Vector3.zero; //Reset Position when PARENTED transform.localRotation = Quaternion.identity; //Reset Rotation when PARENTED } MountInput?.Enable(true); Montura.EnableInput(true); //Enable Animal Controls if (CreateColliderMounted) { MountingCollider(true); } if (Anim) { Anim.updateMode = Montura.Anim.updateMode; //Use the Same UpdateMode from the Animal // Anim.updateMode = AnimatorUpdateMode.Normal; //Use the Same UpdateMode from the Animal Anim.SetBool(Montura.Animal.hash_Grounded, Montura.Animal.Grounded); Anim.SetInteger(Montura.Animal.hash_State, Montura.Animal.ActiveStateID); Anim.SetInteger(Montura.Animal.hash_Mode, Montura.Animal.ModeAbility); Montura.Animal.OnGrounded.AddListener(AnimalGrounded); Montura.Animal.OnStateChange.AddListener(AnimalState); Montura.Animal.OnModeStart.AddListener(AnimalMode); Montura.Animal.OnStanceChange.AddListener(AnimalStance); Anim.SetInteger(Montura.Animal.hash_Stance, Montura.ID); } OnEndMounting.Invoke(); UpdateCanMountDismount(); }
public virtual void EnableMountInput(bool value) { Montura?.EnableInput(value); }