Hi! I’m scripting a Bezier Curve but for some it gets slower at the end. Here is a video about the behaviour:
Even after adjusting the curve-part it still is slower at the end.
Here is the script:
local function lerp(beginning, goal, alpha)
return (1 - alpha) * beginning + alpha * goal
end
local function quadratic(beginning, curvePoint, goal, alpha)
local Lerp1 = lerp(beginning, curvePoint, alpha)
local Lerp2 = lerp(curvePoint, goal, alpha)
return lerp(Lerp1, Lerp2, alpha)
end
for i = 0, 1, 0.01 do
wait()
workspace.beginning.Position = quadratic(workspace.beginning.Position, workspace.curve.Position, workspace.goal.Position, i)
end
So the problem is that the majority of alpha (i) is between the 2 final parts, so I tried to base the wait time on it, but that didn’t turn out that well too.
local function lerp(beginning, goal, alpha)
return (1 - alpha) * beginning + alpha * goal
end
local function quadratic(beginning, curvePoint, goal, alpha)
local Lerp1 = lerp(beginning, curvePoint, alpha)
local Lerp2 = lerp(curvePoint, goal, alpha)
return lerp(Lerp1, Lerp2, alpha)
end
local lastPoint = nil
for i = 0, 1, 0.01 do
local l = quadratic(workspace.beginning.Position, workspace.curve.Position, workspace.goal.Position, i)
if lastPoint then
wait((lastPoint - l).magnitude/20)
else
wait()
end
workspace.beginning.Position = l
lastPoint = l
end
https://streamable.com/y02uri
Thank you!
Btw: Sorry for the discord notifications, I forgot to turn them off, lol.