Networking Level Loading Issues

I am in the development stages of an online game. When a player starts, the player start at server browser where the player can make a new server or connect to other servers. I am trying to make it where when the player joins a server, he automatically loads the level the server is on. Each server has a “server manager” which is used to control what happens when players join and disconnect, and also controls when to change the level. How might I go about accomplishing my goal, which to have players that just connected to server, load into the same level that the server is on?

The simplest way would be to make the server’s LoadLevel call in a buffered RPC with RPCMode set to RPCMode.All so that the server and everyone that connects to the server henceforth will receive this RPC as the first in the buffer and so load the level before anything else.

It’s also advised to suspend receiving new messages until the level has finished loading to prevent receiving states for objects that don’t exist yet and possible crashes.

An alternate solution that may fit your situation better, considering your server will change levels, is to send the player the LoadLevel RPC in the OnPlayerConnected callback on the server. This will save you a little tumbling between network groups. Again the player should suspend receiving new messages and updates until the level has fully loaded.