-->
Today, I learned how to utilize Linear Interpolation (Lerp) in Unity.
Lerping is…
No, not that…
Linear Interpolationis a linear transition between two coordinate points on any bi-axial plane. A color picker is essentially a graph of hues, where each color has an x-coordinate and a y-coordinate. Choosing two colors is thus equivalent to choosing two coordinate points on a graph of color data. Lerping then, in the scope of color, means to smoothly transition from one color coordinate to the other. This is by no means the only use case for lerping either. Anything that can be represented as two points on a plane can be linearly interpolated.
Side Note:
I will never come to terms with the phrase that I’ve heard too often throughout my career as a student… “When will we ever use this?!?”
HERE.
Here is one out of infinite examples in which math can be used in life. With some creative thinking, math can be found in… well in anything.
I digress…
Linear Interpolation has many use cases in video game development. A character can be lerped from one position to another by way of transformation, an object can be interpolated on a rotational axis from one angle to another, or as in my game, colors can be interpolated. As I’ve said, linear interpolation can really be used for any situation that can be represented as a pair of coordinates.
Here’s how lerp is utilized in my game, Neon Cloud:
What you’re seeing is a series of 10 sprite panels that make up the background. Each panel is lerping over a series of colors, offset from one-another by a fraction of time. The overall effect I’ve created is a retro-like box gradient of gradients.
VS.
This is the old background, which chooses from a random color range at startup, and that’s it…BORING
No! Not that!
If you want to see videos or support my development, please check out my Youtube channel where I post progress snippets, dev streams, and devlog videos about the game. Please consider liking and subscribing. Your support is greatly appreciated and will allow me to continue doing what I love!
And every subscriber gets me closer to a shorter URL!