From 161aece83e63d8f3148c1bb3cabc6a20bb9a5539 Mon Sep 17 00:00:00 2001 From: BuyMyMojo Date: Sat, 4 Mar 2023 07:34:48 +1100 Subject: [PATCH] Improve controller movement --- .erp | 4 ++-- Assets/PlayerInputActions.cs | 6 +++--- Assets/PlayerInputActions.inputactions | 6 +++--- Assets/Scripts/GameInput.cs | 2 ++ Assets/Scripts/Player.cs | 4 ++-- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.erp b/.erp index 5952c73..02d1ca6 100644 --- a/.erp +++ b/.erp @@ -5,7 +5,7 @@ false false true - 1677880402 - 7184246594242351147 + 1677876493 + 2115309888051293429 false \ No newline at end of file diff --git a/Assets/PlayerInputActions.cs b/Assets/PlayerInputActions.cs index ad8f693..c522b63 100644 --- a/Assets/PlayerInputActions.cs +++ b/Assets/PlayerInputActions.cs @@ -180,7 +180,7 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable ""id"": ""545341dc-a1a1-47e8-a08d-84a68957f048"", ""path"": ""/leftStick"", ""interactions"": """", - ""processors"": """", + ""processors"": ""StickDeadzone(min=0.5)"", ""groups"": """", ""action"": ""Move"", ""isComposite"": false, @@ -200,7 +200,7 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable { ""name"": """", ""id"": ""f3791e57-b19a-4a65-ba91-e9f4484e7581"", - ""path"": ""/buttonWest"", + ""path"": ""/buttonSouth"", ""interactions"": """", ""processors"": """", ""groups"": """", @@ -222,7 +222,7 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable { ""name"": """", ""id"": ""915cd8bb-a4cc-4a75-b7ee-327c965ac8c2"", - ""path"": ""/buttonSouth"", + ""path"": ""/buttonWest"", ""interactions"": """", ""processors"": """", ""groups"": """", diff --git a/Assets/PlayerInputActions.inputactions b/Assets/PlayerInputActions.inputactions index a6fc4e8..e2e4838 100644 --- a/Assets/PlayerInputActions.inputactions +++ b/Assets/PlayerInputActions.inputactions @@ -158,7 +158,7 @@ "id": "545341dc-a1a1-47e8-a08d-84a68957f048", "path": "/leftStick", "interactions": "", - "processors": "", + "processors": "StickDeadzone(min=0.5)", "groups": "", "action": "Move", "isComposite": false, @@ -178,7 +178,7 @@ { "name": "", "id": "f3791e57-b19a-4a65-ba91-e9f4484e7581", - "path": "/buttonWest", + "path": "/buttonSouth", "interactions": "", "processors": "", "groups": "", @@ -200,7 +200,7 @@ { "name": "", "id": "915cd8bb-a4cc-4a75-b7ee-327c965ac8c2", - "path": "/buttonSouth", + "path": "/buttonWest", "interactions": "", "processors": "", "groups": "", diff --git a/Assets/Scripts/GameInput.cs b/Assets/Scripts/GameInput.cs index 159abba..8aad4c3 100644 --- a/Assets/Scripts/GameInput.cs +++ b/Assets/Scripts/GameInput.cs @@ -35,6 +35,8 @@ public class GameInput : MonoBehaviour playerInputActions = new PlayerInputActions(); + + if (PlayerPrefs.HasKey(PLAYER_PREFS_BINDINGS)) { playerInputActions.LoadBindingOverridesFromJson(PlayerPrefs.GetString(PLAYER_PREFS_BINDINGS)); diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index d4e1fbd..7616e33 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -138,7 +138,7 @@ public class Player : MonoBehaviour, IKitchenObjectParent // attempt only X move Vector3 moveDirX = new Vector3(moveDir.x, 0, 0).normalized; - canMove = moveDir.x != 0 && !Physics.CapsuleCast(transform.position, transform.position + Vector3.up * playerHeight, playerRadius, moveDirX, moveDistance); + canMove = (moveDir.x < -.5f || moveDir.x > +.5f) && !Physics.CapsuleCast(transform.position, transform.position + Vector3.up * playerHeight, playerRadius, moveDirX, moveDistance); // if able to move on X then change moveDir to X if (canMove) @@ -149,7 +149,7 @@ public class Player : MonoBehaviour, IKitchenObjectParent { // cannot move on X so attempt to move on Z Vector3 moveDirZ = new Vector3(0, 0, moveDir.z).normalized; - canMove = moveDir.z != 0 && !Physics.CapsuleCast(transform.position, transform.position + Vector3.up * playerHeight, playerRadius, moveDirZ, moveDistance); + canMove = (moveDir.z < -.5f || moveDir.z > +.5f) && !Physics.CapsuleCast(transform.position, transform.position + Vector3.up * playerHeight, playerRadius, moveDirZ, moveDistance); // if able to move on Z then change moveDir to Z if (canMove)