How to make a simple isometric RTS camera?
You just need to
1) create an empty game object EyeSocket (Game Object → Create Empty)
- set its position to (X, Y, Z) 0, 130, 0

2) create EyeMovement Javascript script and attach it to EyeSocket

3) add camera object called Eye (Create Other → Camera) and attach it to EyeSocket
- set its Rotation to (X, Y, Z) 30, 45, 0
- set its Projection to Orthographic
- set its Size to 50
← rotation coordinates should be exactly the same
EyeMovement.js
function Update () {
/////////////////////
//keyboard scrolling
var translationX : float = Input.GetAxis("Horizontal");
var translationY : float = Input.GetAxis("Vertical");
var fastTranslationX : float = 2 * Input.GetAxis("Horizontal");
var fastTranslationY : float = 2 * Input.GetAxis("Vertical");
if (Input.GetKey(KeyCode.LeftShift))
{
transform.Translate(fastTranslationX + fastTranslationY, 0, fastTranslationY - fastTranslationX);
}
else
{
transform.Translate(translationX + translationY, 0, translationY - translationX);
}
////////////////////
//mouse scrolling
var mousePosX = Input.mousePosition.x;
var mousePosY = Input.mousePosition.y;
var scrollDistance : int = 5;
var scrollSpeed : float = 70;
//Horizontal camera movement
if (mousePosX < scrollDistance)
//horizontal, left
{
transform.Translate(-1, 0, 1);
}
if (mousePosX >= Screen.width - scrollDistance)
//horizontal, right
{
transform.Translate(1, 0, -1);
}
//Vertical camera movement
if (mousePosY < scrollDistance)
//scrolling down
{
transform.Translate(-1, 0, -1);
}
if (mousePosY >= Screen.height - scrollDistance)
//scrolling up
{
transform.Translate(1, 0, 1);
}
////////////////////
//zooming
var Eye : GameObject = GameObject.Find("Eye");
//
if (Input.GetAxis("Mouse ScrollWheel") > 0 Eye.camera.orthographicSize > 4)
{
Eye.camera.orthographicSize = Eye.camera.orthographicSize - 4;
}
//
if (Input.GetAxis("Mouse ScrollWheel") < 0 Eye.camera.orthographicSize < 80)
{
Eye.camera.orthographicSize = Eye.camera.orthographicSize + 4;
}
//default zoom
if (Input.GetKeyDown(KeyCode.Mouse2))
{
Eye.camera.orthographicSize = 50;
}
}
EyeSocket + Eye as a prefab, and EyeMovement.js attached. Please note that you need to set EyeSocket position to (X, Y, Z) 0, 130, 0 to get it to move properly.
