Esempio n. 1
0
 public void ApplyGravity(bool isGrounded = false)
 {
     if (!isGrounded)
     {
         this.currentVerticalSpeed =
             MathfExtensions.ApplyGravity(this.VerticalSpeed, this.GravitySettings.GravityStrength, this.GravitySettings.MaxFallSpeed);
     }
     else
     {
         this.currentVerticalSpeed = -this.GravitySettings.GroundedGravityForce;
     }
 }
Esempio n. 2
0
        public static Quaternion GetMouseRotationInput(float mouseSensitivity = 3f, float minTiltAngle = -75f, float maxTiltAngle = 45f)
        {
            //if (!Input.GetMouseButton(1))
            //{
            //    return;
            //}

            float mouseX = Input.GetAxis("Mouse X");
            float mouseY = Input.GetAxis("Mouse Y");

            // Adjust the look angle (Y Rotation)
            lookAngle += mouseX * mouseSensitivity;
            lookAngle %= 360f;

            // Adjust the tilt angle (X Rotation)
            tiltAngle += mouseY * mouseSensitivity;
            tiltAngle %= 360f;
            tiltAngle  = MathfExtensions.ClampAngle(tiltAngle, minTiltAngle, maxTiltAngle);

            var controlRotation = Quaternion.Euler(-tiltAngle, lookAngle, 0f);

            return(controlRotation);
        }