How to get the closest point on the surface of a part

  1. What do I want to achieve? I am trying to get the closest point on a surface of a part. Not the middle.

  2. What is the issue? Here is my diagram of my issue. I have no idea how to get the fastest overall point on the surface.

diagram first

diagram second

diagram thrid

  1. What solutions have you tried so far? It seemed like nobody had this issue.
2 Likes

You would do RayCast.Position + RayCast.Normal

Normal is the intersected face of the Ray

This can be easily done with worksapce:Raycast

You can start out with rayCasts in forward and down/up in the direction of the part and if none of those hit you check the corners of the part you are looking for and which is closer to your part and that should work

1 Like

I kinda have no idea how this function works.

1 Like

Check this out

THe get closest point of surface

1 Like

If i got you right, how about make another point lower than raypoint instead of surface position? Like, instead of getting baseplate’s position, just make lower point of ray point (for example, raypoint - Vector3.new(0, 1000, 0)) or something, and then do raycast thingy to find surface

Edit: also i know i “KINDA” late (2 years lol), just thought maybe i still can help you or help other people

to get the closest point on the edge of the target part(or within the part if the ray’s origin is inside) you should clamp the ray’s origin to within the object. this is pretty simple to do for non-rotated objects, but incorporating rotation is more difficult.

(does not include the raycast)
closest_pt_within_part.rbxl (50.7 KB)

this was solved years ago, just never added a solution to the post

oh okay, just if the problem was solved by someone else’s post i recommend check solution mark on THEIR post, beacuse solution was given by them.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.