# Linear damping

Get help using Construct 2

### » Wed May 25, 2016 9:58 am

Hey people, so I want to set an objects linear damping value to distance(object x,object y, mouse x, mouse y) and have the objects linear damping increase as it gets closer to the mouse but the opposite happens as linear damping relys on bigger numbers to slow the object, any way of reversing the distance output? any help is greatly appreciated
B
5
Posts: 18
Reputation: 229

### » Wed May 25, 2016 11:53 am

Please one of you awesome math experts help me
B
5
Posts: 18
Reputation: 229

### » Wed May 25, 2016 6:23 pm

Set to 1 - (1/range * distance)

If you want no damping at (range) 100 pixels. Its 1 - (1/100 * 100) = 0
at a distance of 50 it is 1 - (1/100 * 50) = 0.5
at zero distance it is 1 - (1/100 * 0) = 1

This is ofcours linear.
Most natural things are logaritmic. Or.
1 - ((1/range)^2 * (distance)^2) (i think)
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Thu May 26, 2016 8:06 am

99Instances2Go wrote:Set to 1 - (1/range * distance)

If you want no damping at (range) 100 pixels. Its 1 - (1/100 * 100) = 0
at a distance of 50 it is 1 - (1/100 * 50) = 0.5
at zero distance it is 1 - (1/100 * 0) = 1

This is ofcours linear.
Most natural things are logaritmic. Or.
1 - ((1/range)^2 * (distance)^2) (i think)

Hi thanks for your response but it doesnt seem to be working its either setting the linear damping to 0.99... 0r just 1, is this how I was meant to implement it?
B
5
Posts: 18
Reputation: 229

### » Thu May 26, 2016 12:50 pm

edit: i typed here a lot of bullshit, cuz i counted on the manual
Last edited by 99Instances2Go on Thu May 26, 2016 8:40 pm, edited 1 time in total.
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Thu May 26, 2016 5:42 pm

You can reverse the damping with
max(1000-distanceHereToThere, 0)

Basically any distance above 1000 won't be damped, and any within 1000 will.

With the above the damping increases linearly, but you can square it to make it increase in a more drastic way.
max(1000-distanceHereToThere, 0)^2
B
100
S
38
G
134
Posts: 5,556
Reputation: 85,325

### » Thu May 26, 2016 7:04 pm

Linear damping
The rate the object slows down over time while moving, from 0 (no slowdown at all) to 1 (maximum slowdown)

?

Max (1000 - 2000 , 0) = 0
Max (1000 - 500 , 0) = 500 ?

----

I see, manual is not correct.
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Thu May 26, 2016 8:40 pm

B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Fri May 27, 2016 8:19 am

Thank you guys for the great help, rojo your math worked a treat thanks guys
B
5
Posts: 18
Reputation: 229

Return to How do I....?

### Who is online

Users browsing this forum: No registered users and 6 guests