Networking gameplay

Blitz3D Forums/Blitz3D Programming/Networking gameplay

Ross C(Posted 2004) [#1]
Hey, i'm doing my netstuff, and i'm going to send messages with a timestamp, so when the other computer receives it, it can adjust for lag. But, i'm a bit stuck though. I'm not sure how i go about telling the other computer what time mine is at.

If i send across a packet containing my millisecs value, the time it gets there, it will be slightly behind my actual time. I was also thinking about working out the average lag, but i can't tell if the results i get, will stay like that through-out the game. Any ideas?


ckob(Posted 2004) [#2]
why not use splines?


Matty(Posted 2004) [#3]
Perhaps base it on the "frame" the game is upto rather than the actual time the game has been running for.


Damien Sturdy(Posted 2004) [#4]
Dont use millisecs as this only returns the time windows has been running...


martonic(Posted 2004) [#5]
Send a time-stamped packet back and forth and note the transit time. Do this three times and use the average as your estimated lag. Recheck every 2 to 10 minutes and update your estimate, because conditions on the Internet can and do change. Good luck!


Zenith(Posted 2004) [#6]
Let the server send the timestamp, the server will always be in sync, because then everyone gets the same "time zone"


Ross C(Posted 2004) [#7]
The server will be one of the computers that are playing the game. Only two players involved here. I can't really use the frames, because the other person playing might have a crappy computer that doesn't keep up with the frame rate. And i'm pretty sure that i'll need to use millisecs() to time things :o)

I think averaging sounds like the best idea just now. Also, i was wondering. Do i send the players button presses to the server and he positions everything, then sends this positional data back to the client? Or do i just move and transmit the clients positional data to the server?


jfk EO-11110(Posted 2004) [#8]
I suggest use the severs millisecs as a reference time. So the server sends his millisecs, then the client will know the diffrence and can add this to the value it sends to the server frequently. And yes, add the average transmission time etc.

I would move the player locally, send some information about the player, it's up to you to decide if you want to use dead reckoning systems and spline interpolation etc, or if you simply send the coordinates, interpolate the movement of the connected player(s) between the current and the previous coordinate. In the second case you'd have to live with a lag of maybe 100ms. Not a big deal IMHO unless you play "Bruce Lee vs Lucky Luke".


Ross C(Posted 2004) [#9]
Thanks for that jfk :o)