Easing Functions

Inertia and Elasticity are one way to do smoothing in Movement / Time, the other way is by applying an easing function to your effect. The two approaches each have their own strengths and weaknesses.

Inertia and Elasticity work by adding a “lag” to the position before it is returned. This “lag” allows a sequence to gracefully handle changes in direction and speed. I&E is well suited for complex sequences on objects in your world. Easing functions are a very different approach to smoothing. Normally the “PercentDone” variable moves in a straight line from 0% done to 100% done. Easing functions simply make that line progress in more complicated fashion (a non-straight line). Easing functions work well when you are moving UI elements around, like menus or buttons. The advantage of easing functions is that they automatically scale with the size of the transition and they will always leave your effect at the end point. The biggest disadvantage of the easing functions is that it’s really hard to make them handle changes in direction, so they are often badly suited for moving around objects in your environment.

In order to use Easing functions you have to first include the proper namespace: “using MovementEffects.Extensions;” Then you just need to assign the CalculatePercentDone function in your effect to one of the easing functions. If you need some kind of exotic easing like SinInPow3Out, then you can just extend the Easing class in MoT Extensions.cs (they’re all quite simple.)

Here is a graph of the current easing functions:Easing Graphs