views:

891

answers:

4

I'm thinking about making a networked game. I'm a little new to this, and have already run into a lot of issues trying to put together a good plan for dead reckoning and network latency, so I'd love to see some good literature on the topic. I'll describe the methods I've considered.

Originally, I just sent the player's input to the server, simulated there, and broadcast changes in the game state to all players. This made cheating difficult, but under high latency things were a little difficult to control, since you dont see the results of your own actions immediately.

This GamaSutra article has a solution that saves bandwidth and makes local input appear smooth by simulating on the client as well, but it seems to throw cheat-proofing out the window. Also, I'm not sure what to do when players start manipulating the environment, pushing rocks and the like. These previously neutral objects would temporarily become objects the client needs to send PDUs about, or perhaps multiple players do at once. Whose PDUs would win? When would the objects stop being doubly tracked by each player (to compare with the dead reckoned version)? Heaven forbid two players engage in a sumo match (e.g. start pushing each other).

This gamedev.net bit shows the gamasutra solution as inadequate, but describes a different method that doesn't really fix my collaborative boulder-pushing example. Most other things I've found are specific to shooters. I'd love to see something more geared toward games that play like SNES Zelda, but with a little more physics / momentum involved.

  • Note: I'm not asking about physics simulation here -- other libraries have that covered. Just strategies for making games smooth and reactive despite network latency.
+11  A: 

Check out how Valve does it in the Source Engine: http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking

If it's for a first person shooter you'll probably have to delve into some of the topics they mention such as: prediction, compensation, and interpolation.

CD Sanchez
A: 

Check out Networking education topics at the XNA Creator's Club website. It delves into topics such as network architecture (peer to peer or client/server), Network Prediction, and a few other things (in the context of XNA of course). This may help you find the answers you're looking for.

http://creators.xna.com/education/catalog/?contenttype=0&devarea=19&sort=1

Joel Martinez
+3  A: 

I find this network physics blog post by Glenn Fiedler, and even more so the response/discussion below it, awesome. It is quite lengthy, but worth-while.

In summary

Server cannot keep up with reiterating simulation whenever client input is received in a modern game physics simulation (i.e. vehicles or rigid body dynamics). Therefore the server orders all clients latency+jitter (time) ahead of server so that all incomming packets come in JIT before the server needs 'em.

He also gives an outline of how to handle the type of ownership you are asking for. The slides he showed on GDC are awesome!

Jonas Byström
I think this is a great recommendation. Certainly material that it takes a while to crunch through but very worth while.On the down side I think it's worth noting that that solution is not very cheat proof, in fact it was not a concern for the type of cooperative gameplay they were developing this for I believe.
Chris
He mentioned this, but it is really not any less cheat-proof (client/server) than traditional prediction, it just requires that the server performs result calculation and sanity checks - all clients are ahead of server.
Jonas Byström
A: 

You could try imposing latency to all your clients, depending on the average latency in the area. That way the client can try to work around the latency issues and it will feel similar for most players.

I'm of course not suggesting that you force a 500ms delay on everyone, but people with 50ms can be fine with 150 (extra 100ms added) in order for the gameplay to appear smoother.

In a nutshell; if you have 3 players:

  • John: 30ms
  • Paul: 150ms
  • Amy: 80ms

After calculations, instead of sending the data back to the clients all at the same time, you account for their latency and start sending to Paul and Amy before John, for example.

But this approach is not viable in extreme latency situations where dialup connections or wireless users could really mess it up for everybody. But it's an idea.

Andrioid
This can be exploited. A user could modify their client to wait a bit before volleying when you try to detect their latency. If you then sent them packets early, they'd get them before the other players.
Nick Retallack
Latency is the least of my problems if my users are modifying their own clients. However it wouldn't matter; if you say that you have 500ms and the server assumes you have a latency of 500ms and you respond within 50ms. Your response will get delayed according to the delay to synchronize all the clients. Of course, this depends on how the latency settings are implemented. If I was modifying my client, I'd focus on automating gameplay or other exploits.
Andrioid