Hello, new to raycasting, but very confused with the end
local ray = Ray.new(script.Parent.Handle.CFrame.Position, (mouse.Hit.Position - script.Parent.Handle.CFrame.Position).unit * 300)
At the end the .unit * 300 part what does that do? First of all what does unit mean, second of all, what is * that supposed to do?
Let's say you have a Vector3
with the value of (10,0,1), the unit would be a ratio of all components combined.
t = x + y + z
unit = Vector3.new(x / t, y / t, z / t)
Since 10 (x) + 0 (y) + 1 (z) is 11 t equals 11.
10 (x) / 11 (t) is 0.9090909...
1 (z) / 11 (t) is 0.0909090...
Therefor the unit is Vector3.new(0.9090909,0,0.09090909)
.
Unit can be used to set the distance of a raycast
. The multiplication part is to change that distance.