How can I do this?

As I am currently making my own custom animator I need to display the keyframes of which you can edit.
So I have a frame that they will be displayed on but how can I display them evenly depending on what time of the animation the keyframe comes in?


lets say I have 3 keyframes, The first one is at 3 seconds, the second one is at 8 seconds and the third one is at 19
how can I display them evenly between 20 and 1 seconds?


If you look at roblox’s animator you can see that if you hade a keyframe at 1 and 30 seconds and just a bunch of random ones in-between they are all put evenly depending on when they are.

Thats the best I can explain it. Thanks!

Not a very informative title but I think what you are looking for is CFrame:Lerp() ?

I’m obviously not sure how your animator works but try adjusting this code below to how it does:

local userKeyframes = {} -- the frames added by the user (in CFrames)
local processedKeyframes = {} -- scripted adjustments to even out the animations between keyframes

local smoothness = 0.1 -- smoothness for the lerp (decrease the number to be smoother but keep it at a factor of 1)

for i, frame in pairs(userKeyframes) do
	for lerpIndex = 0.1, 1, smoothness do
		table.insert(processedKeyframes, frame:Lerp(userKeyframes[i + 1], lerpIndex))
	end
end

-- now add the code which processes the keyframes

I didn’t include this but you are going to need to “lerp” the time as well by taking the divided time (which is divided by the lerp smoothness) and adding it at a fraction of the wait (the time in between the user added keyframes)

I know that last paragraph probably made no sense so I’m probably gonna come back tomorrow and edit it into the code.

Again, obviously don’t just copy my code word for word it’s not gonna work, just try rewriting it to fit your animator.

2 Likes