Jump to content
  • Advertisement

Archived

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

BSXrider

Frame-rate independent acceleration

This topic is 6105 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 want some sort of exponential decay. At the moment I''m using vx = vx * .999; but this is unreliable as frame rate changes. What do you suggest? - seb

Share this post


Link to post
Share on other sites
Advertisement
each frame before the anything is done grab the framerate. Then when you do the movement divide all your per second stuff by the framerate. That should produce an accurate effect.

Share this post


Link to post
Share on other sites
Yep, that''s how I do all of my other movement. Though I grab the milliseconds since last update and multiply speeds by this. But it''s all the same thing.

But that won''t work in this case.

- seb

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by BSXrider
But that won''t work in this case.



It won''t?

Share this post


Link to post
Share on other sites
No. Look at the line of code I showed and explain how a similar effect can be done using framerate/time information.

- seb

Share this post


Link to post
Share on other sites
It will work, but you''re not using it properly.

Say you''ve got a velocity "v" in meters per second.

Say you''ve got a constant acceleration "a", in meters per second per second.

Every second:

v += a;

Therefore, every frame:

v += (a * frame_time);

If you think about what you''re doing (multiplying by .99 or whatever) you should see that the object will never come to a stop. This isn''t natural.

Instead, see if the object is moving, and if it''s not, apply a deceleration.

- Pete

Share this post


Link to post
Share on other sites
Hi,

read this:

http://www.gamedev.net/community/forums/topic.asp?topic_id=75233


i think this could solve your problem ...

Share this post


Link to post
Share on other sites
quote:
Original post by siaspete
If you think about what you''re doing (multiplying by .99 or whatever) you should see that the object will never come to a stop. This isn''t natural.



Nevertheless this is the behaviour I want. It will come to a stop because of rounding errors, and it''ll do so in a nice ease-out fashion.

- seb

Share this post


Link to post
Share on other sites
That''s possibly not the best approach. Fair enough it''s your software, but it''s best to code specific algorithms than to rely on what''s essentially a fault in the FPU.

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!