Improve controller movement

This commit is contained in:
BuyMyMojo 2023-03-04 07:34:48 +11:00
parent 4e96a88306
commit 161aece83e
5 changed files with 12 additions and 10 deletions

4
.erp
View file

@ -5,7 +5,7 @@
<resetOnSceneChange>false</resetOnSceneChange>
<debugMode>false</debugMode>
<EditorClosed>true</EditorClosed>
<LastTimestamp>1677880402</LastTimestamp>
<LastSessionID>7184246594242351147</LastSessionID>
<LastTimestamp>1677876493</LastTimestamp>
<LastSessionID>2115309888051293429</LastSessionID>
<Errored>false</Errored>
</ERPSettings>

View file

@ -180,7 +180,7 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable
""id"": ""545341dc-a1a1-47e8-a08d-84a68957f048"",
""path"": ""<Gamepad>/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"": ""<Gamepad>/buttonWest"",
""path"": ""<Gamepad>/buttonSouth"",
""interactions"": """",
""processors"": """",
""groups"": """",
@ -222,7 +222,7 @@ public partial class @PlayerInputActions: IInputActionCollection2, IDisposable
{
""name"": """",
""id"": ""915cd8bb-a4cc-4a75-b7ee-327c965ac8c2"",
""path"": ""<Gamepad>/buttonSouth"",
""path"": ""<Gamepad>/buttonWest"",
""interactions"": """",
""processors"": """",
""groups"": """",

View file

@ -158,7 +158,7 @@
"id": "545341dc-a1a1-47e8-a08d-84a68957f048",
"path": "<Gamepad>/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": "<Gamepad>/buttonWest",
"path": "<Gamepad>/buttonSouth",
"interactions": "",
"processors": "",
"groups": "",
@ -200,7 +200,7 @@
{
"name": "",
"id": "915cd8bb-a4cc-4a75-b7ee-327c965ac8c2",
"path": "<Gamepad>/buttonSouth",
"path": "<Gamepad>/buttonWest",
"interactions": "",
"processors": "",
"groups": "",

View file

@ -35,6 +35,8 @@ public class GameInput : MonoBehaviour
playerInputActions = new PlayerInputActions();
if (PlayerPrefs.HasKey(PLAYER_PREFS_BINDINGS))
{
playerInputActions.LoadBindingOverridesFromJson(PlayerPrefs.GetString(PLAYER_PREFS_BINDINGS));

View file

@ -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)