I want to determine a part’s distance from a region of parts. This is happening on a 2d plane btw. Look at the example below if you don’t know what I mean by region.
Since this a 2D plane I don’t know if you could use workspace:RayCast() but if you can then fire a ray cast from the parts position to the center of the region and find the ray cast hit position and get the magnitude of the difference of those. This is assuming that the region is collidable and
lowk you could do sqrt(abs(part.Position.X - part2.Position.X)^2 + abs(part.Position.Y - part.Position.Y)^2 ) if it’s a 2d plane. if it is topdown 2d just use Z instead of Y
I see the confusion here but I want the distance from the region (meaning the minimal distance from the region) please see the figure. Btw rn what I have done is selected the closest vector to my point, then selected the left and right points and formed triangles respectively so a triangle would be formed with the original point, selected point, and left point. Then I would measure the base angles of these triangles if they are both less than 90 degrees (both individually not Together) then the original point is inbetween the 2 points meaning we can either solve for the height of said triangle. But if both triangles formed (with right and left points) have base angles less than 90 degrees then we select the triangle with the least distance. Now this solution has a couple problems, once you get really close to region Roblox doesn’t get a super specific side lines which breaks solving for the height of the triangle. And also this is very inefficient having to solve for angles, sides, and magnitude multiple times. This is why I was curious how others would do it.