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

How to raycast from one CFrame position to another?

Asked by
oggy521 72
6 years ago

Ray casting uses two parameters, one of the origin position and the other of the direction, however, what I need is for it to ray cast from one point to another point.

1
funny number TwoTramp 18 — 3y
1
Neil was here (if you happen to come by years later, here's a fun fact: I accidentally killed a bug on my computer and feel bad for it.) greatneil80 2647 — 3y
0
Xap was here Xapelize 2658 — 2y

1 answer

Log in to vote
3
Answered by
ozzyDrive 670 Moderation Voter
6 years ago

You calculate the vector from point A to point B with ABvector = pointB - pointA

local pointA = Vector3.new(1, 1, 1)
local pointB = Vector3.new(-1, 1, 0)
local ABvector = pointB - pointA

--  Cast a ray from pointA to pointB
local ray = Ray.new(pointA, ABvector)
Ad

Answer this question