private void UpdateCameraRotation() { _rotationY += _verticalInput.GetInvertedAxis(SettingsComponent.gl_InvertVerticalOrientation) * ySensitivity * Time.deltaTime; if (_rotateZInput.GetAxisBool()) { _rotationZ += _horizontalInput.GetAxis() * zSensitivity * Time.deltaTime; } else { if (SettingsComponent.gl_UseInvertedControlsUpsideDown) { if (_rotationY >= SettingsComponent.gl_InvertAngle || _rotationY <= -SettingsComponent.gl_InvertAngle) { _rotationX += -_horizontalInput.GetAxis() * xSensitivity * Time.deltaTime; } else { _rotationX += _horizontalInput.GetAxis() * xSensitivity * Time.deltaTime; } } else { _rotationX += _horizontalInput.GetAxis() * xSensitivity * Time.deltaTime; } } if (xClampAngle != 0) { _rotationX = ClampAngle(_rotationX, -xClampAngle, xClampAngle); } else { ResetAngle(ref _rotationX); } if (yClampAngle != 0) { _rotationY = ClampAngle(_rotationY, -yClampAngle, yClampAngle); } else { ResetAngle(ref _rotationY); } if (zClampAngle != 0) { _rotationZ = ClampAngle(_rotationZ, -zClampAngle, zClampAngle); } else { ResetAngle(ref _rotationZ); } //Debug.Log("Rotation X " + _rotationX); //Debug.Log("Rotation Y " + _rotationY); //Debug.Log("Rotation Z " + _rotationZ); //Vector3 localNormalUp = (up.transform.position - player.transform.position).normalized; //Vector3 localNormalLeft = (left.transform.position - player.transform.position).normalized; //Vector3 localNormalForward = (forward.transform.position - player.transform.position).normalized; Quaternion xQuaternion = Quaternion.AngleAxis(_rotationX, Vector3.up); Quaternion yQuaternion = Quaternion.AngleAxis(_rotationY, Vector3.left); //Quaternion zQuaternion = Quaternion.AngleAxis(_rotationZ, Vector3.forward); _player.transform.rotation = _playerOriginalRotation * xQuaternion /* * zQuaternion*/; //rotates the player horizontally transform.localRotation = _originalRotation * yQuaternion; //rotates the camera vertically }