I have code that allows me to draw a line of a set distance, at whatever angle I want, starting from the player's head to the Mouse.Hit.p (Mouse HIt Position). I want to have the line drawn up to 10 studs max, to physically represent the Ray, but also put a Sphere at the end of the line - about 10 studs from my player's head. I've been pouring over online examples of rays and raycasting, CFrame properties, Vector3 properties, but no examples of anyone setting points or figuring out how to get vector points along a ray. Its easy enough to put something at the point where the ray hits a part, but I want to set a sphere at specific points along the line. What am I missing? Any suggestions? Thanks in advance.
✓ ANSWER ACCEPTED
How To Create Points/Nodes Along A Drawn Ray?
1 answer
✓ Accepted answer
Alright so you've got a vector from the head to the mouse hit position. The direction of this vector is stored in the unit property.
Now that we have the direction, we can multiply this vector by the length you want in order to get a vector of that length in that direction. But this results in a vector centered at the origin (0, 0, 0). We can simply add this vector to the position we want the vector to be centered in order to position it.
This vector we found represents the position at a certain distance along the original vector.
local vector -- Vector you found
local origin -- Position of the head in your case
local newVector = origin + vector.unit*10
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Thanks - I was so close to solving this... I was making things more complicated than they should have been, of course...