So, firstly, here's my code:
var target : GameObject;
var range : float;
var speed : float;
function Update ()
{
range = Vector3.Distance(target.transform.position, transform.position);
if (range<50)
{
transform.LookAt(target.transform.position);
transform.Translate(Vector3.forward*speed*5);
}
}
The objects are cubes and the target should be the player. The cubes are instantiated randomly, and it doesn't let me set the first person controller as the target in the prefab. I tried making the player a prefab and then using that as the target, but that didn't work. Any help?