algorithmunity-game-engineprotocolsmultiplayermmo

MMO Server functionality in Unity3D


I've created a multiplayer server for Unity that works like this:

With this basic system, I can create a multiplayer game with Unity easily (already did it). But what if there's more than a couple of thousand players online? Then, say that every player sends his position to the server about 10times/sec. And the server has to send those position to all players around, say 100m. So, the server would run a loop for all online players (2000) comparing his position with the all 1999 players and if it's less than a 100m, send the position to the player. Or, maybe better, save all the players updated position in one array and send it to the player. (Only one message every 10s to the player should be better than hundreds, right? Anyway, the loop has to go through 2000*1999 10 times per sec, that could be painful..

I want to use Unity3d as client, I don't want to hold any physics on the server because using the unity's physics engine is good/fast/easy to work with. And I think it could be enough, maybe do some anti-cheating checking on the server-side just to get rid of badplayers.

Now, the questions :)

Well, I think this is all! I hope this post can be useful for other indies!


Solution

  • I won't try to answer all your questions, sorry. It would be too long answer. Seems like you need to read a lot of stuff about game physics.

    Shortly, if you have large number of online players you need to start thinking about server cluster and scaling. There're two main approaches:

    1. Instances: you have multiple copies of your virtual world/map each handled by separate physical hardware with a hard limit of maximum number of players. Then you start reading about matchmaking.

    2. "Shared universe": split your world to sectors each handled by separated physical hardware. Much more challenging to implement. Can support seamless world.

    You can find tons of useful info on www.gamedev.net.