Search Unity

Network.isMessageQueueRunning, but which Level to Load?

Discussion in 'Multiplayer' started by pojoih, Jun 9, 2014.

  1. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    226
    Hello Folks,

    we're developing a Multiplayer Space Game and I have a question regarding Joining the game and Level loading.
    After successfully connected to the server, the client has to choose his equipment and ship. After that, the map is loaded and the game starts. I want to prevent the other players from instantiation before everything is choosen and the map is loaded with Network.isMessageQueueRunning = false.
    Unfortunatly, we have multiple maps (as multiple Levels) in our game and the client do not know which to load. Since isMessageQueueRunning seems to pause RPC Calls AND OnSerializeNetworkView, is there any chance to tell the Client which level to load without executing all the buffered RPC Calls?

    Thanks in advance for answers!
    Regards,
    Daniel
     
  2. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    You won't get any data sent/received if your disabling the message queue.
    Either send it before or after.
     
  3. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    226
    Thats the problem, the message queue has to be disabled in OnConnectedToServer, because if not Unity runs all the buffered RPC Calls (instantiate Enemys and other players etc.) and I don't want that until the new level is loaded.

    EDIT: Man I'm so stupid... got it, just use the very first RPCCall to sync settings and then deactivate the queue. Has to be the summer sun soften my brain ;)
     
    Last edited: Jun 11, 2014
  4. MartinLyne

    MartinLyne

    Joined:
    Apr 25, 2013
    Posts:
    30
    I know this is old, but I'd love to know a bit more about how you solved this (I have same issue)

    I am calling "Load Level" RPC in OnPlayerConnected, but it arrives after all the Instantiate RPCs. Is there guide as to which will be sent first?

    Or do you mean the first thing you do (before any clients or instantiating) is to send the load level RPC? [Makes sense now I think of it, just very different to my load-on-demand structure so never occurred to me, will try it now and update answer for any future googlers)

    Edit: Well, that worked for me. Made "LoadLevel" the first RPC that happens (for me OnServerInitialised seemed like a good place to put it), with RPCMode.AllBuffered.

    Now I look again teh RPC page does clearly say they get called in the same order as they are sent, derp!
     
    Last edited: Apr 2, 2015
  5. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    226
    I solved it by doing all the instantiation and loading in another function and buffer exactly ONE RPC call/function with RPCMode.Allbuffered in which I send all relevant data needed for loading the level and deactivate the messagequeue..
     
    gfoot likes this.