Opposite tween to lerp

Get help using Construct 2

» 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

» 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

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
100
S
38
G
134
Posts: 5,555
Reputation: 85,323

» 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

» 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
100
S
38
G
134
Posts: 5,555
Reputation: 85,323

» Sun Mar 13, 2016 9:27 am

Ah cool, makes sense,

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

Who is online

Users browsing this forum: fbarraza28, Google [Bot], Jayextee, RogerBarber, zenox98 and 7 guests