Search Unity

Third Party [Mirror] Reloading a Scene does not spawn networked Objects

Discussion in 'Multiplayer' started by DasMaeh, Mar 22, 2021.

  1. DasMaeh

    DasMaeh

    Joined:
    Oct 18, 2017
    Posts:
    14
    Hey everyone,

    it's again me with another problem related to reloading the active scene. As we know, a newly loaded scene is removed from all networked objects. At the moment where the local machine becomes the server, it spawns all the networked objects and keeps them in sync with every client connecting to this server. But when I reload the active scene with
    NetworkManager.singleton.ServerChangeScene(SceneManager.GetActiveScene().name);
    ,
    the newly loaded scene is again purged from all networked objects, although I do already have a server!

    Why does my server not care about spawning in the objects?

    Thanks for any advice in advance.
     
  2. DasMaeh

    DasMaeh

    Joined:
    Oct 18, 2017
    Posts:
    14
    I finally found the cause of the issue. The problem I explained above was just at the end of a chain of issues.

    Our problem was that our NetworkManager Component was attached to an object that was not parented to the scene's root. For some reason, this leads to the issue that the NetworkManager does not execute the "DontDestroyOnLoad" command successfully. Therefore, by reloading the scene our NetworkManager gets destroyed and is replaced by a new one present in the new scene. Anyways... moving the NetworkManager up to the top in the hierarchy fixed all issues.
     
    trombonaut likes this.