Opposite tween to lerp

Get help using Construct 2

Post » Sat Mar 12, 2016 11:01 pm

Hi there,

I use lerp A LOT when I'm making stuff. Mostly in this form:
Every tick - set box.X to lerp(box.X, 50, 0.1) etc.

The only issue is, this eases into the final position. I'd like something eases out of the first position and hit's the final position a bit harder.

Is this possible in a similar way to Lerp? I know Cosp eases out of first and into second, but this isn't what I need (though super handy for other things).

Thanks!
B
10
S
4
G
5
Posts: 139
Reputation: 2,983

Post » Sun Mar 13, 2016 3:33 am

There have been other topics on this and there isn't such a function, but you can do it with a speed variable.

Global number speed=0

Every tick
--- add 1 to speed

Box X <50
--- box: set X to min(50, box.x+speed)

Box X > 50
--- box: set X to max(50, box.x-speed)
B
91
S
31
G
103
Posts: 5,234
Reputation: 67,754

Post » Sun Mar 13, 2016 5:50 am

Fantastic, thanks for that, I'll give that a go.

How exactly does the the min/max thing work?

The manual's a little vague on it. What exactly are those actions doing?
B
10
S
4
G
5
Posts: 139
Reputation: 2,983

Post » Sun Mar 13, 2016 8:06 am

They're kind of like clamp. Min will only keep the lowest value, and max will keep the highest. I used it here to stop the value from passing 50 from either direction.

Min(a,b)
If a<b then it will be a
If a>b then it will be b

Max(a,b)
If a<b then it will be b
If a>b then it will be a
B
91
S
31
G
103
Posts: 5,234
Reputation: 67,754

Post » Sun Mar 13, 2016 9:27 am

Ah cool, makes sense,

Thanks for your help!
B
10
S
4
G
5
Posts: 139
Reputation: 2,983


Return to How do I....?

Who is online

Users browsing this forum: Alvaro2 and 14 guests