private void DoWeaponSwitch(int weaponSwitch, int weaponVisibility, int weaponNumber, int leftRight, bool sheath) { Debug.Log("DoWeaponSwitch:" + weaponSwitch + " WeaponVisibility:" + weaponVisibility + " WeaponNumber:" + weaponNumber + " LeftRight:" + leftRight + " Sheath:" + sheath); // Lock character for switch unless has moving sheath/unsheath anims. if (weaponSwitch < 1) { if (AnimationData.Is2HandedWeapon(weaponNumber)) { rpgCharacterController.Lock(true, true, true, 0f, 1f); } } else if (AnimationData.Is1HandedWeapon(weaponSwitch)) { rpgCharacterController.Lock(true, true, true, 0f, 1f); } // Set weaponSwitch if applicable. if (weaponSwitch != -2) { animator.SetInteger("WeaponSwitch", weaponSwitch); } animator.SetInteger("Weapon", weaponNumber); // Set leftRight if applicable. if (leftRight != -1) { animator.SetInteger("LeftRight", leftRight); } // Set animator trigger. if (sheath) { rpgCharacterController.SetAnimatorTrigger(AnimatorTrigger.WeaponSheathTrigger); StartCoroutine(_WeaponVisibility(weaponVisibility, false, dualSwitch)); // If using IKHands, trigger IK blend. if (rpgCharacterController.ikHands != null) { rpgCharacterController.ikHands.BlendIK(false, 0f, 0.2f, weaponVisibility); } } else { rpgCharacterController.SetAnimatorTrigger(AnimatorTrigger.WeaponUnsheathTrigger); StartCoroutine(_WeaponVisibility(weaponVisibility, true, dualSwitch)); // If using IKHands, trigger IK blend. if (rpgCharacterController.ikHands != null) { rpgCharacterController.ikHands.BlendIK(true, 0.75f, 1, weaponVisibility); } } }
/// <summary> /// Character Roll. /// </summary> /// <param name="1">Forward.</param> /// <param name="2">Right.</param> /// <param name="3">Backward.</param> /// <param name="4">Left.</param> public IEnumerator _Roll(int roll) { rollNumber = roll; currentState = RPGCharacterState.Roll; rpgCharacterState = RPGCharacterState.Roll; animator.SetInteger("Action", rollNumber); animator.SetTrigger("RollTrigger"); isRolling = true; rpgCharacterController.Lock(true, true, true, 0, 0.5f); yield return(new WaitForSeconds(rollduration)); isRolling = false; currentState = RPGCharacterState.Idle; rpgCharacterState = RPGCharacterState.Idle; }
private void Swim_EnterState() { superCharacterController.DisableClamping(); superCharacterController.DisableSlopeLimit(); rpgCharacterController.EndAction("Strafe"); rpgCharacterController.EndAction("Aim"); rpgCharacterController.Lock(false, true, false, 0f, 0f); rpgCharacterController.SetAnimatorTrigger(AnimatorTrigger.SwimTrigger); animator.SetBool("Swimming", true); // Scale collider to match position of character. superCharacterController.radius = 1.5f; if (capCollider != null) { capCollider.radius = 1.5f; } }
private void DoWeaponSwitch(int weaponSwitch, int weaponVisibility, int weaponNumber, int leftRight, bool sheath) { //Debug.Log("DoWeaponSwitch: " + weaponSwitch + " WeaponNumber: " + weaponNumber + " Sheath: " + sheath); //Go to Null state and wait for animator. animator.SetInteger("Weapon", -2); while (animator.isActiveAndEnabled && animator.GetInteger("Weapon") != -2) { } //Lock character for switch unless has moving sheath/unsheath anims. if (weaponSwitch < 1) { if (Is2HandedWeapon(weaponNumber)) { rpgCharacterController.Lock(true, true, true, 0f, 1f); } } else if (Is1HandedWeapon(weaponSwitch)) { rpgCharacterController.Lock(true, true, true, 0f, 1f); } //Set weaponSwitch if applicable. if (weaponSwitch != -2) { animator.SetInteger("WeaponSwitch", weaponSwitch); } animator.SetInteger("Weapon", weaponNumber); //Set leftRight if applicable. if (leftRight != -1) { animator.SetInteger("LeftRight", leftRight); } //Set animator trigger. if (sheath) { animator.SetTrigger("WeaponSheathTrigger"); if (dualSwitch) { StartCoroutine(_WeaponVisibility(weaponVisibility, false, true)); } else { StartCoroutine(_WeaponVisibility(weaponVisibility, false, false)); } //If using IKHands, trigger IK blend. if (rpgCharacterController.ikHands != null) { StartCoroutine(rpgCharacterController.ikHands._BlendIK(false, 0f, 0.2f, weaponVisibility)); } } else { animator.SetTrigger("WeaponUnsheathTrigger"); if (dualSwitch) { StartCoroutine(_WeaponVisibility(weaponVisibility, true, true)); } else { StartCoroutine(_WeaponVisibility(weaponVisibility, true, false)); } //If using IKHands, trigger IK blend. if (rpgCharacterController.ikHands != null) { StartCoroutine(rpgCharacterController.ikHands._BlendIK(true, 0.5f, 1, weaponVisibility)); } } }