Hello fellow Unity Developers,
I am attempting to create a C# function that linearly interpolates a Rigidbody’s drag based upon the percentage of the Rigidbody’s collider that is within a trigger collider “Water Region”.
- Water Regions will likely be
convex and with relatively simple
geometry, but they may sometimes be
spherical and may not always be regular
- The Rigidbody may enter the Water
Region from any point and may be
facing any direction while doing so.
While I am certain such is possible via a series of Bounds.Contains() checks, this would not be performant and would have a resolution limited by the number points being checked.
Is there an efficient or mathematical means of determining what percentage of a Collider is within a trigger zone?
Even partial solutions are absolutely welcome (eg: only works with rectangular / spherical Water Regions).
My absolute gratitude in advance!
- S. Darkwell