/// <summary>Calculates the Pitch direction to Appy to the Rotator Transform</summary> internal void CalculatePitchDirectionVector() { var UpDown = Mathf.Clamp(UpDownSmooth, -1, 1); var Vertical = Mathf.Clamp(VerticalSmooth, -1, 1); Vector3 PitchDirection; if (MoveWithDirection) //If the Animal is using Directional Movement use the Raw Direction Vector { PitchDirection = TargetMoveDirection; PitchDirection.Normalize(); PitchDirection += (UpVector * UpDown); } else //If not is using Directional Movement Calculate New Direction Vector { if (MovementAxis.z < 0) { UpDown = 0; //Remove UP DOWN MOVEMENT while going backwards } PitchDirection = (transform.forward * Vertical) + (transform.up * UpDown); //Calculate the Direction to Move } if (PitchDirection.magnitude > 1) { PitchDirection.Normalize(); //Remove extra Speed } this.PitchDirection = Vector3.Slerp(this.PitchDirection, PitchDirection, DeltaTime * CurrentSpeedModifier.lerpRotation * 4); // if (debugGizmos) Debug.DrawRay(transform.position, this.PitchDirection * 5, Color.yellow); }
/// <summary>Calculates the Pitch direction to Appy to the Rotator Transform</summary> private void CalculatePitchDirectionVector() { var UpDown = Mathf.Clamp(Smooth_UpDown, -1, 1); var Vertical = Mathf.Clamp(VerticalSmooth, -1, 1); if (MoveWithDirection) //If the Animal is using Directional Movement use the Raw Direction Vector { PitchDirection = TargetMoveDirection; PitchDirection.Normalize(); PitchDirection += (UpVector * UpDown); if (PitchDirection.magnitude > 1) { PitchDirection.Normalize(); //Remove extra Speed } } else //If not is using Directional Movement Calculate New Direction Vector { if (MovementAxis.z < 0) { UpDown = 0; //Remove UP DOWN MOVEMENT while going backwards } PitchDirection = (transform.forward * Vertical) + (transform.up * UpDown); //Calculate the Direction to Move if (PitchDirection.magnitude > 1) { PitchDirection.Normalize(); //Remove extra Speed } } // if (debug) Debug.DrawRay(transform.position, PitchDirection, Color.yellow); }