So im trying to get the normal or face surface type based off the position from another part,
P1 is the parts position
P2 is the main part
So im trying to get the normal or face surface type based off the position from another part,
P1 is the parts position
P2 is the main part
Just the four sides?
I’m assuming p1 and p2 are both parts.
First find the object-space offset of p1:
local offset = p2.CFrame:PointToObjectSpace(p1.Position)
Divide by the part size so you can directly compare the two:
local size = p2.Size
local dx = offset.X / size.X
local dz = offset.Z / size.Z
And check which is bigger, then differentiate left/right and up/down
if math.abs(dx) > math.abs(dz) then
if dx < 0 then
print("left side")
else
print("right side")
end
else
if dz < 0 then
print("front side")
else
print("back side")
end
end
well what if rotation was included in.
Sorry, not sure what you mean. This would work even if p2 was rotated.