Can lerp only process 3 arguments??

Godot Version

4.4.1

Question

Can lerp only process 3 arguments??

lerp takes in exactly three arguments by design. It interpolates between the first two parameters by a weight specified with the third parameter. For example:

print(lerp(1, 2, 0.5))

Outputs “1.5” because 1.5 is exactly between 1 and 2 and we provided 1/2 as the weight.
If it helps, lerp(a, b, t) is exactly the same as a + t * (b - a) or a + b * t - a * t

2 Likes

How many did you want? What are you getting at or what additional arguments would you need and to what end?

Asking out of genuine interest in your question.

1 Like

lerp() takes exactly three arguments, for the reason that @yesko gave, but it’s worth noting that Godot has versions of lerp() for things like Vector3, so you don’t have to do component-wise lerping in most cases.

Are you hoping to gang up multiple things in the same interpolation, or are you hoping to interpolate between more than two positions?

2 Likes

@hexgrid
I was thinking that perhaps they wanted a more complex lerp, like using a curve or a tween function for more complex lerp-like behaviour. If that is what the OP meant I could dig up an example of some code for them, but at the moment it is still a bit of a mystery what they intended.

PS And as for lerp variations lets not forget the fabulous lerp_angle, one of my favourites.

1 Like

I tried 4

Thank You

Thanks

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.