Hey there. I was actually seeing a lot of posts about Normals of a Ray, and I am very confused about what it actually is. Help’s appreciated Here’s my a bit of code:
local rayResult = workspace:Raycast(workspace.Part.Position, workspace.Part.CFrame.LookVector * 50);
if rayResult then
print(rayResult.Normal) -- Prints 1, 0, 0 even if I rotate the part.
end
Thanks again
2 Likes
Rays are vectors. Vectors have a size (usually called magnitude) and a direction. A normalized vector is a vector whose size is 1.
EDIT: Oh I’m a dummy. I misunderstood what the .Normal property was referring too. The post below is correct.
1 Like
The normal isn’t returning the face perpendicular to the point you hit, but it’s telling you a vector or direction that’s perpendicular. A great diagram I was by Quenty:
https://devforum.roblox.com/t/surface-normal-why-vector3/12654/5?u=awesom3_eric
I recommend you check this out for a better understanding of how it works.
I used the normal property for creating bullet holes on walls. The best way to do that was to set the bullet hole part at the position of the raycast and orientate it facing the direction of the normal.
Bullet.CFrame = CFrame.new(raycastResult.Position, raycastResult.Normal)
14 Likes
Oh, so basically it gives the normal vector perpendicular to the position the ray hit?
Right, it returns the normal as a direction.
I see. Thanks for your great explanation. I love it.
1 Like