Archived

This topic is now archived and is closed to further replies.

Decay / friction over time

This topic is 5177 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I know this is probably really simple, but I appear to have a mental block on it - I have a velocity that needs to decay over time due to friction. The nice simple way is to just multiply it by something like 0.98 every frame which produces exactly the right kind of behaviour. However this is obviously tied directly to the framerate. I''m using time-based movement so somehow I need to use my time delta between frames but I have no idea how to decay the velocity which will produce the same output. Ideas?

Share on other sites
This approach gives an exponential decay, but in reality, the decay of the velocity caused by friction is linear.

With the exp. approach, you have to give a number (say D), like 0.98, that describes, what decay you want to achieve in a second. Then you can use the following formula for any dt:

new velocity = old_velocity * D^dt, D should be less than 1
So in this case for accurate result you need a power() operation.

With the linear (real) version the friction is actually a force, say F, which stops the object
F = m * a
So
a = F/m

With euler integration: new_velocity=old velocity + a * dt, and a should be negative, and F too in this case.

I prefer the latter solution. It''s morerealistic, and cheaper.

Share on other sites
eish, can''t remember exact formula right now, and got to run ... but

X = scale per second
T = time

so X=0.9 for 1 second = R=0.9
so x=0.9 for t=2 : R=0.9*0.9 = 0.81

R= ln(x*exp(t))
or
R= ln(t*exp(x))

can''t recall which, must go calc it...

then just multiply by R for timestep T, insted of fixed R=0.98 for fixed timestep T=0.01 or whatever

1. 1
2. 2
3. 3
Rutin
22
4. 4
JoeJ
17
5. 5

• 14
• 30
• 13
• 11
• 11
• Forum Statistics

• Total Topics
631774
• Total Posts
3002297
×