Sequences with easing support (NumberSequence, Color3Sequence, UDim2Sequence, Vector2Sequence, Vector3Sequence, CFrameSequence)

I just thought it would be nice to add more sequence types (like NumberSequence) but with easing support with it’s own GetValue method.

I copied the behavior of NumberSequence/ColorSequence pretty much 1:1 so it should be reverse compatible with any existing code.


--!strict

local NumberSequence = require(script.Parent.NumberSequence)
local NumberSequenceKeypoint = require(script.Parent.NumberSequence.NumberSequenceKeypoint)

type NumberSequence = NumberSequence.NumberSequence
type NumberSequenceKeypoint = NumberSequenceKeypoint.NumberSequenceKeypoint

local sequence: NumberSequence = NumberSequence.new({
	NumberSequenceKeypoint.new(0, 0), -- By default, it uses Enum.EasingStyle.Linear and Enum.EasingDirection.InOut
	NumberSequenceKeypoint.new(0.5, 5, Enum.EasingStyle.Quad),
	NumberSequenceKeypoint.new(1, 10, Enum.EasingStyle.Quint, Enum.EasingDirection.Out),
})

for i = 0, 1, 0.01 do
	print(sequence:GetValue(i))
end

Download: Sequences.rbxm (7.3 KB)

The file currently has NumberSequence*, Color3Sequence, UDim2Sequence, Vector2Sequence, Vector3Sequence, and CFrameSequence.

* Overrides the existing built-in keywords, but essentially functions the same.

All of these modules have the same constructor.


Before you ask: yes, this can be under one module, but I just wanted to (re)use the default constructor. Feel free to do it yourself.

3 Likes

I was always thinking of making functions to get value at point of a sequence available to public since somehow it is not part of the API.
Good resource that has better functionality than mine, although it has specific use cases (like my thing with EditableImages)

1 Like

It’s quite bizarre to me that the API itself doesn’t even have this function, even though they provided an example in the documentation.

I personally use CFrameSequence for client-sided moving platforms that sets themselves up and runs every heartbeat synced to server time.