From f4ae2f9701aa07d32ec98f63ce82cefb852553c1 Mon Sep 17 00:00:00 2001 From: 0ceanSlim Date: Mon, 6 Nov 2023 13:22:19 -0500 Subject: [PATCH] leaning change? --- Assets/Scripts/FirstPersonController.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/FirstPersonController.cs b/Assets/Scripts/FirstPersonController.cs index f3fa0d37..f9db2fde 100644 --- a/Assets/Scripts/FirstPersonController.cs +++ b/Assets/Scripts/FirstPersonController.cs @@ -262,6 +262,7 @@ public class FirstPersonController : MonoBehaviour { if (toggleLeaning) { + // Toggle leaning with a single key press if (Input.GetKeyDown(leanLeftKey)) { isLeaningLeft = !isLeaningLeft; @@ -275,6 +276,7 @@ public class FirstPersonController : MonoBehaviour } else { + // Continuous leaning while the keys are held down if (Input.GetKey(leanLeftKey) && !isLeaningRight) { isLeaningLeft = true; @@ -287,8 +289,8 @@ public class FirstPersonController : MonoBehaviour } } - // Apply the current leaning angle using the maximum leaning angle - currentLeaningAngle = Mathf.Clamp(currentLeaningAngle, -maxLeaningAngle, maxLeaningAngle); + // Calculate and apply the current leaning angle using the maximum leaning angle + currentLeaningAngle = isLeaningLeft ? -maxLeaningAngle : isLeaningRight ? maxLeaningAngle : 0; } private void ApplyFinalMovements()