Lerping NumberSequences

Hey! I’m trying to find the best way to lerp NumberSequences because the built in :Lerp does not work with them.

Are the keypoints in the same place? That would make this much easier. Either way though, I’d just lerp anything that matters and create a new NumberSequence with it.

local function lerp(a, b, t)
    return a+(b-a)*t
end
2 Likes

Thanks!

I found a simple solution but it does require all the keypoints to be in the same spot which is fine I guess…

Here’s my code:

local function Lerp(a, b, t)
	return a + (b - a) * t
end

local function LerpNumberSequnce(a,b,t)
	local NewKeypoints = {}
	for i, OldKeypoint in pairs(a.Keypoints) do
		local WantedValue = b.Keypoints[i].Value
		table.insert(NewKeypoints, NumberSequenceKeypoint.new(OldKeypoint.Time, Lerp(OldKeypoint.Value,WantedValue,t)))
	end
	return NumberSequence.new(NewKeypoints)
end
1 Like