2
\$\begingroup\$

I'm getting this error with the new Unity Networking (5.1):

Spawn scene object not found for 1
UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()

This happens in the client, when it connects to the server: the server is file, while the client fails to load the scene. I guess this error means "I failed to load the (online) scene" (which in fact it is the scene number 1), but I've no clue why it does fail.

The server has a custom player spawning function:

public class NetworkDirector : NetworkManager
{
    public override void OnServerConnect (NetworkConnection conn)
    {
        base.OnServerConnect(conn);

        Transform spawnPoint = FindObjectOfType<SpawnPoints>().getNextSpawnLocation();
        GameObject spawned = FindObjectOfType<InstancedElements>().SpawnObjectFree(playerPrefab,spawnPoint);

        FindObjectOfType<CameraFollow>().SetTarget(spawned);
        NetworkServer.AddPlayerForConnection(conn,spawned,0);
    }
}
\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

OnServerConnect gets called as soon as the client connects, before he has been able to do pretty much anything else, including loading the online scene.

Player spawning should be done in the OnServerReady function, instead.

public override void OnServerReady (NetworkConnection conn)
{
    base.OnServerReady(conn);
    [...]
\$\endgroup\$
2
  • \$\begingroup\$ This is partially correct explanation, since you are using the NetworkManager, it handles the client states and sets them to ready as soon as the scene is loaded in clients. Functions involving spawning should and will only be called through or by connections those clients are set to ready by the server. In this case NetworkManager handles it. \$\endgroup\$ Jun 21, 2015 at 17:50
  • \$\begingroup\$ hi man i am getting same error but in different scenario gamedev.stackexchange.com/questions/136469/… \$\endgroup\$ Jan 28, 2017 at 11:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .