Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to get the "end position" of a ray?

Asked by
gitrog 326 Moderation Voter
6 years ago

So, I've made a ray using the following script.

local ray = Ray.new(firePartPos, (target - firePartPos).unit * movementPerFrame)

I've looked through the Ray page on the ROBLOX Wiki, and I don't see a way to find the "end position" of the ray. How would I get that.

(Yes, I know ray's are infinite, but the raycasting tutorial made it sound like the number at the end (movementPerFrame) would restrict the ray's distance. If this does not give an end position of the ray, I'd like to find a way to get the position on the ray with movementPerFrame studs from the starting point of the ray.)

1 answer

Log in to vote
2
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
6 years ago
Edited 6 years ago

The "end" of a Ray is ray.Origin + ray.Direction.

In general, ray.Origin + distance * ray.Direction.unit is the position that is distance studs along the ray. The end is just ray.Direction.magnitude studs along the ray.

Ad

Answer this question