- Home /
Are there any easing functions built into Unity 5?
Besides Lerp
and SLerp
, does Unity have any sort of easing functions built in, say if you wanted to move an object from point A to point B in exactly 2 seconds with a "Cubic ease-in"?
This seems like something that should be built into any game library, but I can't find any reference to it. I have been having a difficult time Googling this; what have been finding (among a whole lot of unrelated or completely incorrect stuff) are the occasional function written by individual forumers.
Is there proper easing built into Unity 5, or am I going to spend my weekend porting Robert Penner's easing functions? (I don't mind, I just don't want to do the work and realize on Monday it already existed).
Answer by tanoshimi · Aug 19, 2016 at 02:19 PM
The mathfx library provides the most common interpolation functions, including hermite/sinerp/coserp/berp. There's a C# implementation for Unity here: http://wiki.unity3d.com/index.php?title=Mathfx
If you want to define an arbitrary easing function, it's trivial to create an AnimationCurve parameter and evaluate the value of the curve at any position between 0-1, then pass that value into Lerp().
That is in the right direction. Just to be clear, $$anonymous$$athfx
is a user contributed library (and by "library", I mean that C# class you have to save as a file), correct? There's no easing or tweening built into Unity?
Your answer
![](https://koobas.hobune.stream/wayback/20220612091132im_/https://answers.unity.com/themes/thub/images/avi.jpg)