Hi guys,
I'm trying to get the closest point on the bounds of one object to another game object. This is what I am currently trying out:
public class object1 : MonoBehaviour
{
void OnDrawGizmos()
{
Collider[] colliders = Physics.OverlapSphere(transform.position, radius);
foreach (Collider hit in colliders)
{
if( hit.CompareTag("Block") )
{
Gizmos.color = Color.red;
Gizmos.DrawSphere( hit.ClosestPointOnBounds(transform.position), 0.1f );
}
}
}
}
All this gives me is the AABB (Axis Aligned Bounding Box) of the hit object. Unity Uses the OOBB (Object Aligned Bound Box) for it's rigidbody collisions, but using `hit.rigidbody.ClosestPointOnBounds` only gives the AABB again.
Is there a way to get the closest point on the OOBB that isn't computationally expensive?
Or at the very least accessing the OOBB which is used by the rigidbody?