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 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.
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
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.