How do I do this with Bezier curve?

Simple but not simple, I have a bezier curve line but im stuck on how to make my Ball
Follow the bezier curve line? sorry if I didn’t explain it right.
thank you for the time!

1 Like

How are you calculating the bezier line? Couldn’t you just lerp the ball to follow the next point in the curve?

Create a loop, calculate the position using the bezier curve formula with the time as the index of the loop. Place the ball there then continue until it’s finished the curve.

Hold up Im confused, Could you explain it more specifically?
thanks.

your final calculation for your bezier curve, just set the position of your ball to that

For example when I did the final calculation for a quadratic bezier curve I would just set the part position to the value:

local l1 = lerp(fruitVal.PrimaryPart.Position, lerpPart.Position, t)
local l2 = lerp(lerpPart.Position, HRP.Position, t)
local quad = lerp(l1, l2, t)
					
plrPart.Position = quad

By the way Im making it so the ball flings as my Curve when I click a ClickDetector.
some of my code as an example;

local function ConstructQuadraticBezier(start, finish, control)
	local Line1 = ConstructLinearBezier(start, control)
	local Line2 = ConstructLinearBezier(control, finish)
	return function(t)
		return LinearBezier(Line1(t), Line2(t), t)
	end
end

local Bezier = ConstructQuadraticBezier(startpart.Position, endpart.Position, controlpart.Position)

You can start a loop,

for i = 0, 1, 0.001 do
	local Point = ConstructQuadraticBezier(startpart.Position, endpart.Position, controlpart.Position)(i)
end

Point, would be equal to the point on the curve at i.

Yeah I already Have that…
I already did the bezier curve, want to see my complete code?

Sure
that would be helpful for me

OK , here is my code.

local points = workspace.Points
local startpart = points.Start
local endpart = points["90Right"]
local pointpart = script.Start
local controlpart = points.Control

local function ConstructLinearBezier(start, finish)
	local range = finish - start
	return 	function(t)			--start + range*t
		return start + range*t
	end
end

local function LinearBezier(start, finish, t)
	
	local range = finish - start
	return start + range*t
end


local function ConstructQuadraticBezier(start, finish, control)
	local Line1 = ConstructLinearBezier(start, control)
	local Line2 = ConstructLinearBezier(control, finish)
	return function(t)
		return LinearBezier(Line1(t), Line2(t), t)
	end
end
local function Point(position)
	local part = pointpart:Clone()
	part.CFrame = CFrame.new(position)
	part.Parent = workspace.BezierCloned
	return part 
end


local Bezier = ConstructQuadraticBezier(startpart.Position, endpart.Position, controlpart.Position)


for t = 0, 1, 1/100 do
Point(Bezier(t))
end

Thanks.