Easing algorithms

In gamedev you always need some way to ease values in or out. Most of the time you need this for fading in stuff, or sliding in images, objects etc. for your nice animated UI.

The simplest way to smoothly ease a value v to a TARGET_VALUE is doing

v += (TARGET_VALUE - v)*0.8

every frame. (0.8 can be changed to any value in the (0, 1) range to adjust the easing speed.) Any experienced developer will immediately spot the problem here. Although the algorithm is very easy to implement, it does not take frame time into account. So if your game is not locked to a fixed frame rate, then your easing will still be smooth, but its duration will depend on your frame rate.

If you want easing methods considering frame time then go here. This site contains a lot of different algorithms for ease in, ease out and ease in/out, including a live demo and source code.

Share this: