Search Unity

Proper way to change scene in a syncronized way ?

Discussion in 'Multiplayer' started by Vinny-the-true, Mar 16, 2018.

  1. Vinny-the-true

    Vinny-the-true

    Joined:
    Nov 28, 2016
    Posts:
    10
    Hi,
    What is the state of the art proper way to change the scene in a synchronized way in a multiplayer unity game ?
    I am currently using homemade semaphore-like logic using the SyncVar mecanism to syncronize some fadig between scenes, associated with NetworkManager.singleton.ServerChangeScene to actually change the scene.
    But by doing this, I have some issues :

    * any object marked as DontDestroyOnLoad and spawned with client authority has to be spawned again for each scene

    * (my bad, this was something completely unrelated) once I changed one object with client authority from instantiation in each scene to marked as DontDestroyOnLoad and respawned like described earlier, my semaphore mecanism seems broken (the client no longer receives the SyncVar value from the server). And I can't figure out how these could possibily be related...

    * When stoping the multiplayer on the server, then starting a new game, when a client arrives it is automatically sent to the last scene I set in ServerChangeScene, how could I reset this so the new clients won't load any scene at all ? My ideal behaviour is to not load any particular scene when connecting as everybody already is in the right scene when connection occurs (works well the first time)

    So, what is the actual right way to perform a scene change when playing network ? I can't figure out to find a solution to this...
     
    Last edited: Mar 19, 2018
  2. Vinny-the-true

    Vinny-the-true

    Joined:
    Nov 28, 2016
    Posts:
    10
    Nobody with any help for me about how we're supposed to change scene during online multiplayer game the right way ? :(
     
    Last edited: Mar 19, 2018
  3. Vinny-the-true

    Vinny-the-true

    Joined:
    Nov 28, 2016
    Posts:
    10
    Still no one to point me in the right direction here ? I'm sorry if that question has already been answered, but I really can't find anything :(
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Clients are changing scenes when they connect because you set a scene with ServerChangeScene, which is the entire point of that setting. Either use it again to set the scene you expect clients to connect with, or don't use the feature.

    Not sure about your dontdestroyonload issue, but I'd check if they are actually set to that on the clients before you change scenes. Since the order you mentioned is spawned after calling dontdestroyonload I'd guess that they are only set that way on the server.