Multiple world instances

Hello,

I am working on a multiplayer world with a main server that all players connect to when they want to enter the world.

However when a max number of players have joined this world I would like to create another instance of the world for new players to go to in order to maximize performance and minimize latency.

Since I am new to Unity, do you have any recommendations on ways to do that?

Thank you.

you can try and minimize the traffic between the players and the server, to maximize the number of possible connections…

or you can create a similar server, then have the 2 servers communicate the positions/whatever of the players they own with eachother, tho i do not know how to do that myself :smile:

Thanks for replying.

Your first point is something that I am going to do in any case, however I have to limit the maximum number of players per instance. I want the users to login to the game and be automatically transferred to a low-traffic instance instead of listing all available instances and let the player choose from that ( like having multiple hosts in Counter-Strike for example ).

Oh and the players do not have to communicate with each other if they are in different instances…

I realize that this is a complicated thing to do so I am just discussing possible solutions…

all you need to do is see which of your servers have the least amount of players connected to it, you can do that using this thingy over here: Unity - Scripting API: HostData.connectedPlayers

  • look into ConnectGuiMasterServer.js script from the Unity Networking Tutorial.

So when you start the game from your main host, you create a bunch of servers, you then register them with the Master Server and when a player connects to your game you look through the hosts list and pick one to connect the player to?

yes, you can do that, using some similar code to this one [i did not test this, and it’s in C#]

//we get host data from the master server and place it into data
HostData[] data = MasterServer.PollHostList();
	HostData bestChoice = data[0];	//assuming we have at least 1 host
	//we go trough all the hosts we recieved, and memorize the one with the lowest number of connected players
	for(int i = 1; i < data.Length; i++){
		if(bestChoice.connectedPlayers > data.connectedPlayers){
			bestChoice = element;
		}
	}
//we connect to the host we found...
Network.Connect(bestChoice);

I commented the code a bit, I hope you will understand it.

Awesome, I’ll give that a go!

Thanks man!

I hope you will manage to get it right, cheers!