I have a script that can tween a part along a Bezier curve to a moving object. The problem I am having is that the movement is at irregular intervals, and starts out very fast and then slows down greatly.
you can see on this video what I am talking about. If you watch the entire thing, you can also see me scrolling through the output to show that my weight value never speeds up or slows down its increase rate. (the weight value determines how far along the curve the part should be)
here is my script:
local ts = game:GetService("TweenService")
local rs = game:GetService("RunService")
function lerp(a, b, t)
return a + (b - a) * t
end
function quadraticBezier(t, p0, p1, p2)
local l1 = lerp(p0, p1, t)
local l2 = lerp(p1, p2, t)
local quad = lerp(l1, l2, t)
return quad
end
return function(part,targetpart,tweeninfo)
local startingpoint = part.Position
local startingrotation = part.Orientation
local weight = Instance.new("NumberValue")
local step = rs.Stepped:Connect(function()
print(weight.Value)
part.Position = quadraticBezier(weight.Value, part.Position, workspace.P2.Position, targetpart.Position)
end)
local tweeninfo = tweeninfo or TweenInfo.new()
local tween = ts:Create(weight,tweeninfo,{Value = 1})
tween:Play()
tween.Completed:Wait()
step:Disconnect()
end
this module script gets called in another script like this:
require(script.Parent.Tweening)(workspace.Part,workspace.me7474.HumanoidRootPart,TweenInfo.new(5,Enum.EasingStyle.Linear,Enum.EasingDirection.In))
you can also see that the easing style is linear, meaning the speed changes shouldnt happen.
I am very confused as to why this is happening, and would love assistance.