Hi,
The problem is that the OnNetworkSpawn is never called for client only but whenever i called
NetworkManager.Singleton.StartClient(); but it would be invoked when call
NetworkManager.Singleton.StartHost();
Please provide more info. How is the object spawned? By script or in-scene? Could you share the relevant code fragments?
Personally i have not had this issue in both server side spawned objects and in-scene placed ones.
The linked github issue is also lacking information.
Is the object actually spawning on the client, in the inspector does it have a networkId? On the server object in the inspector is the clientId listed under Observers?
In my case, I realized I had a duplicate NetworkManager and the NetworkObject was part of the duplicate. Of course, this duplicate NetworkManager was never started (because StartHost() or StartClient() was never called on it).
To confirm, inspect the NetworkObject component of the object in question and check the NetworkManager field. Confirm that it is assigned to the same NetworkManager that you have started
Just to point out a common oversight: Scene Management.
One critical aspect is that you have to load scenes with NetworkManager.Singleton.SceneManager.
The other issue arises when you donât change scenes at all. Itâs best to set up any Netcode project so that you have two scenes: pregame and ingame. Pregame has the NetworkManager. When starting host or server, you should load the ingame scene in the next line of code.
When the client starts in pregame, it will automatically be transferred to ingame once connected.
This guarantees that the Ingame scene and everything in it is fully networked.
And of course upon disconnect you change back to the pregame scene.
Then build your scene flow around that. Personally I am finding it exceptionally beautiful to stick with just those two scenes, and load all remaining content both for pregame (menu) and ingame (gui, map, etc) with additive scene loading.