From 9211121dcc9f1a4c8d17b25866236a51c0ff9854 Mon Sep 17 00:00:00 2001 From: Fredrik Lillemoen Eiding Date: Sun, 5 Nov 2023 15:58:06 +0100 Subject: [PATCH 1/4] Fix crouching being more visible, fix gamepad look sensitivity --- Assets/Prefabs/Input/Player.prefab | 3 ++- Assets/Scripts/Control&Input/InputManager.cs | 5 ++++- Assets/Scripts/Control&Input/PlayerMovement.cs | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Assets/Prefabs/Input/Player.prefab b/Assets/Prefabs/Input/Player.prefab index a4ed306ca..838d3d242 100644 --- a/Assets/Prefabs/Input/Player.prefab +++ b/Assets/Prefabs/Input/Player.prefab @@ -68,7 +68,7 @@ MonoBehaviour: leapForce: 12.5 jumpTimeout: 0.5 leapTimeout: 0.875 - crouchedHeightOffset: 0.3 + crouchedHeightOffset: 0.8 airThreshold: 0.4 slopeAngleThreshold: 50 state: 1 @@ -177,6 +177,7 @@ MonoBehaviour: m_EditorClassIdentifier: maxHitDistance: 100 targetStartOffset: 0.9 + overrideAimTarget: 0 inputManager: {fileID: 0} identity: {fileID: 0} hudController: {fileID: 555885729091202788} diff --git a/Assets/Scripts/Control&Input/InputManager.cs b/Assets/Scripts/Control&Input/InputManager.cs index c1c71dac9..127735929 100644 --- a/Assets/Scripts/Control&Input/InputManager.cs +++ b/Assets/Scripts/Control&Input/InputManager.cs @@ -43,8 +43,11 @@ public class InputManager : MonoBehaviour [SerializeField] private float mouseLookScale = 0.1f; + [SerializeField] + private float gamepadLookScale = 0.75f; private bool isMouseAndKeyboard = false; + public bool IsMouseAndKeyboard => IsMouseAndKeyboard; void Start() { @@ -130,7 +133,7 @@ private void LookInputPerformed(InputAction.CallbackContext ctx) } else { - lookInput = ctx.ReadValue(); + lookInput = ctx.ReadValue() * gamepadLookScale; } } diff --git a/Assets/Scripts/Control&Input/PlayerMovement.cs b/Assets/Scripts/Control&Input/PlayerMovement.cs index 3c7b49d96..050cbf78b 100644 --- a/Assets/Scripts/Control&Input/PlayerMovement.cs +++ b/Assets/Scripts/Control&Input/PlayerMovement.cs @@ -132,7 +132,7 @@ private void SetCrouch(InputAction.CallbackContext ctx) { animator.SetBool("Crouching", true); strafeForce = strafeForceCrouched; - if (!IsInAir()) + //if (!IsInAir()) inputManager.gameObject.LeanMoveLocalY(localCameraHeight - crouchedHeightOffset, 0.2f); } @@ -140,7 +140,7 @@ private void SetCrouch(InputAction.CallbackContext ctx) { animator.SetBool("Crouching", false); strafeForce = strafeForceGrounded; - if (!IsInAir()) + //if (!IsInAir()) inputManager.gameObject.LeanMoveLocalY(localCameraHeight, 0.2f); } @@ -198,6 +198,7 @@ private void UpdatePosition(Vector3 input) var groundNormal = GroundNormal(); var direction = Vector3.ProjectOnPlane(input, groundNormal); body.AddForce(direction * strafeForce, ForceMode.VelocityChange); + body.AddForce(direction * strafeForce, ForceMode.Impulse); if (IsInAir()) state = PlayerState.IN_AIR; break; } From 4567600aa0b4c0aee16108d7ebd702c20deffe3c Mon Sep 17 00:00:00 2001 From: Fredrik Lillemoen Eiding Date: Sun, 5 Nov 2023 16:00:16 +0100 Subject: [PATCH 2/4] Remove unused variable --- Assets/Scripts/Control&Input/InputManager.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Assets/Scripts/Control&Input/InputManager.cs b/Assets/Scripts/Control&Input/InputManager.cs index 127735929..c14f5d02f 100644 --- a/Assets/Scripts/Control&Input/InputManager.cs +++ b/Assets/Scripts/Control&Input/InputManager.cs @@ -47,7 +47,6 @@ public class InputManager : MonoBehaviour private float gamepadLookScale = 0.75f; private bool isMouseAndKeyboard = false; - public bool IsMouseAndKeyboard => IsMouseAndKeyboard; void Start() { From 17ea1b4b17ff1e5c3a416119b1bc6b0cefe11fd0 Mon Sep 17 00:00:00 2001 From: Fredrik Lillemoen Eiding Date: Mon, 6 Nov 2023 01:20:08 +0100 Subject: [PATCH 3/4] Fix crouch cancelation in air --- Assets/Scripts/Control&Input/PlayerMovement.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Control&Input/PlayerMovement.cs b/Assets/Scripts/Control&Input/PlayerMovement.cs index 050cbf78b..803897fe2 100644 --- a/Assets/Scripts/Control&Input/PlayerMovement.cs +++ b/Assets/Scripts/Control&Input/PlayerMovement.cs @@ -132,7 +132,7 @@ private void SetCrouch(InputAction.CallbackContext ctx) { animator.SetBool("Crouching", true); strafeForce = strafeForceCrouched; - //if (!IsInAir()) + if (!IsInAir()) inputManager.gameObject.LeanMoveLocalY(localCameraHeight - crouchedHeightOffset, 0.2f); } @@ -140,8 +140,7 @@ private void SetCrouch(InputAction.CallbackContext ctx) { animator.SetBool("Crouching", false); strafeForce = strafeForceGrounded; - //if (!IsInAir()) - inputManager.gameObject.LeanMoveLocalY(localCameraHeight, 0.2f); + inputManager.gameObject.LeanMoveLocalY(localCameraHeight, 0.2f); } } From c536632c9857784a5ecbacfbf7d02dfbe112487f Mon Sep 17 00:00:00 2001 From: Fredrik Lillemoen Eiding Date: Mon, 6 Nov 2023 20:20:26 +0100 Subject: [PATCH 4/4] fix crouchspeed locked by jump --- Assets/Scripts/Control&Input/PlayerMovement.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Control&Input/PlayerMovement.cs b/Assets/Scripts/Control&Input/PlayerMovement.cs index 803897fe2..aa3099faf 100644 --- a/Assets/Scripts/Control&Input/PlayerMovement.cs +++ b/Assets/Scripts/Control&Input/PlayerMovement.cs @@ -130,10 +130,11 @@ private void SetCrouch(InputAction.CallbackContext ctx) if (ctx.performed) { + if (IsInAir()) + return; animator.SetBool("Crouching", true); strafeForce = strafeForceCrouched; - if (!IsInAir()) - inputManager.gameObject.LeanMoveLocalY(localCameraHeight - crouchedHeightOffset, 0.2f); + inputManager.gameObject.LeanMoveLocalY(localCameraHeight - crouchedHeightOffset, 0.2f); } if (ctx.canceled)