using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public Rigidbody rb;
public float forwardForce = 2000f;
public float sidewaysForce = 500f;
// Update is called once per frame
//FixedUpdate makes physics smoother
void FixedUpdate()
{
//Time.deltaTime makes game run the same on every FPS
rb.AddForce(0, 0, forwardForce * Time.deltaTime);
if ( Input.GetKey("d") )
{
rb.AddForce(sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
}
if ( Input.GetKey("a") )
{
rb.AddForce(-sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
}
}
}