watch the equation change, and watch the bar at the bottom

lerp can be used for everything from health bars, to color fades, smooth angle changes, to smoothly fading sound effect volume. you can also use it in a loop to set up a bunch of sprites in a neat line. there are endless uses. once you understand what it does, you'll find it comes up often as a useful tool when designing games

if you have any questions about how to do any of the above mentioned, or if lerp simply still doesn't make sense. please ask away

once you have a firm grasp on this, you can easily learn cosp, qerp, and cubic, which are even more awesome

update: here's another tutorial with qarp and cubic=

Thanks Lucid, I understand it, just don't think it will be useful for anything. Things like health bars are already easy to do with variables, just subtract/add.

Did you have a look at the cap I posted a couple of replies ago?

It uses lerp on both the X and Y coordinates of the aiming reticle to predict where to shoot to guaruntee a hit on any of the enemy objects. I'm pretty sure that functionality is now built into the system object however, but they're essentially the same thing

Although, correct me if I'm wrong, I think I've actually created quadratic interpolation with two sets of lerp in that example?

Lerp is great for extrapolating and predicting things!

Because while the third argument is usually a value between 0 and 1, you can go BEYOND 1 to start predicting where a value will be based on the other 2 values

I may have a twisted take on the whole thing, as I'm no mathmatician, I basically just learnt lerp from playing around with it on Construct!

Thanks Lucid, I understand it, just don't think it will be useful for anything. Things like health bars are already easy to do with variables, just subtract/add.

If you can't see lerp being useful for anything, then you did not understand it. Just a very simple example:

Lerpin angles is a bit complicated, might do an example of that.

lerp(sprite.angle, new angle,x*timedelta)= boo hoo when new angle is greater than 360, or is less than 0.

That's no problem with math prior to lerp. Set a variable (we call it 'm' here) to:

m = (abs(new angle) % 360) * Sign(new angle) + 360[/code:3phpb3i2]
then use lerp with:
[code:3phpb3i2]lerp(sprite.angle, m % 360,x*timedelta)[/code:3phpb3i2]
Whatever value 'new angle' has, it will be (mathematically correct) shifted to the range 0-360

> Lerpin angles is a bit complicated, might do an example of that.

> lerp(sprite.angle, new angle,x*timedelta)= boo hoo when new angle is greater than 360, or is less than 0.

>

That's no problem with math prior to lerp. Set a variable (we call it 'm' here) to:

m = (abs(new angle) % 360) * Sign(new angle) + 360[/code:1zzglhlo]
then use lerp with:
[code:1zzglhlo]lerp(sprite.angle, m % 360,x*timedelta)[/code:1zzglhlo]
Whatever value 'new angle' has, it will be (mathematically correct) shifted to the range 0-360

just in case anyone missed it, my new math plugin (only has 2 expressions for now, but will be growing, and safe to use starting now) has anglelerp.

it doesn't handle negative angles or angles larger than 720, it's just for object.angles in Construct for now, but it just makes it simple since you don't have to pay attention to the 0 mark. It assumes you want the shortest path from an angle to the next, meaning, if you do anglelerp(350,10,whatever)

it'll assume you want to go up from 350 to get to 10

if you want to take the long way around, you have to find another way