Sunday, July 18, 2010

Code for camera

heres a code me and baker came up with for a camera might work nicely with our game

var targetThing : Transform;
var smoothness: float = 10;
var xOffset: float = 10;
var yOffset: float = 0;
var zOffset: float = 0;
var enableLookAt: boolean = false;

function Update () {
if (enableLookAt) {
transform.LookAt(targetThing.transform);
}
transform.position.x += (targetThing.transform.position.x - transform.position.x + xOffset) / smoothness;
transform.position.y += (targetThing.transform.position.y - transform.position.y + yOffset) / smoothness;
transform.position.z += (targetThing.transform.position.z - transform.position.z + zOffset) / smoothness;
}

No comments:

Post a Comment