Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do you do surface detection with raycasting?

Asked by
W8X 95
9 years ago

Is their any way to detect what surface of a part a ray hits?

No code because I have absolutely no clue on what to do after the ray hits a part.

1 answer

Log in to vote
2
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

Reading the wiki page will help.

FindPartOnRay returns three things:

1) The Part (if any) that the Raycast hit
2) The Position (if any) that the Raycast hit the Part at
3) The Vector of the surface normal that corresponds with the Surface hit by the Raycast (if any)

The third return is what you're interested in.

As I've already answered how to convert that vector into the hit Surface, read my answer to this question.

Ad

Answer this question