My player moves forward and backward, but not left and right. I am new to Unity, so any help will be appreciated`using UnityEngine;
public class PlayerMovement01 : MonoBehaviour {
// This is a reference to the Rigidbody component called "rb"
public Rigidbody rb;
public float forwardForce = 500f;
public float sidewaysForce = 500f;
void FixedUpdate ()
{
if (Input.GetKey("w"))
{
rb.AddForce(0, 0, forwardForce * Time.deltaTime);
}
if (Input.GetKey("s"))
{
rb.AddForce(0, 0, -forwardForce * Time.deltaTime);
}
if ( Input.GetKey("d") )
{
rb.AddForce(sidewaysForce * Time.deltaTime, 0, 0);
}
if ( Input.GetKey("a") )
{
rb.AddForce(-sidewaysForce * Time.deltaTime, 0, 0);
}
}
}