How do I reverse lerp?

Get help using Construct 2

Post » Fri Feb 13, 2015 1:32 pm

I have this action

Code: Select all
Sprite > set angle > lerp(Sprite.Angle, 0, 0.05 * dt * 60)

which basically decelerate angle of the sprite towards 0. How to make it work the other way, so the sprite angle would slowly accelerate?
ImageImage
B
26
S
6
G
8
Posts: 774
Reputation: 6,685

Post » Fri Feb 13, 2015 1:40 pm

Just invert Sprite.Angle and 0 ?

Should work but I think this question was too easy. I must have missed something. :mrgreen:
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Fri Feb 13, 2015 1:42 pm

Try unlerp.

Sprite > set angle > unlerp(Sprite.Angle, 0, 0.05 * dt * 60)
B
44
S
5
G
5
Posts: 412
Reputation: 5,771

Post » Fri Feb 13, 2015 2:12 pm

nemo wrote:Sprite > set angle > unlerp(Sprite.Angle, 0, 0.05 * dt * 60)


That doesn't work. In the example the brick falls to the angle 90. When I use unlerp it does nothing. How can I accelerate it to the angle 90?
You do not have the required permissions to view the files attached to this post.
ImageImage
B
26
S
6
G
8
Posts: 774
Reputation: 6,685

Post » Fri Feb 13, 2015 2:40 pm

You shouldn't use lerp with angles, because it isn't aware of cycles. See anglelerp. I don't think lerping is the correct way to do this anyway, since you basically want the rotate behavior with an acceleration, which doesn't involve any lerping.

FYI see also Using lerp with delta-time.
Scirra Founder
B
395
S
232
G
88
Posts: 24,368
Reputation: 193,756


Return to How do I....?

Who is online

Users browsing this forum: namaewayukidesu and 8 guests