#Replace scene for all connections

3 messages · Page 1 of 1 (latest)

surreal lodge
#

Version: 3.10.3

Hello,
I am wanting the server host to be able to switch the scene for all connections. I currently have a simple setup for my racing game - one course per scene so I do not need support for additive scenes or scene stacking. It looks like I am supposed to be using SceneManager.LoadGlobalScene() to do this. I was using NetworkManager.ServerChangeScene() previously with Mirror and I figured SceneManager.LoadGlobalScene() was comparable.

When I call this, the scene changes, however, the player objects are not carried over. Do I need to explicitly say which players to carry over to the new scene? Here is my code below.

 // Check to see if the server is already running
 NetworkManager networkManager = InstanceFinder.NetworkManager;
 if (networkManager && networkManager.IsServer)
   {
      SceneManager sceneManager = InstanceFinder.SceneManager;
      if (sceneManager)
          {
              SceneLoadData sld = new SceneLoadData(trackName)
              {
                  ReplaceScenes = ReplaceOption.All,
              };
                    
              // Load the new scene globally
              sceneManager.LoadGlobalScenes(sld);
          }
   }```
https://gyazo.com/f7d28fab8b59f6f5b6dd2c6c9a20aa48

P.S. Sorry if this has been answered before. Discord bugs out when I scroll down on search results in forum channels and removes them completely.
tardy coyote
surreal lodge
#

The "IsGlobal" flag on the NetworkObject actually did what I want without carrying over those objects manually. However, the client seems to lose control over that object when the new scene loads. Do I need to give ownership of that object back to the client manually when the scene loads?