Multiple scenes

Hi,

In both Lobby Manager asset and NetworkManager is assumed to have a single scene as game scene, called “Online scene” but in my game, like a lot of games, there are lots of levels/scenes, what should I do?

I was thinking of extending LobbyManager/NetworkManager to accept multiple scenes but don’t know how.

Thanks.

I don’t think it’s possible using the same architecture, HLAPI by default doesn’t support multiple scenes far as I understood from various comments around the forums.
Maybe it’s possible if you rebuild the whole system using low level api, but it’s gonna need lots of work.

You can Async Load Scenes into your game scene. So for example have “Online Scene” then have all of your different scenes for your Maps. They start a game with a specific map and “Online Scene” will Async load the correct “Map” into the scene.

You can change network game scenes at run time with this command:-

    void ChangeScene()
    {
        NetworkManager.singleton.ServerChangeScene("Scene name");
    }

http://docs.unity3d.com/ScriptReference/Networking.NetworkManager.ServerChangeScene.html

2 Likes

So you suggest/imply to have my “onlineScene” as an empty/temporary scene in which I load my “real” map?

Why do you need an empty scene? Just set the initial scene in the NetworkManager and that’s what the host or first client (if using a dedicated server) will connect to.

Subsequent scenes can be loaded via a menu system and the above command. The network system will make sure that the other clients change scene if already connected, or load the current scene when they connect.

If by temporary scene, you mean some kind of lobby from which you launch games once all clients are connected, then maybe you should take a look at the NetworkLobbyManager instead, however you could still roll your own with the above approach.

Temporary scene for calling “ServerChangeScene”. If I don’t need one, where should I call this function? (extending NetworkLobbyManager perhaps?)

Also please note that I’m using NetworkLobbyManager.

Where do you suggest I call this command from?

You’re misunderstanding what “Online Scene” is - it’s not restricting you to just one. It’s just doing some of the lifting for you, and when the connection state changes from one of the enum types that means disconnected, to a connected state, the manager is going to automatically change to the scene for online.

You are free from there, to do whatever you want to do, including loading other scenes if you’d like. In fact, you don’t even need to use that box for online scene and offline scene, you can handle it through your back end code and tie an even to the network managers connected state.

How? Would you or someone else please elaborate on how to do this in code? I believe it’s in lines of extending NetworkManager.

Okay, I think this can help. If there’s a better way, I’d love to know it. But after a long time searching, this is the only example of it in use I found.

NetworkStarter. You’ll find that you can switch scenes while on the network, and other players jump scenes with you. (Players sync, crates don’t, I don’t know what that’s about.)
The code he gave you is used here in SceneControl.cs. It’s attached to the player prefab.
Experiment, you can make more buttons that will refer to your scenes.
Tell me if that makes sense.
Good luck.

Can you load scenes, pulling yourself into the new scene and still have the other players in the previous scene? (able to join you when they load that new scene themselves)

2 Likes

It can be done with Photon PUN with a bit of work, because that’s what we have done for our multiplayer RPG in development, but I’m not sure about UNET, although from what experience I’ve had of it I can’t see any reason why not.

In either case, you’ll need to manually handle visibility of players depending on which map they are on.