Finding nearest point on the surface

Hello there!

Anyone has got idea how to make script which will find the nearest point on surface between two specified parts?


I want to make script which will just specify the gravity to the part. It should work on wedges too tho.

Edit: At least way to specify what surface is player on would be appreciated :smiley:

Thank you so much,
DevKurka

I hope you’re prepared to do a lot of math

1 Like

I guess so. :stuck_out_tongue:
Maybe at least specifying surface won’t be that hard. :confused:

For a catch-all solution which it looks like you’re wanting to do I think you should start here

Ray parellel to surface, point as middle of ball.

But you can’t specify ray to find the nearest point on surface. You can only set the ray to look with a direction from it. I do now exactly know where is the arrow shown on image.

YOU ARE A GOD!!!
Thank you so much. Didn’t even know about this article.

if you have 2 rays along the surface (perpendicular to each other) and find closest point on those to the ball you have a rather accurate location, you do not need to know anything about the ball for that.

Also you are aware gravity works downwards, not in the direction of the surface right?

Yes, I do thanks. :slight_smile:

The gravity thing is working. Just needed surface thing.
I get your idea now. It’s interesting, but I would just need to make much rays.

Thanks anyways! :wink: