Jump to content

PhysicsElapsed & Monitor Refresh rate


Zampano
 Share

Recommended Posts

Hey guys,

I had related topics before, but let me give a short summary: I am working on a time-based game, roughly similar to guitar hero. For that, I use deltaTime and PhysicsElapsed like this:

update: function() {
  deltaTime = (this.time.elapsedMS)/(1000/60)	
  this.time.physicsElapsed = this.time.elapsedMS*0.001;
}

So if the framerate drops to 30, deltaTime = 2 and physicsElapsed will also be double the value it is normally (1/60 as in 1/desiredFPS). 
It always seemed to work perfectly fine. Sure, it leads to a loss of accuracy whith lower framerates or bigger lags, but that's another story. I've tested it with 30fps (forced with a screen capture tool) and it was running at the same speed as it would with 60, so everything is alright.

Just yesterday, I found out that when played on a 144hz monitor, the game runs in slow motion. I've checked all the vars above, and I could not find a problem. The game runs at 144 fps, deltaTime is around 0.42 as it should be and physicsElapsed naturally also has the value I expected (0.006999999999999999 for example). But all the motions are at half speed. Or more like 0.42x speed. The spawns, which are also tied to the game time are correct, so no problems there, but everything just moves too slow. The big mistery is: if somebody has a 30hz display, will it run at double speed which wouldn't be playable at all?

I just can't think of a reason why this would happen as everything works fine with software caused differences in fps and especially since all the values seem to be in check. Maybe I am overlooking something? Maybe the hardware has some other effect that takes place outside of my code logic? I read that there are issues with other refresh rates, but I was under the impression my code would take care of that.

Please help D:

Link to comment
Share on other sites

Oh. It actually works. But I don't exactly get why it does... and moreso, why is it even there in the first place then and not "set to infinite"? 
And I guess this also means that 30hz monitors wouldn't have that problem, doesn't it?

Link to comment
Share on other sites

I see. But the monitor's refresh rate seems to put a cap on it, I don't have 144 logic updates on my 60hz monitor as far as I can tell. So can I just globally leave it at 144  or would it be better for performance to put a system in place that checks the max fps and adjusts desiredFps accordingly in common refresh rate steps?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...