What is the math behind Easing Styles?

So I used to use the TweenService a lot for animating. It’s a great tool but it has one flaw that I just can’t get around. The TweenService requires an object to tween, so if I want to tween a CFrame, I have to call an object that has a CFrame property, or use a CFrameValue.

For one of my new projects, I can’t do that. How would I be able to employ all of the easing styles into a for loop using CFrame:lerp instead? Does anyone actually know the mathematical functions behind each style?

7 Likes

You can use TweenService:GetValue, which takes the desired alpha value and returns a new alpha value to be used with a linear interpolation that corresponds with the easing style and direction that you also pass to the function.

-- gets the alpha to be used in a linear interpolation that represents the halfway point of an in-out sine tween
local alpha = tweenService:GetValue(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local cFrame = cFrame1:Lerp(cFrame2, alpha)
49 Likes

Thank you very much, I actually didn’t know that existed. This helps ALOT!

2 Likes

Beautiful. Thanks for doing so. Take my like.

2 Likes