Alternative way of assigning object through Inspector

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

You can do a GameObject.Find in Start to set your target1 and target2.

Thanks! Why didn’t I see it before?! I found another important information there
“For performance reasons it is recommended to not use this function every frame Instead cache the result in a member variable at startup or use GameObject.FindWithTag.”

Thanks again.