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.
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?
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)
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?