too many boxcolliders

Hi,

in my game there are many boxcolliders. But i need only a few of them in a camera view (only the colliders which are seen with the camera). Is there a way to disable the colliders which are not seen with the camera? Or are there other possibilities?

Could you use OnBecameVisible to turn on / off the ones you need or don’t need?

no, because they have no MeshRenderer and you can not disable only colliders, you must then disable the whole gameobject

The name isn’t especially suggestive, but the GeometryUtility class might help you out here. The CalculateFrustumPlanes function creates a list of plane objects marking out a camera’s view frustum. The TestPlanesAABB function then uses this list to test whether a bounding box is in the frustum or not. You can use these together to test whether a camera’s view contains an object regardless of whether it is rendered or not.

this will be calculated every frame? i think this will be performance expensive too