Search Unity

level selection for network loading use M2H tutorial code.

Discussion in 'Multiplayer' started by cerebrate, Mar 9, 2010.

  1. cerebrate

    cerebrate

    Joined:
    Jan 8, 2010
    Posts:
    261
    Rather, I'm stuck on this. I was attempting to add a way to select which level is loaded before you start hosting a server, but I'm rather lost on how it even knows to which level to load in the first place. I can follow it this far:

    Code (csharp):
    1. if (GUILayout.Button ("Start hosting a server")){
    2.             multiplayerScript.StartHost(hostPlayers, hostPort);
    3.         }
    goes to:

    Code (csharp):
    1. function StartHost(players : int, port : int){
    2.     if(players<=1){
    3.         players=1;
    4.     }
    5.     //Network.InitializeSecurity();
    6.     Network.InitializeServer(players, port);
    7. }
    which possibly goes to here? :
    Code (csharp):
    1. function OnConnectedToServer(){
    2.     //Stop communication until in the game
    3.     Network.isMessageQueueRunning = false;
    4.  
    5.     //Save these details so we can use it in the next scene
    6.     PlayerPrefs.SetString("connectIP", Network.connections[0].ipAddress);
    7.     PlayerPrefs.SetInt("connectPort", Network.connections[0].port);
    8. }
    After this, I'm rather confused. I can't seem to find any loadlevel or anything. Does InitializeServer just load the next map in order or what? Because as I saw, it seemed you actually had to stop receiving rpc's, and then load the level yourself (on client and server), but M2h doesn't seem to do that.

    Anyone have any clue of what's going on, and if so, how I could possibly make it choose which level I AM loading?