How can I raycast a bezier curve?

Can anyone help with any code or ideas? How can I make the result of a raycast follow a bezier path? Anything will help <3

You can’t raycast a curve because a raycast is a like a part beam when something touchs it, its true but when not its false.

I’m fully aware of what a raycast is, but I’m sure that it can it can be casted on a bezier.

Don’t know if it can be done exactly. A decent and simple approximation is to sample a bunch of points and just do normal raycasts between each pair of adjecent points.

No it can’t be you have to make a two parts and 2 raycasts like I showed in the image I posted.

Yeah, I can do raycasts and I can also visualize them but I was wondering if I can do it on a bezier curve, but I will try raycasting infront of the projectile then

Well I don’t know how to do that. :confused:

Haha, thanks for the help anyways, here’s what I did unknown_replay_2022.04.10-17.34_1, but I will try doing something about that raycast

You can just raycast by making the bezier curve twice in order for it to have a start and a direction such as using this way:

for i=1,2,.1 do
local newI = i-1
local bezier1 = makeBezier(newI,...)
local bezier2 = makeBezier(newI+.1,...)
local raycast = workspace:Raycast(bezier1,bezier2-bezier1)
task.wait(.1)
end
2 Likes

But your ray is not following the bezier curve. Is there a way to make the ray follow the bezier curve?