Runner game question

hi im making a runner game and was wondering how to make the fps controller move automatically forward so the player can only move it left or right …

This is done with C#. It assumes you have already added a rigidbody, and have a surface for it to run on. The only thing left for you to do is parent the camera to the player.

    public float moveSpeed = 20;
public float sideSpeed = 10;
Vector3 forward;
Vector3 right;

void Start () {

    forward = transform.forward;
    right = transform.right;

    rigidbody.constraints = RigidbodyConstraints.FreezeRotationZ;

}

void Update () {

    //Move forward
    transform.position += forward * Time.deltaTime * moveSpeed;

    //If player presses D or Right Arrow, move right
    if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
        transform.position += right * Time.deltaTime * sideSpeed;

    //If player presses A or Left Arrow, move left
    if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
        transform.position += -right * Time.deltaTime * sideSpeed;
}