Detect Specific Areas of Parts Through Raycast?

Sorry for the obscure title, can’t explain it all without it being lengthy.

I’ve always wondered how one can detect a specific area of a part through a ray (e.g… top left, bottom right), I’ve seen examples of it happening on other games, but I’ve always been puzzled by how to code it. If I had to guess, you’d split the part into different divisions in such a fashion that the ray’s result will be the fragment of the desired division of the part as a whole, but is there a more efficient way? Let me know.

What I want:
question

Current solution I know:
questions2

1 Like

Maybe by checking RaycastResult.Position, and doing some complicated CFrame math that personally I can’t understand…

1 Like

Firstly you’d have to get the positions of the corners of the part (including the center if you need that).
Secondly, you would get the position of the raycast on the part.
Lastly, you would compare the raycast position to all the corner positions. The closest position is the division you’ve hit.

You can find the corners of the part here:

Keep in mind the above example provides eight corners.

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