Hundreds of features to explore
Games made in Construct
Your questions answered
Popular & trusted by schools and Universities world-wide
Construct 3 runs in the browser & works offline
Students do not need accounts with us
Our educational partners
Free education resources to use in the classroom
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
Could someone please explain me how it works?
nlerp(a, b, y) Reverse linear interpolation: if lerp(a, b, x) = y, then unlerp(a, b, y) = x. Calculates (y - a) / (b - a).
but to be fair i don't get it.
The manual gave the full definition: it calculates (y - a) / (b - a), which is the opposite of lerp. So unlerp(a, b, lerp(a, b, x)) = x. E.g. lerp(10, 20, 0.5) gives 15, so unlerp(10, 20, 15) gives 0.5.
Yes, that part of manual I can understand ;P
Let me rephrase my question. What about practical use of unlerp
I can easily comprehend what e.g. lerp(self.x,target.x,dt) do, but unlerp?
I know i'm missing something simple.
Develop games in your browser. Powerful, performant & highly capable.
One possible use of unlerp is to do scrollbar math.
In layman's terms, it gives you the percentage of point between two values.
You have points A and B and you want to know where your "x" between points is in relation to those points. So you do unlerp(A,B,x) to see where the x is standing relative to the range between A and B.
Thanks for the examples of using unlerp guys! It's SUPER useful stuff.