Need Clarification how LoadScene affects NetworkManager

There is a MainMenu. When you press a button “New Game”, a script will invoke

NetworkManager.Singleton.StartHost();
[...]
SceneManager.LoadScene("CampaignScene");

The host is started successfully.

In the CampaignScene, there is a CampaignManager-Object which is In-Scene placed. The CampaignManager has a component NetworkObject and a script of type NetworkBehaviour assigned to it. However, after the Scene is loaded, the CampaignManager is not spawned. The Start()-method is called, and Debug.Log(IsHost) shows that the host is NOT started. But the inspector clearly shows that the host is started and i could call

void Start() {
    GetComponent<NetworkObject>().Spawn();
}

which would work on the host-side, but later on turns into problems with the client side…

I am lost here. Why is the CampaignManager not spawned? And why does it say IsHost == false??
Is this a bug or does it work as designed?

It sounds like you need to be calling the NetworkManager’s scene manager, try:

NetworkManager.Singleton.SceneManager.LoadScene("CampaignScene", LoadSceneMode.Single);
2 Likes

Thank you very much for your quick reply. That did the job. :slight_smile:

I have read the whole multiplayer-documentation but somehow missed the part about the SceneManagement :frowning:

2 Likes