Server player object not sent to client on connect?

I have a simple level where you can create/join a server. If you create the server, it takes you to playing the game right away, spawning your avatar via Network.Instantiate(…) within the Start() method. OnPlayerConnected tells the client to load whatever level the server is currently on. The client’s avatar is then instantiated from within the same Start() method as was the server’s avatar.

The client’s avatar appears correctly and moves correctly on the server’s screen, but the server’s avatar is not spawned on the client.

What is the proper way to remedy this?

[edit: I solved it myself and submitted the answer.]

Figured it out.

There was a document that I finally stumbled across about level switching in networked games: http://unity3d.com/support/documentation/Components/net-NetworkLevelLoad.html

The problem I was having is that the server was telling the client to load the correct level, however the Network.Instantiate call had already been propagated to the client at that point; and when the new level loaded, the object that had been created was destroyed.

The document mentions specifically pausing the message queue (Network.isMessageQueueRunning = false), then loading the level, and finally resuming it.

I put the resume message handling code in my Start() method in the new level, and it worked perfectly. :slight_smile: