Isometric Camera !

Isometric games have their charm, mainly because it is home to many great old-school RPG and adventures games.

From a designer perspective, its charm is also due to their tile based nature, neat graphical advantages of refining modular pieces.

Inspired by that I started working on a Camera script for Unity3d. It uses an orthographic cam with the following script(JavaScript) attached:

var target : Transform;
var distance = 45.0;
var height = 45.0;
var distanceDamping = 3.0;
var heightDamping = 1.0;
function LateUpdate () {
    if (!target)
    var wantedHeight = target.position.y + height;
    var wantedDistance = target.position.x + distance;
    var wantedDistanceZ = target.position.z - distance;
    var currentHeight = transform.position.y;
    var currentDistance = transform.position.x;
    var currentDistanceZ = transform.position.z;
    currentHeight = Mathf.Lerp (currentHeight, wantedHeight, heightDamping * Time.deltaTime);
    currentDistance = Mathf.Lerp (currentDistance, wantedDistance, distanceDamping * Time.deltaTime);
    currentDistanceZ = Mathf.Lerp (currentDistanceZ, wantedDistanceZ, distanceDamping * Time.deltaTime);
    transform.position.y = currentHeight;
    transform.position.x = currentDistance;
    transform.position.z = currentDistanceZ;
    transform.LookAt (target);
Currently it's a very basic script, to have a true orthographic view, both distance and height variables should have the same number. It also has damping for each parameters.

No hay comentarios:

Publicar un comentario