Hi!
ok, so im trying to detect if a gameobject is outside the view of the main camera of the character controller. Here is my script, it is attached to the enemy:
var angel : Transform;
var cam : GameObject;
var target : Transform;
function Start () {
}
function Update () {
var rot = target.position - angel.position;
var dist = Vector3.Distance(angel.position, target.position);
rot.y = 0;
if (cam.renderer.isVisible) {
//do nothing
} else {
Debug.Log("Not looking");
}
}
Here is the actual error I get:
![alt text][1]
Now, obviously I do have a renderer attached to my cam object, it is the main camera.
This is driving me up the walls, any ideas?
[1]: http://i.imgur.com/kqvCIpO.png+
↧