Skip to content

Commit a167ca2

Browse files
authored
Fix FreeCamera speed boost controls (#2967)
Two issues: 1. Holding Shift key during mouse-look with right mouse button would only boost speed for a single frame because it was checking GetKeyDown. Fixed by checking GetKey. 2. The Shift key only gives a speed boost when mouse-looking with RMB, but the Fire input (LMB by default) should always work. However, there was an issue where Fire would not boost the camera if the RMB was held down. This change fixes that so Fire will always boost and Shift will still only boost during mouse-look.
1 parent a52f590 commit a167ca2

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

com.unity.render-pipelines.core/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111

1212
### Fixed
1313
- Fixed ACES tonemaping for Nintendo Switch by forcing some shader color conversion functions to full float precision.
14+
- Fixed a bug in FreeCamera which would only provide a speed boost for the first frame when pressing the Shfit key.
1415

1516
## [10.2.0] - 2020-10-19
1617

com.unity.render-pipelines.core/Runtime/Camera/FreeCamera.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void UpdateInputs()
151151
inputRotateAxisX += (Input.GetAxis(kRightStickX) * m_LookSpeedController * Time.deltaTime);
152152
inputRotateAxisY += (Input.GetAxis(kRightStickY) * m_LookSpeedController * Time.deltaTime);
153153

154-
leftShift = Input.GetKeyDown(KeyCode.LeftShift);
154+
leftShift = Input.GetKey(KeyCode.LeftShift);
155155
fire1 = Input.GetAxis("Fire1") > 0.0f;
156156

157157
inputChangeSpeed = Input.GetAxis(kSpeedAxis);
@@ -192,10 +192,8 @@ void Update()
192192
transform.localRotation = Quaternion.Euler(newRotationX, newRotationY, transform.localEulerAngles.z);
193193

194194
float moveSpeed = Time.deltaTime * m_MoveSpeed;
195-
if (leftShiftBoost)
196-
moveSpeed *= leftShift ? m_Turbo : 1.0f;
197-
else
198-
moveSpeed *= fire1 ? m_Turbo : 1.0f;
195+
if (fire1 || leftShiftBoost && leftShift)
196+
moveSpeed *= m_Turbo;
199197
transform.position += transform.forward * moveSpeed * inputVertical;
200198
transform.position += transform.right * moveSpeed * inputHorizontal;
201199
transform.position += Vector3.up * moveSpeed * inputYAxis;

0 commit comments

Comments
 (0)