Jump to content
  • Advertisement


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.

If you intended to correct an error in the post then please contact us.

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 this post

Link to post
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
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 this post

Link to post
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))
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

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!