gameobject in view fustrum

Hey guys,

Is there a way to know if a gameObject is in the view fustrum ?
I cannot use renderer.isVisible, etc, because my gameObject doens’t always have a renderer associated with it.
Any clues ?

Thanks,
Bruno

I would create a function that cycles through the children of the game object, finds all the renderers in it and tests each one.

function isInViewFrustrum(testObject : gameObject){
	var visible=false;
	var objs : Component=testObject.GetComponentsInChildren(Renderer);
	for(var obj : GameObject in objs){
		if(obj.renderer.isVisible)visible=true;
	}
	if(testObject.renderer)if(testObject.renderer.isVisible) then visible=true;
	return visible;
}

If the game object has no renderer(s) associated with it, you can perform the test manually. If you just need something approximate, a simple ‘field of view’ test might be sufficient, but if you need a more exact result you can perform the frustum test yourself. (Not looking at the docs right now, but I believe the Unity API even includes a convenience function for computing the planes of the frustum.)

GeometryUtility.CalculateFrustumPlanes plus GeometryUtility.TestPlanesAABB

Hi,

I’m working on a custom particle emitter, and I would like to know wich particles are in the camera Frustum or not.
I’ve tried the sample code in the manual, but I get wrong or weird results.
What should I do exactly to know if a point is in view or not ?

EDIT : ok, I’ve found the problem : my particle emitter wasn’t positionned at 0,0,0… that was my weirdness :wink: