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 ![]()
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);
}
}
}