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
Posts: 50
Reputation: 367

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
64
S
25
G
4
Posts: 204
Reputation: 6,993

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
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

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
Posts: 50
Reputation: 367


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, GrogIsGood, plinkie, rayolf and 7 guests