Search code examples
network-programmingtcpudpminecraftmultiplayer

Should I use UDP or TCP for my Minecraft-style game?


I'm creating a 2D Minecraft style game, where the map is stored in a 2-dimensional int array.

You can place and destroy blocks and ai-controlled characters will walk around the map. The game's made using xna/c#. The problem is that I don't have much experience coding networked games.

Which protocol should I use? UDP, TCP? Or perhaps the Lindgren library? (which uses UDP + reliability)

Should I let the following things be done on the client, server or on both?

  1. ai/pathfinding
  2. collision detection

Also, is it good practice to send destroy and place-block messages to the server? I guess that when the client starts, it first needs to download the map. And then changes to the map will be made in parallel to the maps on the clients and the one on the server...

Finally, should I broadcast the positions of the characters only when they change (tends towards TCP) or should I continually send them (tends towards UDP)?


Solution

  • I feel as if the thread below has some nice information that will be useful to you. Like AmitApollo said, in a nutshell UDP is faster, but less reliable. If all your information you're sending across this network is absolutely vital then TCP might be the best implementation. You could always try both and see what kinds of performance/latency hits you have. In general, most fast paced/realtime games I've read up on have used UDP.

    Android game UDP / TCP?