How do I ease parameter value?

Get help using Construct 2

Post » Thu Mar 30, 2017 2:01 pm

I have an object that looks at my cursor direction in Mouse.X and Mouse.Y position. But currently it's way too fast, so I want to ease it a bit. Any idea how do I apply an "easing" effect to the MouseX and MouseY value?
Note: as this object is interacting within a plugin I cannot apply an easing behavior to the object, I need to ease the parameter.
B
28
S
8
G
1
Posts: 19
Reputation: 2,245

Post » Thu Mar 30, 2017 4:27 pm

Try lerping. lerp(a, b, x) Linear interpolation of a to b by x. Calculates a + x * (b - a).

So a is your starting point, b is your target, and x is the amount between the two values (0-1 scale)

For your case, object.angle is a, angle(object.x,object.y,mouse.x,mouse.y) is b, and you can choose anything between 0 and 1 which determines how much you want to move towards the target every tick.

Note that this will never actually reach your target value unless you round() the value. And even then only when your c value is more than 0.5.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458


Return to How do I....?

Who is online

Users browsing this forum: blue visionary and 5 guests