This may be a stupid question to some of yall but I spent my whole entire day thinking about this and can’t come to a conclusion as to why do we normalize vector to a (1.0,1.0,1.0) for raycasting and then multiply
any video or forum to the other site that will help me will be appreciated or your brief statement on it
Normally we want to control how long our raycasts are, if they are too long Roblox/ the engine will lag. To do this we normalize/unitize our vectors so that when we multiply it by a number the length/magnitude will equal that number:
local up = Vector3.new(0,1,0)
local upNotNormalized = Vector3.new(0,5,0)
print((up*1000).Magnitude) -- length is 1000 desired effect
print((upNotNormalized*1000).Magnitude) -- length is 5000 O_O
print((upNotNormalized.Unit*1000).Magnitude) -- Normalized now, all good length is 1000
--We wanted 1000 but we got 5000
This applies to any normalized vector regardless of direction so yeah hope this helps.
TL;DR, we want to control the length/magnitude of the vector but maintain the direction. Just a mathematics technique that’s very useful.
So I kind of get it a bit more but I just got to experiment with what you just said thanks I appreciate your reply
Completely understand it now .unit is just for those directions you calculate on the go
(For example the cursor moves all around the screen it is impossible to know its direction entering vector3.new(math.random(1,1000),math.random(1,1000),math.random(1,1000)))
it makes the direction to one stud and with the multiply(*) your able to extend that one stud direction don’t know how I didn’t understand this the first time I saw it thanks @dthecoolest