How do I make it so that the parts go right after another on my Bezier Curve?

Hey so I’ve created a interpolated bezier curve thing and everything is working but the problem is that im trying to create multiple parts on the curve but like there staying in the same spot, im just not sure how to fix it so it can work with any amount of parts and just flow like a stream?

The code:

local totalDuration = 1
local elapsed = 0

game:GetService("RunService").Heartbeat:Connect(function(dt)

local p1 = workspace.p1.Position
local p2 = workspace.p2.Position
local p3 = workspace.p3.Position

elapsed = elapsed + dt
local t = math.clamp(elapsed / totalDuration, 0, 1)

if t >= 1 then
    -- right heree
	for i = 1, 2 do
		local newDroplet = droplet:Clone()
		newDroplet.Position = p1 + Vector3.new(0,0,0)
		newDroplet.Anchored = true
		newDroplet.Parent = workspace.Droplets
	end
	elapsed = 0
else
	for i,v in ipairs(workspace.Droplets:GetChildren()) do
		v.Position = BezierLerp(p1,p2,p3,t)
	end
end
end)

You can offset the input to the curve, so while one part is at 0.5 along the curve, the next part may be at 0.45 and so on. This wont create a perfect spacing in terms of arc length, since beziers are not parameterized for arc length, but it will be close enough for curves with relatively constant velocity.

1 Like

Yeah alright so basically how I solved it was I added basically an offset based on the amount of particles I want, then i added that to the t an it worked! @azqjanna

local numDroplets = math.floor(t * numParticles) -- Number of droplets to create at this time step
local tOffset = 1 / (numDroplets + 1)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.