From eb4a84a3181e6966d357b10265afec2750de5464 Mon Sep 17 00:00:00 2001 From: Arshvir Goraya <113562877+ArshvirGoraya@users.noreply.github.com> Date: Thu, 24 Oct 2024 17:46:03 -0400 Subject: [PATCH 1/2] camera clipping fix --- Assets/Scripts/Game/PlayerMouseLook.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Assets/Scripts/Game/PlayerMouseLook.cs b/Assets/Scripts/Game/PlayerMouseLook.cs index 7ed5b5504c..29174ba859 100644 --- a/Assets/Scripts/Game/PlayerMouseLook.cs +++ b/Assets/Scripts/Game/PlayerMouseLook.cs @@ -66,7 +66,6 @@ public float Pitch get { return cameraPitch * Mathf.Rad2Deg; } set { - value = Mathf.Clamp(value, pitchMin, pitchMax); cameraPitch = value * Mathf.Deg2Rad; if (cameraPitch > piover2 * .99f) cameraPitch = piover2 * .99f; From f872ae0755362353957eba66b57e78d2bcc04807 Mon Sep 17 00:00:00 2001 From: Arshvir Goraya <113562877+ArshvirGoraya@users.noreply.github.com> Date: Sun, 3 Nov 2024 15:43:08 -0500 Subject: [PATCH 2/2] double vertical clamp without reversing signs --- Assets/Scripts/Game/PlayerMouseLook.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Game/PlayerMouseLook.cs b/Assets/Scripts/Game/PlayerMouseLook.cs index 29174ba859..9bd674a83e 100644 --- a/Assets/Scripts/Game/PlayerMouseLook.cs +++ b/Assets/Scripts/Game/PlayerMouseLook.cs @@ -66,6 +66,7 @@ public float Pitch get { return cameraPitch * Mathf.Rad2Deg; } set { + value = Mathf.Clamp(value, -pitchMax, -pitchMin); cameraPitch = value * Mathf.Deg2Rad; if (cameraPitch > piover2 * .99f) cameraPitch = piover2 * .99f; @@ -126,7 +127,7 @@ void ApplyLook() sensitivityY = sensitivity.y * sensitivityScale; } - Vector2 rawMouseDelta = new Vector2(InputManager.Instance.LookX, InputManager.Instance.LookY); + Vector2 rawMouseDelta = new Vector2(InputManager.Instance.LookX, -InputManager.Instance.LookY); lookTarget += Vector2.Scale(rawMouseDelta, new Vector2(sensitivityX, sensitivityY * (invertMouseY ? -1 : 1))); @@ -140,12 +141,11 @@ void ApplyLook() } // Clamp target look pitch to range of straight down to straight up - lookTarget.y = Mathf.Clamp(lookTarget.y, pitchMin, pitchMax); - + lookTarget.y = Mathf.Clamp(lookTarget.y, -pitchMax, -pitchMin); ApplySmoothing(); Yaw = lookCurrent.x; - Pitch = -lookCurrent.y; + Pitch = lookCurrent.y; } // Updates lookCurrent by moving it a fraction towards lookTarget