Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to raycast from one CFrame position to another?

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.

3 comments

1

funny number

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.)

0

Xap was here

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.