From ETC Public Wiki
Jump to: navigation, search

Is an object in view of the camera:

 var target : Transform;
 function Start() {
   var viewPos : Vector3 = camera.WorldToViewportPoint(target.position);
   print( viewPos );

prints the vector3

x = 0 - 1 from left to right y = 0 - 1 from bottom to top z = distance from camera to object in world units

if x or y are >1 or < 0 then the object is not in view of the camera


these events are called when an object comes into and goes outof a cameras renderer

 function OnBecomeVisible() {
   print("I see you");
 function OnBecomeInvisible() {
   print("Where did you go);

Also think about useing them to set the enabled properity so that scripts on objects outside of the camera do not run.