[gameprogrammer] Fixed Rate Logic

Hi Everyone!

In my current project I'm about to start migrating my fixed rate logic code.

The system that's currently in place measures the time in miliseconds
between frames and then uses that number in all the physics calculations
(like gravity, momentum etc).  This leads to really sporadic results where
you can't duplicate skill jumps except by luck and also when you lag, things
go crazy!  For the most part though, it works fairly decently.

The system that I want to move to is instead to keep track of how many
miliseconds between frames and then when that number got above some
threshhold (like lets say 50 miliseconds?) then it will call the
LogicUpdate() function.

More specifically something like this (pseudocode):

TotalTime+=TimeSinceLastFrame;

while(TotalTime>50)
{
 UpdateLogic();
 TotalTime-=50;
}

I know people on this list have dealt with these things before so I was
wondering, are there any pitfalls I should know about?

One thing I am concerned about is I'm wondering if different things should
have different logic update rates?  For instance a bullet should maybe be
updated every 10 miliseconds while an enemy should be updated every 50?  Or
is this a needless worry and things should run fine if they are all updating
at the same rate?

Also I was wondering, what is a reasonable update rate?

Thanks a bunch, I'm a noob to this fixed rate logic stuff so any help is
much appreciated! (:

Alan

Other related posts: