I have been looking at some wiki pages on Raycasting, and I have failed to understand how to direct the ray where you want it. I know that to make a ray, you do something like this:
local ray = Ray.new(startposition, direction?)
The thing I don't understand is what to put to make the ray go in the way I want. Do I have to put another point along the path I want it to go on?
Also, I am wondering if/how it is possible to send a ray in a certain direction based on a mouse click on the screen.
Thanks in advance!
The direction is equal to (endpoint-startpoint).unit * length
. Subtracting the starting point from the ending point results in a vector pointing in the correct direction, and .unit
normalizes that vector so that all components are less than or equal to one. To create a ray from any point to the mouse's target, simply set the endpoint in that formula to Mouse.Hit.p
.
Locked by SanityMan, Perci1, Shawnyg, and BlueTaslem
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?