XNA GameTime TotalGameTime slower than real time
- by robasaurus
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.