How do I scale an object smoothly with lerp?

Get help using Construct 2

Post » Fri Feb 19, 2016 2:08 pm

Hey there,

i've been trying to make an object appear (spawned from another object) and then do some work on it. It has to "drop from the sky" onto the background. I want to create this effect by using fade in & a set scale function. This is what i have:

onClick (on a button) => road2 => set scale to lerp(0.1608, 0.0804, 2*dt) .

Any ideas why it doesn't do anything? Right before this action i do a change angle and fade, and they both work.
B
6
S
1
Posts: 50
Reputation: 517

Post » Fri Feb 19, 2016 10:00 pm

I'd say it's because the onClick event only triggers once - so it starts scaling the object but never gets past the first tick. You probably need a variable set up and when that variable is true run those scaling events and it should work.
B
69
S
25
G
4
Posts: 214
Reputation: 7,143

Post » Fri Feb 19, 2016 10:37 pm

That's part of the answer. The other issue is even if you used that expression every tick it would be the same. You need a variable that you change over time and use that for the lerp. This could work:

global number go=0
global number t=0

on click
--- set go to 1

go = 1
t < 1
--- add dt to t
--- road2: set scale to lerp(0.1608, 0.0804, t)
B
100
S
38
G
134
Posts: 5,551
Reputation: 85,315

Post » Tue Feb 23, 2016 7:49 am

R0J0hound wrote:That's part of the answer. The other issue is even if you used that expression every tick it would be the same. You need a variable that you change over time and use that for the lerp. This could work:

global number go=0
global number t=0

on click
--- set go to 1

go = 1
t < 1
--- add dt to t
--- road2: set scale to lerp(0.1608, 0.0804, t)


Great, thanks for the answer, when i get to it i'll give it a try ;)
B
6
S
1
Posts: 50
Reputation: 517


Return to How do I....?

Who is online

Users browsing this forum: plinkie, PurifiedWater and 2 guests