How do I lerp on effects parameters

Get help using Construct 2

Post » Tue Oct 28, 2014 11:47 am

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!
B
125
S
43
G
41
Posts: 849
Reputation: 28,260

Post » Tue Oct 28, 2014 12:15 pm

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

LiteTween

and

Tween to effect
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Oct 28, 2014 12:20 pm

@LittleStain Tween to effect sounds like exactly what I was searching for! Thanks!
B
125
S
43
G
41
Posts: 849
Reputation: 28,260

Post » Tue Oct 28, 2014 12:28 pm

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.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
54
S
22
G
18
Posts: 2,123
Reputation: 17,150

Post » Tue Oct 28, 2014 1:11 pm

Hey andreyin. :D

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.
viewtopic.php?f=147&t=118251&p=849372#p849372

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.)
B
28
S
18
G
8
Posts: 333
Reputation: 6,193

Post » Tue Oct 28, 2014 1:18 pm

Thanks @fisholith and @Aphrodite!

What bugs me is that even when I try to manually set the effect to a variable and change that variable, it still doesn't work.. it seems to work only once. I'll try with LiteTween later.
B
125
S
43
G
41
Posts: 849
Reputation: 28,260


Return to How do I....?

Who is online

Users browsing this forum: WesleyDeveloper9, Yahoo [Bot] and 5 guests