How to calculate min distance between parts

How to calculate min distance between parts? No from midpoint to midpoint, but from closest to closest point? Actually Im more interested to calc the smallest distance from given point A to Wedge closest point! Sound very difficult. Ufff

1 Like

Sircfenner has answerd this here: Finding the closest Vector3 point on a part from the character - #3 by sircfenner

Using his solution, you can do:

local p1 = ClosestPointOnPart(part1, part2.Position)
local p2 = ClosestPointOnPart(part2, part1.Position)
local minDistance = (p1 - p2).magnitude
8 Likes

Btw I think this works only with rectangular parts.

No. This uses vector positions to calculate the distance between the objects. Doesn’t take into account the mesh or part.

2 Likes