XNA GameTime TotalGameTime slower than real time
Posted
by
robasaurus
on Game Development
See other posts from Game Development
or by robasaurus
Published on 2012-10-08T13:20:36Z
Indexed on
2012/10/08
15:54 UTC
Read the original article
Hit count: 246
XNA
|time-management
I have set-up an empty test project consisting of a System.Diagnostics.Stopwatch and this in the draw method:
spriteBatch.DrawString(font, gameTime.TotalGameTime.TotalSeconds.ToString(),
new Vector2(100, 100), Color.White);
spriteBatch.DrawString(font, stopwatch.Elapsed.TotalSeconds.ToString(), new
Vector2(100, 200), Color.White);
The GameTime.TotalGameTime displayed is slower than the stop watch (by about 5 seconds per minute) even though GameTime.IsRunningSlowly is always false, why is this?
The reason this is an issue is because I have a server which uses stopwatch and it is faster than my client game. For instance my client notifies the server it has dropped a mine which explodes in one minute. Because the stopwatch is faster the server state explodes the mine before the client and they are out of sync. I don't want to have to notify the client when the server explodes it as this would use unnecessary bandwidth.
© Game Development or respective owner