Local Multiplayer
This commit is contained in:
@@ -18,28 +18,31 @@ public class PlayerMove : MonoBehaviour
|
||||
bool vertical;
|
||||
private bool horizontal;
|
||||
|
||||
[SerializeField] private StandUpCollider standUp;
|
||||
[SerializeField] StandUpCollider standUp;
|
||||
|
||||
[SerializeField] private string inputNameHorizontal;
|
||||
[SerializeField] private string inputNameVertical;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
rb = GetComponent<Rigidbody>();
|
||||
standUp = FindAnyObjectByType(typeof(StandUpCollider)) as StandUpCollider;
|
||||
standUp = GetComponentInChildren<StandUpCollider>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
float horizontalInput = Input.GetAxis("Horizontal");
|
||||
float verticalInput = Input.GetAxis("Vertical");
|
||||
float horizontalInput = Input.GetAxis(inputNameHorizontal);
|
||||
float verticalInput = Input.GetAxis(inputNameVertical);
|
||||
horizontalInput = Mathf.Round(horizontalInput);
|
||||
verticalInput = Mathf.Round(verticalInput);
|
||||
|
||||
|
||||
|
||||
if (horizontalInput != 0 && horizontal == true)
|
||||
{
|
||||
if (!standUp.ispushing)
|
||||
{
|
||||
transform.rotation = Quaternion.Euler(0f, 0f, 90f);
|
||||
transform.rotation = Quaternion.Euler(0f, 0f, 90f);
|
||||
}
|
||||
vertical = false;
|
||||
moveDirection = new Vector3(horizontalInput,0, 0);
|
||||
@@ -49,7 +52,6 @@ public class PlayerMove : MonoBehaviour
|
||||
{
|
||||
speed += speedincrease;
|
||||
}
|
||||
|
||||
}
|
||||
else if (verticalInput != 0 && vertical == true)
|
||||
{
|
||||
@@ -65,20 +67,60 @@ public class PlayerMove : MonoBehaviour
|
||||
{
|
||||
speed += speedincrease;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
StartCoroutine(Slide(slide));
|
||||
transform.rotation = Quaternion.Euler(0f, 0f, 0f);
|
||||
}
|
||||
transform.Translate(moveDirection * speed * Time.deltaTime, Space.World);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void Move(float _horizontalInput, float _verticalInput)
|
||||
{
|
||||
if (_horizontalInput != 0 && horizontal == true)
|
||||
{
|
||||
if (!standUp.ispushing)
|
||||
{
|
||||
transform.rotation = Quaternion.Euler(0f, 0f, 90f);
|
||||
}
|
||||
vertical = false;
|
||||
moveDirection = new Vector3(_horizontalInput,0, 0);
|
||||
moveDirection.Normalize();
|
||||
|
||||
if (!vertical && speed <= maxspeed && !standUp.ispushing)
|
||||
{
|
||||
speed += speedincrease;
|
||||
}
|
||||
}
|
||||
else if (_verticalInput != 0 && vertical == true)
|
||||
{
|
||||
if (!standUp.ispushing)
|
||||
{
|
||||
transform.rotation = Quaternion.Euler(90f, 0f, 0f);
|
||||
}
|
||||
horizontal = false;
|
||||
moveDirection = new Vector3(0, 0, _verticalInput);
|
||||
moveDirection.Normalize();
|
||||
|
||||
if (!horizontal && speed <= maxspeed && !standUp.ispushing)
|
||||
{
|
||||
speed += speedincrease;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
transform.Translate(moveDirection * speed * Time.deltaTime, Space.World);
|
||||
// else
|
||||
// {
|
||||
// StartCoroutine(Slide(slide));
|
||||
// transform.rotation = Quaternion.Euler(0f, 0f, 0f);
|
||||
// }
|
||||
//
|
||||
// transform.Translate(moveDirection * speed * Time.deltaTime, Space.World);
|
||||
//Debug.Log(moveDirection);
|
||||
}
|
||||
|
||||
|
||||
|
||||
IEnumerator Slide(float delay)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user