How do I check if a line segment intersects a point?

Hello everyone,

I need some help determining if a line segment (formed between two parts) intersects an edge (one part).

This picture should help to illustrate what I’m trying to do:
Background

I have no idea how to do this, so any help is very appreciated.

Please help. :pensive:

Rays should work for you.

local p0,p1 --parts for the line
local ep --edge part

local ray = Ray.new(p0.Position,p1.Position-p0.Position)
if workspace:FindPartOnRayWithWhitelist(ray,{ep}) then
    --stuff
end
1 Like

Wow, I don’t know why I thought it would’ve been more complex.

Thanks for the help!

1 Like