Spawn scene object not found for 1

i have error while loading map on client and network Scene objects deactivated

i was calling the NetworkServer.SpawnObjects at the end on map load fuction(on server)

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

I have this same problem. I have a host and a client. When I switch scenes using ServerChangeScene() the scene objects with NetworkIdentity components are disabled (as they should be). I then set clients to ready after their scenes load. Then on the server I call SpawnObjects() and the disabled scene objects load on the host, but not on the clients.

I also have the same problem, but it only happens sometimes, seems pretty random and might depend on the load timing. Unfortunately I couldn't yet reproduce an exact case when it happens.

It seems the randomness might be related to if the server loads before client, or if the client loads before server (just a guess). I found a workaround that seemed to help… I force the server to load first.

On the server call both of these.
Application.LoadLevel(sceneName);
NetworkManager.singleton.ServerChangeScene(sceneName);

Does anybody know why this is happening?

2 Likes

I was totally convinced this was something I was doing wrong but after reading this thread I’m less sure. For anyone wondering this still seems to be a problem as of 5.2.0f2 and Zullar’s fix seems to work.

1 Like

It may also be related to custom NetworkManager. I noticed calling Awake() in a custom NetworkManager caused all sorts of problems, including this one I believe. Do you have a custom NetworkManager, and if so are you calling Awake()?
http://forum.unity3d.com/threads/unet-scene-objects-not-spawning-w-custom-networkmanager.369236/

2 Likes

Maybe this will help someone else out. I found this comment while trying to solve an unrelated issue but I think it solves this problem as well. In your custom NetworkManager, if you need to have an Awake method for whatever reason, just put

System.Type type = typeof(UnityEngine.Networking.NetworkManager);
var baseMethod = type.GetMethod("Awake", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
if (baseMethod != null) baseMethod.Invoke(this, null);

at the top of the Awake method to call Awake on the base class. Normally you would just call base.Awake() but for some reason the unity devs decided to make the NetworkManager’s Awake() method private so you have to use reflection like this.

I spent 1 hour trying to figure this out but I solved it in the most dumb way.
I removed and readded the network identity component to my prefab

I did this because I’ve noticed the Scene ID = 1 field, while all the others where = 0
Don’t know why unity did this change at some point, but fucked up my project.

6 Likes

I had the same issue. After reading your response I did the same and it worked. Thank you. I know how mine got messed up though. I had in inadvertently dragged my cloned prefab on to the original prefab while in run mode.

1 Like

I had exactly the same problem, I had to recreate my network identity component of the player prefab in the online scene..

But what if I have multiple online Scenes? Like Map1, Map2 or Map3..... do I need 3 differnt Player Prefabs?
Sounds Like a bug...

Hi everyone,

I ran into the same issue and got to the following conclusion:
If the clients change the scene before the server does, the server will try to sync all NetworkIdentity game objects to its clients. If those are just objects on the scene and are not registered as spawnable objects, the sync will fail because it can't spawn the object, which results in this message.

1 Like

So guys, what's your conclusions? All I have is a server enter a scene with one (1) networkobject (one object with networkidentity). Since I use serverchangescene in my custom networkmanager, it nicely enough reactivates this object, However, when a client tries to join the server, I get the error "Spawn scene object not found for 1" and I can't seem to wrap my head around it. It seems to happen when it tries to spawn that object (and as sonic220 wrote earlier, the scene id is 1 instead of 0) because after some mixing I managed it to work without serverchangescene, but I still got the error.. I just can't seem to get rid of it...

I think what is happening (not completely sure). Let me know if this is what is happening.

Scene1: Has no networked objects. Default scene
Scene2: Has 1 networked object

Order of Stuff that Works OK
Host starts game in Scene1
Client connects (Client is Scene1)
Host switches to Scene2.
Host sends scene change message to client
Client loads Scene 2
Host sends "spawn" messages and spawns the object from Scene2
Object is properly spawned on Client
---Everthing works fine---

Order of Stuff that Fails
Host starts game in Scene1
Host switches to Scene 2
Host "spawns" object from scene 2 (and it loads properly on host)
Client connects (but client is in scene 1)
Client receives "spawn" messages for the object in scene 2. But the object doesn't exist because client is still in Scene1
Host sends scene change message to client
Client loads Scene 2
---The client is in scene 2, but the object failed to spawn because messages are received in incorrect order---

I'll also add that I've realized that SceneObjects are NOT added to the spawnedObjectList that is automatically maintained for late connecting players. If you have a SceneObject and use DontDestroyOnLoad() and carry that SceneObject to another scene where it doesn't exist... and then connect with a client... the client will not get that object. However if you instantiate & spawn a registered prefab (as opposed to a scene object) then it works fine for late-connecting-players even if they connect to a scene where the object was not generated.

I can not delete my network Identity my scripts are dependent on it and I seem to be able to connect to the same room but can not see the other players. I attempted to change the net ID from local to server only and then back to local but all that has done is allow players to join the same game but not see each other. Please help. I am a total noob

Spent half day finding the problem until I read this… the scene id became 1!! I just change it back to 0 in inspector debug mode… how could this happen and where is the scene id used?!?

Yep, had this same problem and used your solution.
Not sure why, as it was a brand new project.

hi guys I am getting
I am loading additive scene through rpc call but as my new scene load its all network identity object becomes disable so i use this line of code in start of my next scene. its showing me this error

Spawn scene object not found for 1…

Although it is running fine on server but not on client. please help

I used this solution, now object is displaying but objects transform is not syncing across network.

Can someone clarify what is meant by “scene id” and where I can find that? Do you mean the number that is next to the scene in “Build Settings” (Ctrl-Shift-B)?
I didn’t understand when to remove and readd the NetworkIdentity component and what the scene ID has to do with it.

1 Like

Use debug mode in inspector, you will get scene id in network identity/behaviour.(I Guess)

1 Like