The lerp expression take the input range made by the two first values and consider it as equivalent to 1, then returns the value that corresponds to the x ratio. In other words, it takes the difference between the first two values, multiply it by the interpolation ratio and adds the result to the first value.

This is what happens when you set a variable to lerp(variable,600,0.5) every tick, considering that the variable initial value is zero:

In the first tick the variable will be set to the middle point between the range 0-600, which is 300. In the next tick the lerp will take the current variable value that is 300, and return the middle point of the range 300-600, which is 450. In the third tick the range will be 450-600 and lerp will return the middle point 525, and so on for the other ticks until it reaches 600.

The rate at which the variable changes is a curve and not a straight line, so you get a deceleration as the variable approaches the destination value.

If you want a constant rate you need to set constant values to the range and increment the ratio every tick. So you need to do something like:

+Every Tick

>set width to lerp(0,600,variable)

>set variable to clamp( variable + dt / duration ,0,1)

Being 'duration' the desired time in seconds to go from 0 to 600. Which means that if duration=2 the width of the object will go from 0 to 600 in 2 seconds.

The clamp expression is used to ensure that the variable value will always stay between 0 and 1, otherwise the width of the object would increase forever.

Animmaniac2012-01-31 19:51:19