1
0
Fork 0
This commit is contained in:
Piegames 2018-04-21 18:19:53 +02:00
parent bd9f61a671
commit 0abad3bc57

View file

@ -10,6 +10,8 @@ public class PlayerMovement : MonoBehaviour {
public float turnSpeed = 2;
[SerializeField]
public float drift = 1f;
[SerializeField]
public float brake = 2f;
Rigidbody2D rigidbody2D;
@ -27,6 +29,8 @@ public class PlayerMovement : MonoBehaviour {
}
{// Drag
Vector3 drag = speedVec.normalized * speed * speed * friction * -1;
if (Input.GetKey(KeyCode.S))
drag *= brake;
rigidbody2D.AddForce(drag);
Debug.DrawLine(transform.position, transform.position + drag, Color.cyan, 0.01f, false);
}
@ -38,12 +42,10 @@ public class PlayerMovement : MonoBehaviour {
//Debug.Log(br);
Debug.DrawLine(transform.position, transform.position + br, Color.red, 0.01f, false);
}
if (Input.GetKey(KeyCode.A)){
if (Input.GetKey(KeyCode.A))
transform.Rotate(Vector3.forward * turnSpeed);
}
if (Input.GetKey(KeyCode.D)) {
if (Input.GetKey(KeyCode.D))
transform.Rotate(Vector3.forward * -turnSpeed);
}
// Debug lines
Debug.DrawLine(transform.position, transform.position + speedVec, Color.magenta, 0.01f, false);
Debug.DrawLine(transform.position, transform.position + transform.localRotation * Vector3.up, Color.yellow, 0.01f, false);