0 Favourites

# How do I lerp on effects parameters

• 6 posts
• Hi,

Every time I try to lerp an effect parameters, it just won't work. Not sure if this is possible.

What I'm trying to do having a water effect gradually appear using lerp. So I have something like:

Every tick - set layout effect parameter 4 to lerp(0,30,3*dt)

But nothing happens. I tried different parameters too, and they all work if I set it to a regular number, but not to lerp. Weirdly enough, it doesn't work even if I do something like

varWaterEffect

every 0.5 seconds - add 1 to varWaterEffect

every tick - set layout effect parameter 4 to varWaterEffect

Not sure if I'm doing something wrong, or it's a bug or it's just not supported. Thanks!

• To get this to work with as much controlability as possible i would use these third party plugins:

LiteTween

and

Tween to effect

• LittleStain Tween to effect sounds like exactly what I was searching for! Thanks!

• Lerp(0,30,3*dt) is not varying since none of the parameters are varying (it is equal to 90*dt if I am not wrong).

But I will say LittleStain method is better anyway.

• Hey andreyin.

If I'm not mistaken, dt is the amount of time (in seconds) that has passed since the last tick. So, if your game runs at 60 frames (ticks) per second, then dt will always be a value around 0.0166 (i.e. 1/60). It may fluctuate a little, if you get some lag between frames.

So every tick, lerp( 0 , 30 , 3 * dt ) evaluates to approximately ...

= lerp( 0 , 30 , 3 * 0.0166 )

= lerp( 0 , 30 , 0.0498 )

= 1.494

So if 1.494 looks like it could be the value you were getting, then that may be the issue.

To get gradual changes in a value, you can use two variables, a Target variable that stores the desired target value, and a Follower variable that continually computes a time-smoothed version of the Target's value. The Follower variable essentially just gradually approaches the value stored in the Target variable.

I actually just posted an explanation of this Target/Follower setup with a list of events in another topic.

The example I give there shows a linear follower setup, but I generally use multiplicative follower setups in my projects, since the follower can be set every tick with only one event.

(Some day ... some day I will get that 4th egg.)