Understanding raycastResult.Normal

So I’m starting to get into the whole math aspect of scripting, tried to avoid it as long as possible but now its time to learn even as much as I suck at it going through every little bit 1 by 1,

When I use .Normal on my raycast result, I consistently obtain values like -1,0,0 or 1,0,0, which aligns with expectations. However, my custom implementation returns values such as -1, 0.2904, 0.255, deviating from what I anticipate. (-1 never changes)

Maybe what I made is wildly in which case do correct me but as far as I’m aware I followed a formula which Is suppose to get the normal of a vector:

function MetaTable:Normalize(raycastResult)
	local vector = raycastResult.Position
	local vectorLength = math.sqrt(vector.x ^ 2, vector.Y ^ 2, vector.Z ^ 2)

	return Vector3.new((vector.X / vectorLength), (vector.Y / vectorLength), (vector.Z / vectorLength))
end
1 Like

I think you may be confusing normalizing a vector and the normal vector of a surface. One is a vector where its components are restricted to [0, 1] and the other is the direction of the vector perpendicular to an object’s surface.

1 Like

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