From Menu to Game

I’ve been lookig at the Networking example, been reeding stuff on the forums and documentation and still no clue. My game has a main menu from which the player either becomes a host and hosts a server on a level or a client. The host was easy - I just load the level and then make initialize a server on it, but the clients are really tricky.
I’m using a master server and I get the server’s information with MasterServer.PollHostList();
Say hostData is an array, holding the information from PollHostList
Now if I try Network.Instantiate(hostData[index]) my player get’s spawned…somehow and outputs this error to the console:

The level stays the same. How do I jump to the server’s level and hook up with the server’s player? It’s pretty unclear to me, it seems like Network.Instantiate(hostData[index]) is just what it’s needed for this, but I’m having difficulties here.

I hate to once again bump my topic, but I see it’s getting left behind and I still haven’t figured out how to solve my issue.

Do both server and client have the same level loaded before you call network.instantiate? they should.

To start simple, you probably want to cal Network.Instantiate on the server. That will create the gameobject on both server and all connected players. get that working, then go from there.

Well here’s what I do:

if(GUI.Button(Rect(5, 22, 560, 20), "Connect")) serverIP = hostData[i].ip[i]; userType = UserType.Client; Application.LoadLevel(1);

Then when the level is loaded:

if(Network.peerType == NetworkPeerType.Disconnected  Windows.userType == UserType.Client)
Network.Connect(serverIP, 25000);

The level loads, but the player doesn’t spawn. I have function OnConnectedToServer() to check if the client has connected, but nothing happens. Before I had the connection script in the level I load now and when I clicked Connect everything was OK, but now something’s wrong…

EDIT: Actually it doesn’t even get connected.

I call the network.instantiate function on the client, because the network is non authoritative.

First, try using explicit IP, even running 2 editors on the same machine and using localhost an explicit IP:
Network.Connect (“127.0.0.1”, 25000);
'cause who knows what’s going on with the master server…

Sure, eventually you will want to do so, but just for testing see if you can get it to happen from the server.