I’m sure there is already a topic on this, I just couldn’t find one. So when you do
what is normal?
It is the deprecated version of this:
local Params = RaycastParams.new()
Params.FilterDescendantsInstances = {}
Params.FilterType = Enum.RaycastFilterType.Blacklist
local RayResult = workspace:Raycast(Origin, Direction, Params)
does the same, but should no longer be used.
Deprecated
This function has been deprecated. UseWorldRoot:Raycast()
along withRaycastParams
for new work.
yeah I get that its used to make a ray, just unsure what the normal variable is equal to
That variable is the same as RaycastResult.Normal
.
It is as if all the variables it gave were put into a table. but obviously it is not
So if a ray is heading towards a surface of a part and hits it, the normal vector would be a new vector going out from the point on the surface that was hit by the ray on a right angle?
More or less, CFrame
can give LookVector
, RightVector
and UpVector
, what the normal thing does is identify the face in which it impacts and returns one of those values, if it is the left face it will return -RightVector
, if it is the face below it will return -UpVector
and so on.
the face of the part being hit?
Imagine it like this
Blue line is only a reference of where you are looking, it is not important
The red line is a ray and the darkest face is where it hits, that is the right face of the part.
If you put this in the command bar and the target part has rotation 0,0,0
print(workspace:Raycast(workspace.RaycastPart.Position, workspace.Target.Position).Normal)
-- RaycastPart: light blue square - Target: green square.
-- Output: 1, 0, 0
if you print this
print(workspace.Target.CFrame.RightVector)
-- OutPut: 1, 0, 0
They are the same following the logic that I raised before.
Correct.
However, if you wanted for example an object to face that direction (from the normal), you’d have to (I think?) convert the position the ray hit into a CFrame
, then do the same except add it by the normal.
Ex:
CFrame.new(position, position + normal)
In a sense, normals are like faces, pretty much.
They’re Vector3
variables that are usually in -1, 0, and 1. It might not look convincing, but it’s the direction of where the ray hit.
In essence,
0, 1, 0 = Top
0, -1, 0 = Bottom
1, 0, 0 = Right
-1, 0, 0 = Left
0, 0, 1 = Back
0, 0, -1 = Front