- Home /
Destroy object question!
How i can destroy an object when out of camera view?
Thx you in advance,
Answer by FreeTimeDev · May 05, 2011 at 07:33 AM
You could make a large trigger that when the objects leave the "sphere of influence" of (OnTriggerExit) they get sent a message (that ultimately leads to a function that kills them).
This would have more control than say, immediately killing something off screen.
And don't forget to attach them triggers to the camera itself so that the sphere influence is moving with the camera.
Answer by FLASHDENMARK · May 05, 2011 at 11:09 AM
I have never tried this, but mabye:
function OnBecameInvisible ()
{
//Destroy your object here.
}
Answer by Joshua · May 05, 2011 at 04:21 AM
if (!gameObject.renderer.isVisible)
Destroy(gameObject);
Like so :)
with renderer.isVisible make my material invisible but i wanna destroy object when its out of range (camera view)