XNA Essentials

Game Programming for Xbox 360, PC + Windows Phone

NAVIGATION - SEARCH

Chapter 29 - Prediction and Smoothing - packetSendTime

Hello Chad,


I'm currently reading chapter 29 and have a question to the method ApplyPrediction. timeDelta is being calculated as the difference between localTime and packetSendTime which both are only accurate to the second. (gameTime.TotalGameTime.TotalSeconds)


Thus I guess that timeDelta is likely to have the same value all along. The latency of normal traffic is at 50 to 100ms so I think timeDelta can only be different in very rare cases. That doesn't make much sense to me.


Wouldn't it be better to use TotalMilliseconds in that case?


Thanks


-Martin

MartinM - Sunday, August 9, 2009 @ 5:39 PM

Re: Chapter 29 - Prediction and Smoothing - packetSendTime

Hello Martin and welcome!


The TotalSeconds property "Gets the value of the current System.TimeSpan structure expressed in whole and fractional seconds."


Here is a link for your convenience.


http://msdn.microsoft.com/en-us/library/system.timespan.totalseconds.aspx


You can see the only difference between TotalSeconds and TotalMilliseconds is the decimal place. Hopefully this helps clear it up, but if not let me know!


Thanks,


Chad

Chad Carter - Monday, August 10, 2009 @ 9:08 AM

Re: Chapter 29 - Prediction and Smoothing - packetSendTime

Thanks Chad! Smile


Stupid me, I had "Seconds" in my actual code instead of "TotalSeconds" and therefore no decimal places...

MartinM - Monday, August 10, 2009 @ 10:36 AM

Re: Chapter 29 - Prediction and Smoothing - packetSendTime

No problem! Yep, having Seconds in there would do it - Glad you got it figured out!

Chad Carter - Monday, August 10, 2009 @ 10:41 AM