I’m toying around with bezier curves but I’m extremely new to it. I just copied this from someone, and I want to place it in a part. How would I do that?
return (1-Time)^2*Point0+2*(1-Time)*Time*Point1+t^2*Point2; --This'll give you that curve you were looking for :)
end;```
function Bezier_Module:QuadraticBezier(Time,Point0,Point1,Point2)
return (1-Time)^2*Point0+2*(1-Time)*Time*Point1+t^2*Point2; --This'll give you that curve you were looking for :)
end;```
In Bezier curves, Time or normally referred to as t must increase between 0 and 1 using a loop, This function outputs the position of the curve at time t so all we have to do is just put it in a loop:
function QuadraticBezier(Time,Point0,Point1,Point2)
return (1-Time)^2*Point0+2*(1-Time)*Time*Point1+t^2*Point2;
end
for t = 0, 1, 0.01 do -- Just increase the 3rd value on the for loop to draw the curve with more points
-- Every time we loop we need to add a new part of the workspace to visualize it:
local newpoint = Instance.new("Part")
newpoint.Anchored = true
newpoint.Parent = game.Workspace
newpoint.Position = QuadraticBezier(t, game.Workspace.Point0.Position, --etc. with all 3 points)
end
local steps = .1
local StartPart -- Path to part
local EndPart -- Path to part
local CurvePart -- Path to part
for Time = 0 + steps, 1 - steps, steps do
local Part = Instance.new("Part")
Part.Anchored, Part.CanCollide, Part.Transparency = true, false, .5
Part.Position = QuadraticBezier(Time, StartPart.Position, EndPart.Position, CurvePart.Position)
end