The unity documentation for raycasting says that a raycast “Casts a ray against all colliders in the scene.”
I only need to raycast against the colliders of objects which have renderer.isVisible == true
. I’m thinking it would relieve a lot of strain on the CPU if you had a scene with a ton of colliders.
Does anyone with more unity know-how have any idea if this is possible?
Would I gain anything performance-wise if I had a script on each object (and say I have 1600 objects) which turned its collider on or off based on their own OnBecameVisible()
or OnWillRenderObject()
events?
Or would the only option be, implementing your own raycast/collision system which keeps track of isVisible objects on its own?