-
-
Notifications
You must be signed in to change notification settings - Fork 18
lerp
drewmccluskey edited this page Jan 9, 2019
·
5 revisions
This function will return a percentage of the sum of two inputs
lerp(float a, float b, float amt)
Argument | Description |
---|---|
float a |
The first number to add |
float b |
The second number to add |
float amt |
The percentage to return |
Returns: float
This function will return a value which is the stated percentage of the sum of two input float values. It can be used to predict movement within a program.
float tax = lerp(income, -expenses, 0.1)
This will set float tax to ten percent of net income in a game of finances for example.
float xFuture = lerp(x, x+hspeed, room_speed/2)
This code will set float xFuture to the predicted x position of an object after half a second of gameplay. This can be useful for online games to reduce visual lag as well as for smarter enemy AI.
Back to interpolations