Is it possible in C# to check for a box collider turned into a trigger being a certain percent full and running code based on that being over a certain % (Say 85 or so)?
My original idea was either a lot of little triggers that would make up the 100% and each time one is triggered it increments a value and deactivates that trigger so it cant flood it. Once the incremented number hits 85 you know 85% of the triggers have been hit but this will drop the accuracy because it might not be 85% filled but 85 triggers are hit.
I also thought raycasting but not to sure on that. Any ideas from you guys and girls?
How do you define full? Geometry in the scene doesn’t consist of volume. It’s just a bunch of triangles. Only the surface of an object is defined. Colliders do represent some sort volume but the purpose of the physics system is to detect collisions / overlaps in order to create a penalty force to simulate physics. Triggers do the same but instead of calculating a force they just send a message when a collision happens.
Colliders can be quite complex. For example a MeshCollider can have a non regular shape where it’s extremely difficult to calculate the volume / boundary. A similar problem happens with compound colliders. They can already intersect each other. Since in a compound collider multiple colliders are treated as one, how would you treat the overlapping volume inside the compound collider itself?
So the answer is no, Unity doesn’t have something like that built-in. You would have to calculate that yourself. Even if you only use box colliders, calculating the shape of the overlapping volume can be very difficult if your colliders can be rotated. If all colliders are axis aligned it’s way simpler.