Destroy Ragdoll / Gameobject When Off-screen

Hi All!

I’d like to know: How do I destroy a ragdoll when offscreen.

Also, should I add the function to the script that creates the ragdolls, or is it performancewise better to instantiate the ragdolls with destroy.when.offscreen function attached to it?

Thanks in advance!

You can use Renderer.isVisible to determine if an object is within the camera’s view frustrum.

If the ragdoll/gameobject is not in the view, you can then call Destroy(GameObject) on it.

The easiest way is to attach a script to your ragdoll and use theOnBecameInvisible event.