Distance between two edges

How do I get the distance between two bounds? I recently made a post about how to fill some gaps and I got an idea that is based on getting the distance between the outer bounds of the position.

magnitude

I need to get the distance between these bounds (including rotation)

Isn’t this gap fill?

Anyways, looking from that source code I believe here is how it goes:

  1. You get the points of the edges

  2. Create a ray representing the edges by drawing a vector between the two edge/corner points.

  3. Get closest distance between two rays.

And if you want you can evaluate all the point-point distances to find max distance and such.

1 Like

Yes but I don’t want to use external shapes like cylinders to fill the gaps because I’m gonna use stretched models to make a conveyor system like this
lolx

Also I got something with a function but I still get my error that leaves some gaps but I’ll mark you as solution because it’s actually a solution for this thread.

You can just get the positions of the edges of the parts and then get the magnitude between them
Something like this:

local function getFarCornerPoint(segment)
    return segment.Position + (segment.CFrame.LookVector * segment.Size.Z/2) + (segment.CFrame.RightVector * segment.Size.X/2)
end

local function getCloseCornerPoint(segment)
    return segment.Position + (-segment.CFrame.LookVector * segment.Size.Z/2) + (segment.CFrame.RightVector * segment.Size.X/2)
end