Bezier Curve Projectile Travel Speed

So i basically am using bezier curves for my projectile, and i want it to travel at the same speed, Currently if i aim it close by it travels slow and if i aim it far it goes fast, how would i make it travel at the same speed no matter what the distance is between StartPosition and EndPosition.

function Quadratic(p1,p2,p3,i)
  p1,p2,p3 = p1,p2,p3
 return Lerp(Lerp(p1,p2,i),Lerp(p2,p3,i),i)
end

for i = 0, 1, 0.025 do
  local TargetPosition = Quadratic(Clone.Position,Clone.Position + Vector3.new(0,15,0),MouseCF.Position + Vector3.new(0,0,8),i)
  Projectile.Position = TargetPosition
  RunService.Stepped:Wait()
end

You can divide the speed by the magnitude of the two positions

You can also approximate the length of the bezier and divide the speed by that, instead.

Note that the speed along a bezier isn’t constant in general. You’d need to approximate that as well. Google “bezier curve constant movement speed”, there are a few posts online about options if that’s what you need.

Edit: actually just read this article

1 Like

This doesn’t work?

function Quadratic(p1,p2,p3,i)
p1,p2,p3 = p1,p2,p3
return Lerp(Lerp(p1,p2,i),Lerp(p2,p3,i),i)
end

local Distance = (MouseCF.Position - Projectile.Position).Magnitude

for i = 0, 1, 0.025 do
local Time = i/Distance
local TargetPosition = Quadratic(Projectile.Position,Projectile.Position + Vector3.new(0,15,0),MouseCF.Position,Time)
Projectile.Position = TargetPosition
RunService.Stepped:Wait()
end

I’ve read about it and i don’t seem to understand " Arc-length parameterization", Could you maybe explain it in a more simple way?

or show me how i could add that to what i’ve got right now.

That article has many good code snippets so I won’t write more, but arc-length paramaterization is just “guessing the length of the curve”. But it’s a good guess.

Actually this kinda works but now it’s so when i aim close by it goes fast and when i aim far away it goes super slow