コード例 #1
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);
        }