Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

With Scene NetworkViews, do the clients have to load the level before the server?

Discussion in 'Multiplayer' started by mriegger, Nov 19, 2014.

  1. mriegger

    mriegger

    Joined:
    Mar 28, 2009
    Posts:
    7
    I have a game with a few hundred Scene NetworkViews located on buildings throughout the level.

    When the server finishes loading the level first, the client will receive lots of "View ID SceneID: XXX Level Prefix: 0 not found during lookup. Strange behaviour may occur" errors.

    If the client loads the level before the server, everything is fine.

    I am calling Network.SetSendingEnabled(0, false) and Network.isMessageQueueRunning = false before loading the level as per Unity's sample code. (on both client and server) This doesn't appear to help.

    Is the correct solution to this problem to make sure the Clients call Application.LoadLevel() before the Server?
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    This warning is logged when you receive updates for NetworkViews which are not known to a client (yet).
    When the clients load the level first, then they know all those NetworkViews and any RPC or update can be applied. That's why that works.
    Like in the example, you need to make sure that you pause the message queue when you a client gets the task to load a level (via RPC). Any next message after the RPC "load level X" will apply to a NetworkView that has to be loaded first.

    So in the "level change" RPC, pause the message queue, load the level and then activate the queue again.
    In the sample you also see that one NetworkView gets marked as DontDestroyOnLoad. This way, you can continue to use the NetworkView to send RPCs.
     
    MikeR_UFG likes this.
  3. MikeR_UFG

    MikeR_UFG

    Joined:
    Dec 1, 2014
    Posts:
    12
    Thank you so much for your help Tobiass. After much refactoring our game can now proceed smoothly with the client and the server both shutting down and re-enabling their message queues at the appropriate times.