Hi,
I have the following code that make the camera to look at the midpoint between two objects. But I have to manually assign the object in the Inspector.
#pragma strict
var target1 : Transform;
var target2 : Transform;
private var lookAtPosition : Vector3;
function Update () {
// find the mid point between 2 object
lookAtPosition = (target1.position + target2.position ) / 2;
// update the camera to look at the midpoint between two object
transform.LookAt(lookAtPosition);
}
Is there an alternative way of doing it without manually assign the object through Inspector?
Thanks,
ikel