///────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── /// <summary> /// Syncronize the Horse/Rider animations if Rider loose sync with the animal on the locomotion state /// </summary> protected virtual void Animators_ReSync() { if (!Anim) { return; } if (!Montura.syncAnimators) { return; //Don't Sync animators when that parameter is disabled } if (Montura.Animal.AnimState == AnimTag.Locomotion) //Search for syncron the locomotion state on the animal { RiderNormalizedTime = Anim.GetCurrentAnimatorStateInfo(MountLayerIndex).normalizedTime; //Get the normalized time from the Rider HorseNormalizedTime = Montura.Animal.Anim.GetCurrentAnimatorStateInfo(0).normalizedTime; //Get the normalized time from the Horse syncronize = true; if (Mathf.Abs(RiderNormalizedTime - HorseNormalizedTime) > 0.1f && Time.time - LastSyncTime > 1f) //Checking if the animal and the rider are unsync by 0.2 { Anim.CrossFade(AnimTag.Locomotion, 0.2f, MountLayerIndex, HorseNormalizedTime); //Normalized with blend LastSyncTime = Time.time; } } else { syncronize = false; RiderNormalizedTime = HorseNormalizedTime = 0; } }
/// <summary> /// Set an Action using their Action ID (Find the IDs on the Animator Actions Transitions) /// </summary> /// <param name="actionName">Name of the Animation State</param> public virtual void SetAction(string actionName) { if (CurrentAnimState.tagHash != T_Action && ActionID < 0) { Anim.CrossFade(actionName, 0.1f); } }
/// <summary> Syncronize the Animal/Rider animations if Rider loose sync with the animal on the locomotion state </summary> protected virtual void Animators_ReSync() { if (!Anim) { return; } if (Montura.Animal.Stance != 0) { return; //Skip if the we are not on the default stance } if (Montura.ID != 0) { return; // if is not the Horse (Wagon do not sync ) } if (Montura.Animal.ActiveStateID == StateEnum.Locomotion) //Search for syncron the locomotion state on the animal { RiderNormalizedTime = Anim.GetCurrentAnimatorStateInfo(MountLayerIndex).normalizedTime; //Get the normalized time from the Rider HorseNormalizedTime = Montura.Animal.Anim.GetCurrentAnimatorStateInfo(0).normalizedTime; //Get the normalized time from the Horse syncronize = true; if (Mathf.Abs(RiderNormalizedTime - HorseNormalizedTime) > 0.1f && Time.time - LastSyncTime > 1f) //Checking if the animal and the rider are unsync by 0.2 { Anim.CrossFade(AnimTag.Locomotion, 0.2f, MountLayerIndex, HorseNormalizedTime); //Normalized with blend LastSyncTime = Time.time; } } else { syncronize = false; RiderNormalizedTime = HorseNormalizedTime = 0; } }
/// <summary> /// Sets in the animator the Correct Idle Animation State for the Right/Left Hand Ex: "Melee Idle Right Hand" which is the exact name in the Animator /// </summary> public virtual void SetWeaponIdleAnimState(bool IsRightHand) { string WeaponIdle = " Idle " + (IsRightHand ? "Right" : "Left") + " Hand"; WeaponIdle = ActiveWeapon.WeaponType.name + WeaponIdle; //Melee Idle Right/Left Hand Anim.CrossFade(WeaponIdle, 0.25f, ActiveWeapon.RightHand ? Layer_RiderArmRight : Layer_RiderArmLeft); //Active the Layer Right/Left Arm for Idle Pose }
/// <summary> /// Set an Action using their Action ID (Find the IDs on the Animator Actions Transitions) /// </summary> /// <param name="actionName">Name of the Animation State</param> public virtual void SetAction(string actionName) { if (Anim.HasState(0, Animator.StringToHash(actionName))) { if (AnimState != AnimTag.Action && actionID <= 0) //Don't play an action if you are already making one and if is on a Zone { Anim.CrossFade(actionName, 0.1f, 0); } } else { Debug.LogWarning("The animal does not have an action called " + actionName); } }
IEnumerator StartShotgunReload(int Bullets) { if (m_AnimationType == AnimationType.Animation) { Anim.CrossFade(StartReloadAnim.name, 0.2f); ParentGun.PlayReloadAudio(0); yield return(new WaitForSeconds(StartReloadAnim.length)); for (int i = 0; i < Bullets; i++) { Anim[InsertAnim.name].wrapMode = WrapMode.Loop; float speed = Anim[InsertAnim.name].length / InsertSpeed; Anim[InsertAnim.name].speed = speed; Anim.CrossFade(InsertAnim.name); GunManager.HeadAnimation(3, speed); ParentGun.PlayReloadAudio(1); yield return(new WaitForSeconds(InsertAnim.length / speed)); ParentGun.AddBullet(1); if (cancelReload) { Anim.CrossFade(AfterReloadAnim.name, 0.2f); GunManager.HeadAnimation(0, AfterReloadAnim.length); yield return(new WaitForSeconds(AfterReloadAnim.length)); ParentGun.FinishReload(); cancelReload = false; yield break; } } Anim.CrossFade(AfterReloadAnim.name, 0.2f); GunManager.HeadAnimation(0, AfterReloadAnim.length); ParentGun.PlayReloadAudio(2); yield return(new WaitForSeconds(AfterReloadAnim.length)); ParentGun.FinishReload(); } else { animator.speed = 1; animator.Play("StartReload", 0, 0); ParentGun.PlayReloadAudio(0); yield return(new WaitForSeconds(StartReloadAnim.length)); for (int i = 0; i < Bullets; i++) { float speed = InsertAnim.length / InsertSpeed; animator.speed = speed; animator.Play("Insert", 0, 0); GunManager.HeadAnimation(3, speed); ParentGun.PlayReloadAudio(1); yield return(new WaitForSeconds(InsertAnim.length / speed)); ParentGun.AddBullet(1); if (cancelReload) { animator.CrossFade("AfterReload", 0.32f, 0); GunManager.HeadAnimation(0, AfterReloadAnim.length); yield return(new WaitForSeconds(AfterReloadAnim.length)); ParentGun.FinishReload(); cancelReload = false; yield break; } } animator.Play("EndReload", 0, 0); GunManager.HeadAnimation(0, AfterReloadAnim.length); ParentGun.PlayReloadAudio(2); yield return(new WaitForSeconds(AfterReloadAnim.length)); ParentGun.FinishReload(); } }
/// <summary> /// Set an Action using their Action ID (Find the IDs on the Animator Actions Transitions) /// </summary> /// <param name="actionName">Name of the Animation State</param> public virtual void SetAction(string actionName) { Anim.CrossFade(actionName, 0.1f); }