How the heck do I get which side when the raycast normal is wacky

So basically the part that i’m raycasting too is slightly rotated and I want to get the surface normal, and of course I get it but it’s all wacky and I have no clue which side im raycasting on

the code

print(raycast.Normal)

the part

image
image

I tried normalizing it but that didnt work…

1 Like

You need to transform the normal from world space to local space. Raycast result normals are in world space:

local localNormal = part.CFrame:VectorToObjectSpace(normal)
1 Like

Alright I tried that but it just makes it worse, thank you though

image

whats the issue exactly? you’re output seems to be the normal which is essentially the opposite direction from the actual ray cast

Yeah but I have no clue which side it is im raycasting onto…

Usually Vector3.new(0,0,-1) would be the front but I cant even figure out which side it is with those random values

You can try to use math.Round()

1 Like

On every single axis of the surface normal?

What do you mean, that looks correct. That’s the front surface (negative Z)

Mhm. . .

i literally tried it on the left side of the part and it still made the Z -1

Welp i feel stupid af, rounding it worked, the numbers were just so wacky i didnt think this worked
@azqjanna @msix29 thanks guys i appreciate it
image

1 Like

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