How to make my cube go the way it is facing.

I searched around and tried a few things but I can’t get it to work.

I have the basic movement and rotation working.

Also if anyone has the time to provide a small amount of clarification on why I need += at the transform.position instead of a simple =

public float speed = 5f;

	void Update ()
	{ 
		if (Input.GetKey(KeyCode.LeftArrow))
		{
			transform.Rotate  ( Vector3.forward * speed  * Time.deltaTime);
		}
		if (Input.GetKey(KeyCode.RightArrow))
		{
			transform.Rotate  (Vector3.back * speed  * Time.deltaTime);
		}
		if (Input.GetKey(KeyCode.UpArrow))
		{
			transform.position += Vector3.up * speed * Time.deltaTime;
		}
		if (Input.GetKey(KeyCode.DownArrow))
		{
			transform.position += Vector3.down * speed * Time.deltaTime;
		}

transform.position += Vector3.up

is the same as:

transform.position = transform.position + Vector3.up

this means that it adds the value at the right on every frame.

As for your code you coud use transform.up, to move the cube in localSpace. I have added different values for moveSpeed and rotateSpeed, so you can have them separated…

public float moveSpeed = 5f;
	public float rotateSpeed = 20f;
	
	void Update ()
	{ 
		if (Input.GetKey(KeyCode.LeftArrow))
		{
			transform.Rotate  ( Vector3.forward * rotateSpeed  * Time.deltaTime);
		}
		if (Input.GetKey(KeyCode.RightArrow))
		{
			transform.Rotate  (Vector3.back * rotateSpeed  * Time.deltaTime);
		}
		if (Input.GetKey(KeyCode.UpArrow))
		{
			transform.position += transform.up * moveSpeed * Time.deltaTime;
		}
		if (Input.GetKey(KeyCode.DownArrow))
		{
			transform.position += -transform.up * moveSpeed * Time.deltaTime;
		}
	}