Find nearest contact point inside trigger

I have a sphere collider trigger and i need to find the closest contact point on various other colliders.

  • I’ve tried using “ClosestPointOnBounds” but have read here that the reason this isn’t working is because i am dealing with rotated objects, and this method is “Axis Aligned”, so this is a no go, unless someone knows a way to translate the axis aligned results into something meaningful?
  • I also can’t simply raycast towards the origin of the “other” collider, as I’m dealing with large and variously shaped colliders, and I do need the closest point, so this will often give an unacceptable result for my purposes.
  • And I can’t use the method suggested here of finding the nearest vertex as im not only dealing with mesh colliders, but spheres, boxes, etc.
  • I don’t think i can simply use a kinematic rigidbody and normal collision detection, because I have to avoid my trigger sphere having any effect on the objects im colliding with.

Desperate at this point, so if anyone has a solution you will forever have my adoration.

Have you tried using ClosestPoint? link text You can use it to get the closest point from your trigger collider to the other collider then use the point it gives you with the trigger collider and ClosestPoint and that will give you the point of contact between the two.

You could also use the collider size/radius to fire a Ray in the direction of the other collider and use Ray.GetPoint link text

For the distance to use on GetPoint- you can use the position GetClosestPoint gives you- just some ideas-

Solved for those stumbling across this in the future:

Use “ClosestPoint” not “ClosestPointOnBounds” and make sure “convex” is ticked on all your mesh colliders!