Hey developers! How do I raycast in a specific direction? For example if I set the origin position to Vector3.new(18,18,18), how would I raycast down from Vector3.new(18,18,18)? I’ve searched the devforum for similar topics but I cannot find anything which might help me.
Ray.new requires two arguments; Origin and Direction.
The origin is the position for the start of the Ray, and the direction is the direction for the ray, offset from the origin position.
So if we do Ray.new(Vector3.new(30, 0, 0), Vector3.new(0, -1, 0) * 10)
then this Ray will go downwards from the origin position Vector3.new(30, 0, 0)
by 10 studs before it stops.
The typical setup would be Ray.new(Origin, Direction * Length)
4 Likes