Bezier Curve Loopings

Hi, I’ve been dealing with this problem for a really long time now and I have a Bezier Curve that should have both loops and a smooth curve alignment. Unfortunately, as soon as I change Up to Vector3.new(0,1,0) the curve rotates smoothly but doesn’t loop. When I do Up to direction:Cross(right).Unit, there are loops but no smooth rotation.

Smooth rotation:

			for i = 0, numPoints do
				local t = i / numPoints
				local nextT = (i + 1) / numPoints
				local slerpPosition = bezier(StartPart.Position, ControlPart.Position, EndPart.Position, t)
				local nextPosition = bezier(StartPart.Position, ControlPart.Position, EndPart.Position, nextT)
				local direction = (nextPosition - slerpPosition).Unit
				local right = previousUp:Cross(direction).Unit
				local up = Vector3.new(0,1,0)

No smooth rotation but loopings:

			for i = 0, numPoints do
				local t = i / numPoints
				local nextT = (i + 1) / numPoints
				local slerpPosition = bezier(StartPart.Position, ControlPart.Position, EndPart.Position, t)
				local nextPosition = bezier(StartPart.Position, ControlPart.Position, EndPart.Position, nextT)
				local direction = (nextPosition - slerpPosition).Unit
				local right = previousUp:Cross(direction).Unit
				local up = direction:Cross(right).Unit

Btw the up value just keeps changing.
Thanks for every answer, I really don’t know how to solve it.

2 Likes

Can’t be answered without the code for bezier()

4 Likes

Oh, Sorry

	local function bezier(p0, p1, p2, t)
		local h = (1 - t)
		return (h * (h * p0 + t * p1) + t * (h * p1 + t * p2))
	end
1 Like