How to fix this timestep once and for all?

Started by
12 comments, last by Kylotan 6 years, 7 months ago

Wow, didn't realize I had more responses to the thread...

Anyway, I'm fixed it "forrealzees" this time.  Using the roxlu portable nanosecond timer in place of my millisecond one, then converting the numerator from 1000 milliseconds to the appropriate number (1000*1000*1000), it appears to work fine this time.  Even without Vsync, ran nicely at 120+fps. 

It was a combination of a low resolution timer plus my own spawning code was causing some entities to spawn yet rapidly disappear!  Since it happens in the blink of an eye, it was a rather hard bug to catch until today.  So far, no more spawning issues!

Now to try it on my desktop Mac and PC, as well as mobile devices.

On 8/13/2017 at 2:52 PM, Hodgman said:

;(

Try it in a PC with a 144Hz monitor now..

If only I had one.  All of my monitors are 60hz only :/

Shogun.

Advertisement

Why not use a high-precision timer?

You can look at mine (Timer.h, Timer.cpp) for example :) .

I always used this kind of timer when coding a game and it always gave me great result in the past.

Honestly, what's the point of fixed timestep except in some circumstance, and hard coded frames per seconds limits if you

can just use vsync to do the job for you? Just my 2 cents here...

3 hours ago, Vortez said:

Honestly, what's the point of fixed timestep except in some circumstance, and hard coded frames per seconds limits if you

can just use vsync to do the job for you?

Vsync doesn't guarantee you a fixed frame duration - it guarantees you one of several frame durations that is a multiple of the hypothetical minimum, and that minimum can vary from one machine to another. That is a problem if you want consistent physics for all players.

This topic is closed to new replies.

Advertisement