diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index 45ef764..e6e9e94 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -11,6 +11,16 @@ public class Player : MonoBehaviour private bool isWalking; private void Update() + { + HandleMovement(); + } + + public bool IsWalking() + { + return isWalking; + } + + private void HandleMovement() { Vector2 inputVector = gameInput.GetMovementVectorNormalized(); @@ -32,7 +42,8 @@ public class Player : MonoBehaviour if (canMove) { moveDir = moveDirX; - } else + } + else { // Cannot move on X so attempt to move on Z Vector3 moveDirZ = new Vector3(0, 0, moveDir.z).normalized; @@ -40,7 +51,8 @@ public class Player : MonoBehaviour if (canMove) { moveDir = moveDirZ; - } else + } + else { // Cannot move at all } @@ -57,9 +69,4 @@ public class Player : MonoBehaviour transform.forward = Vector3.Slerp(transform.forward, moveDir, Time.deltaTime * rotateSpeed); } - public bool IsWalking() - { - return isWalking; - } - }