Game Development Community

Virtual time in unusual circumstances

by Joel Baxter · in Torque Game Engine · 05/14/2002 (5:52 pm) · 3 replies

I was experimenting with $timeScale recently to do slo-mo, and noticed that the game clock continued to run at the same rate. Well, the game clock uses getVirtualMilliseconds, so one would think that it would correctly track any monkeying with the game's timescale, but nope.

If you look in main.cc, you can see where the "virtual time" is incremented using Platform::advanceTime; it looks like this:
U32 timeDelta;

   if(gTimeAdvance)
      timeDelta = gTimeAdvance;
   else
      timeDelta = elapsedTime * gTimeScale;

   Platform::advanceTime(elapsedTime);
And then timeDelta is used to advance the physics simulation and trigger scheduled events. So the timescale does affect those processes, but it doesn't affect the virtual time. I tried fiddling with that so that the virtual time is also affected by the timescale, and that fixes the clock behavior, and the game seems to work fine, but I'm a little nervous about that. I do see a lot of uses of getVirtualMilliseconds throughout the code that make sense in that they should be dealing in "simulated time" (for example, the progression of changing light color in sceneObject.cc) but also a lot of other uses that seem to be expecting "real time" (for example the calculation of ping time in netConnection.cc). Although, granted, most or all of those latter uses are in the net code, where it probably doesn't matter for any practical situation where you would be changing the timescale...

The other monkey wrench in the works is $timeAdvance, or gTimeAdvance. Looks like this is supposed to roll the simulation forward by a fixed time period, but again, it doesn't affect the virtual time.

I'm inclined to think that a) it's an oversight that timescale and timeadvance don't affect the virtual time, and b) that there are uses of getVirtualMilliseconds in the code that should be getRealMilliseonds instead. But I ain't sure. Thoughts?

#1
05/27/2002 (4:41 pm)
*bump*
#2
06/08/2002 (10:57 am)
One more thread bump... still haven't been able to get into investigating this yet, so I'll continue to troll for other people's input. :-)

BTW, as to why I would care: it'll be cool to be able to reliably FFWD and slo-mo playback of game recordings, of course, but I'll especially need rock-solid virtual time manipulation when it comes time to implement a "match pause" functionality.
#3
08/21/2006 (2:33 pm)
Joel,

Sorry to resurrect an old post, but I have been trying to use timescale, and was wondering if you ever resolved your questions. I am setting time scale to different values to try to control how quickly a 3D simulation dispays, and when time scale is set to small numbers (Like .1, or so,) the display seems correct in terms of how things move, but things get jerky. Even moving the mouse from left to right redraws in jerks, instead of smoothly. I was wondering if your observation about getRealMilliseconds vs getVirtualMilliseconds might effect this. All I am doing is changing gTimeScale, and like I said the timing seems ok, but some things are changed that don't seem like they should be.

Thanks for any advice,

-Steve Lamperti