|
|
|
|
@ -7,8 +7,6 @@ public class PlayerMove : MonoBehaviour
|
|
|
|
|
[SerializeField] private Rigidbody rb;
|
|
|
|
|
[SerializeField] private Vector3 StartPos;
|
|
|
|
|
|
|
|
|
|
bool vertical;
|
|
|
|
|
bool horizontal;
|
|
|
|
|
private void Start()
|
|
|
|
|
{
|
|
|
|
|
rb = GetComponent<Rigidbody>();
|
|
|
|
|
@ -18,31 +16,9 @@ public class PlayerMove : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
float horizontalInput = Input.GetAxis("Horizontal");
|
|
|
|
|
float verticalInput = Input.GetAxis("Vertical");
|
|
|
|
|
horizontalInput = Mathf.Round(horizontalInput);
|
|
|
|
|
verticalInput = Mathf.Round(verticalInput);
|
|
|
|
|
|
|
|
|
|
Vector3 moveDirection;
|
|
|
|
|
|
|
|
|
|
if (horizontalInput != 0 && horizontal == true)
|
|
|
|
|
{
|
|
|
|
|
vertical = false;
|
|
|
|
|
moveDirection = new Vector3(horizontalInput,0, 0);
|
|
|
|
|
moveDirection.Normalize();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (verticalInput != 0 && vertical == true)
|
|
|
|
|
{
|
|
|
|
|
horizontal = false;
|
|
|
|
|
moveDirection = new Vector3(0, 0, verticalInput);
|
|
|
|
|
moveDirection.Normalize();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
moveDirection = new Vector3(0, 0, 0);
|
|
|
|
|
horizontal = true;
|
|
|
|
|
vertical = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Vector3 moveDirection = new Vector3(horizontalInput,0, verticalInput);
|
|
|
|
|
moveDirection.Normalize();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
transform.Translate(moveDirection * speed * Time.deltaTime, Space.World);
|
|
|
|
|
|