How to rotate around the centre of screen on the Y axis in othrographic

I asked this in another post but could not post anymore on that page so I’ve started a new topic!

I am trying to rotate on Y around the centre of the screen in othographic mode. I do not want any tilt whatsoever (I’m going for a 3d isometric theme). The problem is that the rotation goes in a large circular arch and the centre screen is lost until the rotation is complete.

I was given advice to make the script holding parent of the camera the centre of the camera viewpoint from the get go. This worked initially but as soon as I moved the parent, the camera would go on these large circular rotations and the original centre of the screen would be lost from sight.

I’ve attached the code I’m using. It’s cobbled together from various tutorials and has some of my own additions. My camera is in orthographic, its positioned so the parent is in the centre, the script is attached to the parent, and near clipping is set to -100.

Hope that is enough info! Ideally I would love to find a way for the camera to stop blurring when it moves… but maybe I shouldn’t get greedy in this post :wink:

using UnityEngine;
using System.Collections;

public class IsometricCamera : MonoBehaviour 
{
	//camera move speed
	public int cameraSpeed; 
	

	// Update is called once per frame
	void Update () 
	{
		//translating on the x, z and Y axes using WASD

	if(Input.GetKey("w"))
		{

			transform.Translate(Vector3.up * cameraSpeed * Time.deltaTime ); 
		}

		if(Input.GetKey("s"))
		{
			
			transform.Translate(Vector3.down * cameraSpeed * Time.deltaTime ); 
		}

		if(Input.GetKey("d"))
		{
			
			transform.Translate((Vector3.right + Vector3.back) * cameraSpeed * Time.deltaTime); 
		}

		if(Input.GetKey("a"))
		{
			
			transform.Translate((Vector3.left + Vector3.forward)  * cameraSpeed * Time.deltaTime ); 
		}

		//zooming up and down with the scrollWheel

		GameObject isoView = GameObject.Find("Main Camera");
		if(Input.GetAxis ("Mouse ScrollWheel") > 0 && isoView.camera.orthographicSize > 2)
		{
			isoView.camera.orthographicSize = isoView.camera.orthographicSize - 1; 
		}

		if(Input.GetAxis ("Mouse ScrollWheel") < 0 && isoView.camera.orthographicSize < 20)
		{
			isoView.camera.orthographicSize = isoView.camera.orthographicSize + 1; 
		}

		//rotate

		if(Input.GetKey("e"))
		{
			transform.Rotate(Vector3.up * cameraSpeed * Time.deltaTime, Space.World); 
		}

		if(Input.GetKey ("q"))
		{
			transform.Rotate(Vector3.down * cameraSpeed * Time.deltaTime, Space.World); 
		}

	}

}

Hmmm. What kind of isometric camera are you working on? I’m unsure of what your code would do since you have

 transform.Translate((Vector3.right + Vector3.back) * cameraSpeed * Time.deltaTime); 

…which makes it odd that you also have Vector3.up and Vector3.down there. Unless we’re talking non-Euclidean geometries here. xD

Try this. It’s derived from a top-down isometric camera I did for school.

if(Input.GetKey("w"))
        {
 
            transform.Translate(transform.forward * cameraSpeed * Time.deltaTime ); 
        }
 
        if(Input.GetKey("s"))
        {
 
            transform.Translate(-transform.forward * cameraSpeed * Time.deltaTime ); 
        }
 
        if(Input.GetKey("d"))
        {
 
            transform.Translate(transform.right * cameraSpeed * Time.deltaTime); 
        }
 
        if(Input.GetKey("a"))
        {
 
            transform.Translate(-transform.right  * cameraSpeed * Time.deltaTime ); 
        }

if(Input.GetKey("e"))
        {
            transform.Rotate(transform.up * cameraSpeed * Time.deltaTime); 
        }
 
        if(Input.GetKey ("q"))
        {
            transform.Rotate(-transform.up * cameraSpeed * Time.deltaTime); 
        }

Put it on an empty gameObject at position (0,0,0) and rotation (0,0,0). Then parent a camera to it with position (-18.371,15,-18.371) and rotation (30,45,0).

It should look like a Diablo 1/2 style camera and moves relative to its own rotation. Even if you rotate it, it will move in the local forward.