Skip to content

Commit e45496a

Browse files
[HDRP] Fix camera controller in template with old input system (#4124)
* Fixed the camera controller in the template with the old input system. * Updated changelog * Adjust values between two systems * Fix difference between delta of two input systems * Updated changelog * Update SimpleCameraController.cs Co-authored-by: sebastienlagarde <sebastien@unity3d.com>
1 parent 681a834 commit e45496a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

com.unity.render-pipelines.high-definition/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
148148
- Fixed camera preview with multi selection (case 1324126).
149149
- Fixed a NaN generating in Area light code.
150150
- Fix potential NaN on apply distortion pass.
151+
- Fixed the camera controller in the template with the old input system (case 1326816).
151152

152153
### Changed
153154
- Changed Window/Render Pipeline/HD Render Pipeline Wizard to Window/Rendering/HDRP Wizard

com.unity.template-hd/Assets/SampleSceneAssets/Scripts/SimpleCameraController.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public void UpdateTransform(Transform t)
6565
public float positionLerpTime = 0.2f;
6666

6767
[Header("Rotation Settings")]
68+
[Tooltip("Multiplier for the sensitivity of the rotation.")]
69+
public float mouseSensitivity = 60.0f;
70+
6871
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for camera rotation.")]
6972
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));
7073

@@ -188,7 +191,7 @@ void Update()
188191
// Rotation
189192
if (IsCameraRotationAllowed())
190193
{
191-
var mouseMovement = GetInputLookRotation() * Time.deltaTime * 5;
194+
var mouseMovement = GetInputLookRotation() * Time.deltaTime * mouseSensitivity;
192195
if (invertY)
193196
mouseMovement.y = -mouseMovement.y;
194197

@@ -225,7 +228,6 @@ void Update()
225228
float GetBoostFactor()
226229
{
227230
#if ENABLE_INPUT_SYSTEM
228-
// TODO
229231
return boostFactorAction.ReadValue<Vector2>().y * 0.01f;
230232
#else
231233
return Input.mouseScrollDelta.y * 0.01f;
@@ -234,8 +236,12 @@ float GetBoostFactor()
234236

235237
Vector2 GetInputLookRotation()
236238
{
239+
// try to compensate the diff between the two input systems by multiplying with empirical values
237240
#if ENABLE_INPUT_SYSTEM
238-
return lookAction.ReadValue<Vector2>();
241+
var delta = lookAction.ReadValue<Vector2>();
242+
delta *= 0.5f; // Account for scaling applied directly in Windows code by old input system.
243+
delta *= 0.1f; // Account for sensitivity setting on old Mouse X and Y axes.
244+
return delta;
239245
#else
240246
return new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y") * (invertY ? 1 : -1));
241247
#endif
@@ -268,7 +274,7 @@ bool IsCameraRotationAllowed()
268274
canRotate |= Gamepad.current != null ? Gamepad.current.rightStick.ReadValue().magnitude > 0 : false;
269275
return canRotate;
270276
#else
271-
return Input.GetMouseButtonDown(1);
277+
return Input.GetMouseButton(1);
272278
#endif
273279
}
274280

0 commit comments

Comments
 (0)