1

In a networked game project following on from the Unity Multiplayer Tutorial, how is one supposed to go about changing scene to a new level/map while preserving camera/player GO/health etc. in one overarching master scene. (e.g. Gameplay.unity with Level1.unity or Level2.unity added to it)

All related help seems to be legacy code, singleplayer solutions or a more specialized circumstance. The current Unity 5.5 documentation suggests ServerChangeScene - which only seems to provide half the solution.

Does something like ServerAddScene and ServerGetScene exist?

Attempted solutions have been using DontDestroyOnLoad on known GameObjects in the master scene and keep a currentMapNumber variable synced between client NetworkManagers that gets updated when a player reaches the end-of-level trigger. This is then checked in the Update() method and either calls

networkManager.ServerChangeScene("Level" + networkManager.GetComponent<NetGame>().mapNumber);

or

SceneManager.LoadScene("Level" + networkManager.GetComponent<NetGame>().mapNumber, LoadSceneMode.Additive);

neither of which work as expected.

Rogod
  • 188
  • 1
  • 13
  • Hi rogod did you find any solution. i am also looking for additive scene loading in unity across netwrok – Muhammad Faizan Khan Jan 26 '17 at 12:39
  • Not yet - I'm aware there are lots of people with this problem, but no one seems to have an answer who's seen this thread yet. - My project is basically on hold until I have a good solution to this sadly. :( – Rogod Jan 27 '17 at 14:12

1 Answers1

0

I am able to do this through an additive scene loading i used this code.

[ClientRpc]
    public void RpcLoadLevelAcrossNetwork() {
        SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);   
    }

ClientRpc will load the new scene to all connected clients and additive scene loading will allow you to preserve camera/player GO/health etc

Muhammad Faizan Khan
  • 10,013
  • 18
  • 97
  • 186
  • While this works in a way, it only loads the objects in a scene that do not have a NetworkIdentity. In order to achieve the desire effect, it would seem one has to use ServerChangeScene with objects set to DoNotDestroyOnLoad. However, one must ensure only the server runs this method when it detects a map change request via a SyncVar (in something like a scene-manager script). In short, I have it working now, but it is not as simple as the document makes it out to be. – Rogod Jan 31 '17 at 13:37
  • @Rogod AH.., This is the problem i am facing from last couple of days. You said right, networkidentiy objects are not loading with my code. How do i correct it? http://stackoverflow.com/questions/41909305/spawn-scene-object-not-found-for-1 – Muhammad Faizan Khan Feb 01 '17 at 04:40
  • I had to resort to using ServerChangeScene instead of this as I couldn't find a way to get the objects with NetworkIdentity to load. I am currently just setting everything I want to keep as DoNotDestroyOnLoad and using ServerChangeScene. – Rogod Feb 02 '17 at 23:24
  • But serveChangeseve will complete replace the scene. I am searching for additive scene loading – Muhammad Faizan Khan Feb 06 '17 at 04:21
  • The only way I've been able to achieve this is by setting things to DoNotDestroyOnLoad and using ServerChangeScene. - Using the above method only allows non-networked objects to be loaded additively. – Rogod Feb 08 '17 at 17:13