UNET - Spawn scene object not found

I’m looking into UNET, but I’m having some trouble getting a client to spawn GameObjects.

I have a host, which correctly creates a number of GameObjects (from prefabs that are registered in the Inspector of the NetworkManager).

    public GameObject unitPrefab;

    public GameObject Spawn(Vector3 position, Quaternion orientation)
    {
        Debug.Log("Spawn object " + unitPrefab.name);

        GameObject go = (GameObject)Instantiate(unitPrefab, position, orientation);
        NetworkServer.Spawn(go);

        return go;
    }

When the client connects, it appears that it’s trying to create equivalent objects in the client:

Client spawn scene handler instantiating [netId:9 sceneId:1 pos: (746.0, 13.1, 862.6)
UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()

but I get the error :

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

I’m callingNetworkServer.SpawnObjects()from the OnClientConnect() method in the NetworkManager.

The prefab being spawned has a NetworkIdentifer, and a script which derives from NetworkBehaviour

I’ve been stuck on this all day, any pointers would be really helpful.

Hope I can help, doubt it, but who knows. It is my understanding that objects spawned from the server (that are in the NetworkManager spawnable prefabs list (or registered to it through code) that are spawned on the server using NetworkServer.Spawn) is that when the client connects to the server, the spawned objects are automatically spawned on the client with their current state. I believe this means that these objects do not need to be spawned through any SpawnObjects() code on the client.

NetworkServer.SpawnObjects() tells the server to spawn more of the network identity objects, which are likely already spawned on the network (as they were when the server started). I don’t believe this function needs to be called in the OnClientConnect method, as the networkidentity spawned objects on the server should be automatically spawned.

Also be sure that the networkidentity is on the root gameobject of the prefab.
Also sorry for the extremely long run on sentences, best of luck. If you do figure it out, be sure to post what the problem/solution was, as I’m sure many others will have similar problems eventually with the new networking system.

Same here. Anything we can do about that?

I got it working. In my case it was the player prefab. I had to recreate it from scratch and then it worked.
Took me two days of unsuccessfully trying to find the problem by messing around with the Networking classes - which was not at all necessary. It could be some bug in how prefabs are read by the client routines in the api.

I was also having this problem. I deleted my Library folder and everything started to work after Unity rebuilt it on startup. Thanks Faloon, it would have taken me a while to go down that road if it wasn’t for your post.

Yes. Attempt ! =(
I have that bug to, one way is rebuild to startup.

1 Like

What the heck? I had this exact same problem myself, and somehow remaking the networked prefab from scratch fixed it too. I’m happy, but also kinda annoyed that this happens.

Reportable bug? What do you guys think?