How to check what face a part is touching with

A simple question (i hope). How do you check what face a part is touching another part with, (assuming the part is a 6-sided polygon)

From what I know, parts themselves don’t return what side the part was touched on with ‘Touched’ (which is odd considering touched is when two surfaces collide)

3 Likes

What do you mean “Face a part is touching with” could you be a bit more specific? (could you provide a screenshot) (if possible)

In this picture, you’ll see what I mean with ‘face is touching a part with’. This example shows the red part touching the green part with the Front face

2 Likes

This is fairly difficult to do because there is no way to get how two parts are touching.
But if you are talking about using a rectangular hitbox like that at all times, you could probably try getting the position of both and performing calculations based on the edges or corners of the box to determine which face is interacting with the object.

1 Like

Building on that, I think using CFrame data, which has Right, Look, and Up vectors (I think, it could be left, I forget). If the parts are colliding, you can find which faces are touching by finding which vectors are parallel, assuming they are not rotated in any way. If they are rotated, it gets trickier, but it should still be possible to do this.

for simple shapes, you could simply raycast, and if the first part on that ray is half the size away from the middle point of that shape, it touches

1 Like