Help with loading scenes in Multiplayer

Hi, I’m relatively new to multiplayer game development, only started working with Relay and Network for GameObjects a few months ago.

What I am trying to do:
Move between the main menu scene and the main game scene.

The problem:
I have a setup with a network manager in both the menu scene and main game scene. I assumed that when switching scenes I would be able to pass the info from one to the other but it seems as though that is not the case.

The network manager keeps itself alive between scenes and that leads to some issues. I’ve thought about using only the one NetworkManager script but they hold different player prefabs with different scripts.

My question:
Any solutions that are viable apart from just rewriting everything?

a) Can I join the code for PlayerInMenu and PlayerInGame into 1 script and toggle what code runs based on which scene I am in?
b) Can I switch the player prefab when I load scenes?
c) Can I switch NetworkManagers when I load scenes?

I’m not really sure on which solution is best or if there are others I haven’t considered, I wouldn’t mind someone else’s opinion on this as I have had trouble finding anything online.

Don’t do that! In fact, don’t put the NetworkManager in any scene that you ever load again!

NetworkManager is a singleton. If you do either of the above, you will duplicate it. Instead, put it in a “launch” scene that is the first scene in the build list and merely loads the main menu scene to be on the safe side.

Personally, I prefer to only load scenes additively - that’s right, I only have a single “single-loaded” scene in my project.

Not really. Instead I would use a single “player prefab” that will then spawn the actual player entities based on whatever logic you choose. Consider the Player prefab the “LocalPlayerManager”, it has no visual representation but tells the server which one to spawn.

Sorry for the late response! I didn’t get a notification from this ':smiley:

Ok I understand what you are saying, I think I will be able to implement that.

Thanks for your time helping me out!