Forward and back movements with a camera emulating an isometric view

Hello,

It’s been three days and I still have no idea how to do this, so it’s time I start bothering you all.

My problem is as follows: imagine a simple terrain object with a camera over it at a certain angle (x:60, y:0, z:0), I managed to have this camera zoom in and out, rotate using a point in the middle of the screen corresponding to a position on the terrain, and move left and right whatever the curent rotation is.

But I absolutely don’t know how to have the camera move forward and back taking into account the current camera angle that may have changed due to rotation. I know it works with left and right movments because the x axis doesn’t change, still I do not knwow how to work with the camera’s angle when it comes to the two other movements.


CameraBehaviour.cs

	private void Move (){
		if (Input.GetKey(KeyCode.UpArrow) || Input.mousePosition.y>(ScreenHeight-ScreenLimit)){
			transform.position += Vector3.forward * MoveSpeed * Time.deltaTime;
		}
		if (Input.GetKey(KeyCode.DownArrow) || Input.mousePosition.y<ScreenLimit){
			transform.position += Vector3.back * MoveSpeed * Time.deltaTime;
		}
		if (Input.GetKey(KeyCode.RightArrow) || Input.mousePosition.x>(ScreenWidth-ScreenLimit)){
			transform.Translate(Vector3.right * MoveSpeed * Time.deltaTime);
		}
		if (Input.GetKey(KeyCode.LeftArrow) || Input.mousePosition.x<ScreenLimit){
			transform.Translate(Vector3.left * MoveSpeed * Time.deltaTime);
		}
	}

Thanks a lot for your help!

The by far easiest way it to make the camera a child of a “camera mover” empty gameobject. Put this mover on your terrain at the required height (ground height, I assume), and then change the camera’s localPosition and localRotation to whatever you want. Give the mover a temporary meshrenderer and meshfilter to position the camera in a way that it looks directly and the mover (the mover is at the center of the screen).

All code concerning the movement and rotation of the camera is then actually applied to the mover.