In-scene placed networkbject which is inactive at scene load does not spawn the network object on client side

I have a lobby scene where all players (clients) connect, once required number of clients connect I load the game scene. I have an in-scene placed networkObject that is inactive when scene is loaded and is set active by my sceneManager.

This spawns the networkObject on client but not on server.

I tried manually spawning the networkObject in Start(), this spawns the networkObject on Host but not on client, I get the error on client: Netcode] Failed to create object locally. [globalObjectIdHash=(HashID)]. NetworkPrefab could not be found. Is the prefab registered with NetworkManager?

My NetworkManager.EnableSceneManagement is marked true.
My networkObject’s Active Scene Synchronization is marked true.
The scene is loaded through NetworkSceneManager.

This networkObjects differs from other in-scene placed networkObjects only in the sense that this one is not active when scene is loaded, it is set active later.

And you set it active on the client only?
If you aren’t setting it active on the server-side, it won’t synchronize to clients.

I would generally advice against calling SetActive on network objects. Instead refactor your components so that either the object is dynamically spawned (this makes more sense anyway for an object that is only needed later) or where its active state isn’t controlled by SetActive but by custom logic that disables the network object’s child object that contains the colliders, visuals, and so on.

Using NetworkObjectVisibility might also be an alternative.

1 Like

inactive objects don’t spawn