Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions com.unity.render-pipelines.core/Runtime/Camera/FreeCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ namespace UnityEngine.Rendering
[CoreRPHelpURLAttribute("Free-Camera")]
public class FreeCamera : MonoBehaviour
{
const float k_MouseSensitivityMultiplier = 0.01f;

/// <summary>
/// Rotation speed when using a controller.
/// </summary>
public float m_LookSpeedController = 120f;
/// <summary>
/// Rotation speed when using the mouse.
/// </summary>
public float m_LookSpeedMouse = 10.0f;
public float m_LookSpeedMouse = 4.0f;
/// <summary>
/// Movement speed.
/// </summary>
Expand Down Expand Up @@ -51,7 +53,6 @@ public class FreeCamera : MonoBehaviour
InputAction lookAction;
InputAction moveAction;
InputAction speedAction;
InputAction fireAction;
InputAction yMoveAction;
#endif

Expand Down Expand Up @@ -94,7 +95,6 @@ void RegisterInputs()
moveAction.Enable();
lookAction.Enable();
speedAction.Enable();
fireAction.Enable();
yMoveAction.Enable();
#endif

Expand Down Expand Up @@ -129,8 +129,8 @@ void UpdateInputs()

#if USE_INPUT_SYSTEM
var lookDelta = lookAction.ReadValue<Vector2>();
inputRotateAxisX = lookDelta.x * m_LookSpeedMouse * Time.deltaTime;
inputRotateAxisY = lookDelta.y * m_LookSpeedMouse * Time.deltaTime;
inputRotateAxisX = lookDelta.x * m_LookSpeedMouse * k_MouseSensitivityMultiplier;
inputRotateAxisY = lookDelta.y * m_LookSpeedMouse * k_MouseSensitivityMultiplier;

leftShift = Keyboard.current.leftShiftKey.isPressed;
fire1 = Mouse.current?.leftButton?.isPressed == true || Gamepad.current?.xButton?.isPressed == true;
Expand All @@ -148,8 +148,8 @@ void UpdateInputs()
inputRotateAxisX = Input.GetAxis(kMouseX) * m_LookSpeedMouse;
inputRotateAxisY = Input.GetAxis(kMouseY) * m_LookSpeedMouse;
}
inputRotateAxisX += (Input.GetAxis(kRightStickX) * m_LookSpeedController * Time.deltaTime);
inputRotateAxisY += (Input.GetAxis(kRightStickY) * m_LookSpeedController * Time.deltaTime);
inputRotateAxisX += (Input.GetAxis(kRightStickX) * m_LookSpeedController * k_MouseSensitivityMultiplier);
inputRotateAxisY += (Input.GetAxis(kRightStickY) * m_LookSpeedController * k_MouseSensitivityMultiplier);

leftShift = Input.GetKey(KeyCode.LeftShift);
fire1 = Input.GetAxis("Fire1") > 0.0f;
Expand Down
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed remapping of depth pyramid debug view
- Fixed an issue with asymmetric projection matrices and fog / pathtracing. (case 1330290).
- Fixed gbuffer depth debug mode for materials not rendered during the prepass.
- Fixed the FreeCamera and SimpleCameraController mouse rotation unusable at low framerate (case 1340344).

### Changed
- Changed Window/Render Pipeline/HD Render Pipeline Wizard to Window/Rendering/HDRP Wizard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

public class LookWithMouse : MonoBehaviour
{
const float k_MouseSensitivityMultiplier = 0.01f;

public float mouseSensitivity = 100f;

public Transform playerBody;
Expand Down Expand Up @@ -39,11 +41,11 @@ void Update()
mouseY += value.y;
}

mouseX *= mouseSensitivity * Time.deltaTime;
mouseY *= mouseSensitivity * Time.deltaTime;
mouseX *= mouseSensitivity * k_MouseSensitivityMultiplier;
mouseY *= mouseSensitivity * k_MouseSensitivityMultiplier;
#else
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * k_MouseSensitivityMultiplier;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * k_MouseSensitivityMultiplier;
#endif

xRotation -= mouseY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public void UpdateTransform(Transform t)
}
}

const float k_MouseSensitivityMultiplier = 0.01f;

CameraState m_TargetCameraState = new CameraState();
CameraState m_InterpolatingCameraState = new CameraState();

Expand Down Expand Up @@ -165,8 +167,6 @@ Vector3 GetInputTranslationDirection()

void Update()
{
// Exit Sample

if (IsEscapePressed())
{
Application.Quit();
Expand All @@ -191,7 +191,7 @@ void Update()
// Rotation
if (IsCameraRotationAllowed())
{
var mouseMovement = GetInputLookRotation() * Time.deltaTime * mouseSensitivity;
var mouseMovement = GetInputLookRotation() * k_MouseSensitivityMultiplier * mouseSensitivity;
if (invertY)
mouseMovement.y = -mouseMovement.y;

Expand Down Expand Up @@ -243,7 +243,7 @@ Vector2 GetInputLookRotation()
delta *= 0.1f; // Account for sensitivity setting on old Mouse X and Y axes.
return delta;
#else
return new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y") * (invertY ? 1 : -1));
return new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public void UpdateTransform(Transform t)
}
}

const float k_MouseSensitivityMultiplier = 0.01f;

CameraState m_TargetCameraState = new CameraState();
CameraState m_InterpolatingCameraState = new CameraState();

Expand All @@ -65,6 +67,9 @@ public void UpdateTransform(Transform t)
public float positionLerpTime = 0.2f;

[Header("Rotation Settings")]
[Tooltip("Multiplier for the sensitivity of the rotation.")]
public float mouseSensitivity = 60.0f;

[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));

Expand Down Expand Up @@ -188,7 +193,7 @@ void Update()
// Rotation
if (IsCameraRotationAllowed())
{
var mouseMovement = GetInputLookRotation() * Time.deltaTime * 5;
var mouseMovement = GetInputLookRotation() * k_MouseSensitivityMultiplier * mouseSensitivity;
if (invertY)
mouseMovement.y = -mouseMovement.y;

Expand Down Expand Up @@ -227,16 +232,20 @@ float GetBoostFactor()
#if ENABLE_INPUT_SYSTEM
return boostFactorAction.ReadValue<Vector2>().y * 0.01f;
#else
return Input.mouseScrollDelta.y * 0.2f;
return Input.mouseScrollDelta.y * 0.01f;
#endif
}

Vector2 GetInputLookRotation()
{
// try to compensate the diff between the two input systems by multiplying with empirical values
#if ENABLE_INPUT_SYSTEM
return lookAction.ReadValue<Vector2>();
var delta = lookAction.ReadValue<Vector2>();
delta *= 0.5f; // Account for scaling applied directly in Windows code by old input system.
delta *= 0.1f; // Account for sensitivity setting on old Mouse X and Y axes.
return delta;
#else
return new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y")) * 10;
return new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));
#endif
}

Expand Down