Improve controller movement
This commit is contained in:
parent
4e96a88306
commit
161aece83e
5 changed files with 12 additions and 10 deletions
|
@ -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)
|
||||
|
|
Reference in a new issue