Bezier Curve Issue

I’ve made a Quadratic Bezier Curve. To find the point between 2 positions i am subtracting the 2nd point from the first point. For example, (End - Start) which i think is correct. Im then adding on my own vector to the middle vector to give the part sometime to curve to. Here is my code

function VFX:Bezier(Part,Start,End,Type)
	local function lerp(p0,p1,t)
		return p0*(1-t) + p1*t
	end
	local function Quad(p0,p1,p2, t)
		local L1 = lerp(p0,p1,t)
		local L2 = lerp(p1,p2,t)
		local Quad = lerp(L1,L2,t)
		return Quad
	end
	local Middle = (End - Start) + Vector3.new(0,20,0)
	for i = 1,100 do
		local t = i/100
		local updated = Quad(Start,Middle,End,t)
		Part.Position = updated
		wait(0.001)
	end
end

Instead of finding the middle, it curves all the way to the position 0,0,0 on the map then back around to the end point.
I’ve searched everywhere and cant find out why?
if you have any answers please let me know!

1 Like

the middle would be

local Middle = (End + Start)/2 + Vector3.new(0,20,0)

You can’t subtract 2 points to find the middle between them.
There are two easy methods to get the middle:

Start:Lerp(End, 0.5)
(Start + End) / 2