So i am making a “car” game and i want the car to only move forward and back, and left and right, without rotation. I want it to just translate into its next position. I already have the car moving forward and back, but if anyone could add on to this and make it also move left and right it would be huge. Thanks

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MoveForwards : MonoBehaviour {
public float Speed = 60.0f;

// Update is called once per frame
void Update () {
float translation = Input.GetAxis ("Vertical") * Speed;
translation *= Time.deltaTime;
transform.Translate (0, 0, translation);
}
}

You are getting “Up” and “Down” input with Input.GetAxis (“Vertical”). If you want “Left” and “Right” input, you will need to use Input.GetAxis (“Horizontal”). Possible code could look something like this:

void Update ()
{
// Get input of the Left and Right arrow keys.
float horizontalInput = Input.GetAxis ("Horizontal");
// Get input of the Up and Down arrow keys.
float verticalInput = Input.GetAxis ("Vertical");
// input.x will dictate how far to move in the X (sideways) dimension
// input.y will dictate how far to move in the Y (upwards) dimension
// input.z will dictate how far to move in the Z (forward) dimension
Vector3 input = new Vector3 (horizontalInput, 0, verticalInput);
// Multiply by Time.deltaTime to adjust for framerate
transform.Translate (input * Speed * Time.deltaTime);
}

Remember that transform.Translate pushes the object in 3 directions. Translate (0,0,1) would move forward by 1, Translate (0,1,0) would move up by 1, and Translate (1,0,0) would move sideways by 1.