I’m trying to use Bezier Curves in a 3D space; however, it’s proving difficult to visualize the path the bezier takes.
I was trying to edit this source code from the bézier curves article, however it’s not really effective
--p0,p1, etc = parts
-- function for drawing a 3D point
function drawPoint(p1)
local f = Instance.new("Part")
f.Size = Vector3.new(0.2, 0.2, 0.2)
f.Position = Vector3.new(0, p1.x - f.Size.X* 0.5, 0, p1.y - f.Size.Y* 0.5)
return f
end
function update(p0, p1, p2, p3, canvas)
local last
canvas:ClearAllChildren() -- clear any previous drawings
for t = 0, 1, 0.01 do -- 0 <= t <= 1
local p = cubicBezier(t, p0, p1, p2, p3)
drawPoint(p).Parent = world
last = p
end
end
If you have a way to generate the points u can just create a part which connects to the other, or alternatively use a beam. Either way all you need to do is have some sort of linking, think like dynamic arrays in c. We need to have a reference to the previous position and our position and see if its index is even or odd. Using this info we can connect them to each other.
The issue is doing so wouldn’t follow the path of the Bézier Curve. The point is to make it follow the curvature, connecting between points with beams can’t do that. With parts I’m not sure.