Managing scenes server + client

So I have 2 different scenes for my project the Server and the Client. Right now the clients just sit in the main-menu scene however when if I Network.instantiate something on the server none of the clients see the object i’m assuming its because they aren’t in the server scene.

Would someone be able to educate me on how I can correctly have the server and the clients in the same scene i’m sorry if this has been asked before I did my best to find a similar question but it didn’t seem to match up to what I was asking.

basically you need the client to connect to the server
Network.Connect(serverip, port);

Server can use the OnPlayerConnected() event to send a RPC to the client with the level he has to load

The Client stops the Network.isMessageQueueRunning = false loads the received LevelId and turns the MessageQueue back on.

GameObjects with NetworkViews should now be sync on Client and Server.

complete network tutorial:
http://unity3d.com/learn/tutorials/modules/intermediate/live-training-archive/merry-fragmas-multiplayer-fps
http://unity3d.com/learn/tutorials/modules/intermediate/live-training-archive/merry-fragmas-multiplayer-fps-2
http://unity3d.com/learn/tutorials/modules/intermediate/live-training-archive/merry-fragmas-multiplayer-fps-3

Hi tobad! thank you for your response. However I seem to have run into an issue the client is loading the scene fine but since I don’t have any scripts or anything like that in the scene that i’m loading it just appears blank should I be bringing the Client object over onto the scene i’m loading?

Thanks again.

try this modell:

Device A is in menu scene and starts server

Network.InitializeServer(...)

when server is initialized he is loading the gamescene

void OnServerInitialized()
    {
    /** Server
      * Called on the server whenever a Network.InitializeServer was invoked and has completed.
      * */
        Application.loadedLevelName("GameScene");
    }

Device B is in menu scene and connecting to Device A

 Network.Connect(serverip, port);

when connection was successfull device B is loading the gamescene

    void OnConnectedToServer()
    {
        /** Client
         *  Called on the client when you have successfully connected to a server.
         **/
        Network.isMessageQueueRunning = false;

        Application.loadedLevelName("GameScene");
    }

in the gamescene there are gameobjects for example a GameObject calld Manager with following awake function

    void Awake () {

        if(Network.isClient)
        {
            // Enable MessageQueue after loading the GameScene is complete
            Network.isMessageQueueRunning = true;
        }

        if(Network.isServer)
        {
            int randomPos = Random.Range(0,spawnPointList.Count);
            Network.Instantiate(prefabPlayerWithNetworkView, spawnPointList.ToArray[randomPos], Quaternion.identity, 0);
        }
    }

in the gamescene the client only activates the message queue back on, the server instantiates his own player GameObject (Prefab with NetworkView !)

so when the client joins he gets the information about the player GameObject of the server and see’s it (if you set it correctly in the inspector (picture)

for more information… a good start is following page and book:
https://www.packtpub.com/books/content/unity-networking-–-pong-game

good luck and keep in mind unity is bringing a new Networking Modell in 5.x !

2019206--130604--networkview.png

Hi again tobad! Thank you for your response. Would this work with the dedicated server style of networking having Server and Client as to different .exes?

Iv managed to accomplish this by using DontDestroyOnLoad(this);

with this function you create persistent gameobjects that stay after loading a new scene.

but this has nothing todo with network, next time ask more precisly like you want to keep gameobjects accross loading scenes :slight_smile: