So I’m using renderer.isVisible on an object (it’s a model of a person I imported as an FBX). The script seems to work as the object doesn’t move when you’re looking at it. Except it only seems to matter whether or not his FEET are visible or not. Even if you’re looking at it, if it’s feet are not seen by the camera, it registers as not visible.
Have I missed something here?
Here’s the code:
#pragma strict
var speed = 0.5;
var ObjectB:GameObject;
var isSeen:boolean;
var cam : Camera;
private var planes : Plane;
private var increment:float;
private var rotation:Quaternion;
function Start () {
//cam = Camera.main;
//isSeen = true;
planes = GeometryUtility.CalculateFrustumPlanes(cam);
}
function Update () {
if(renderer.isVisible)
{
isSeen = true;
}
else if(!renderer.isVisible){
isSeen = false;
}
if(isSeen == true){
}
else if(isSeen == false){
if(increment <=1)
increment += speed/100;
transform.position = Vector3.Lerp(this.transform.position, ObjectB.transform.position, increment);
var direction:Vector3 = ObjectB.transform.position - transform.position;
rotation = Quaternion.LookRotation(direction);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, increment);
this.transform.rotation.x = 0;
//this.transform.rotation.y = 0;
}
}