Spawned objects not initialised on JIP clients.

Hey everyone! Long time lurker, first time poster here.

I’ve been messing around with uNet and it seems pretty decent so far. Seems to be nicer than Photon and the legacy system and on par with Bolt. I’ve ran into an issue however: clients that join after an object is spawned on the network don’t have that object instantiated but still receive updates. Scene objects with network identities are also not activated upon connecting. Everything works perfectly fine on the server though.

I’m using a custom NetworkManager and overriding a lot of the methods so I’m probably overriding a method where the client sets up these things. However, I have no idea what I am missing. Access to the NetworkManager source would make this a lot easier. (I don’t see a reason not to considering it’s just a C# class)

Thanks for reading through.

NetworkServer.SpawnObjects() causes scene objects to be activated… maybe somehow that is not being called by the NetworkManager.

I already call that in OnServerSceneChanged. Besides, it still doesn’t explain clients not instantiating player objects that were created at runtime before they joined.

I think that some initialisation happens in one of the methods I override in the NetworkManager and that is what is causing this.

the game objects might have been created on the client and then destroyed when the scene changed. Synchronized scene changes between the server and client require delicate timing coordination.

That’s impossible. The player objects are created when the ‘round’ starts and are destroyed when it ends (then the server switches to a new scene) so that isn’t a factor to consider.

I just did some testing and the default NetworkManager (as opposed to my custom one) doesn’t cause this behaviour. I’m 99% sure that I’m overriding some necessary behaviour in my custom NetworkManager but I have no idea what it is as I don’t have the original source and the documentation is rather sub-par.

are there errors in the log for the client that connects?
are the prefabs of these objects registered with the spawning system?

If you really want, you can use ILSPy on the UnityEngine.Networking.dll to see exactly what the NetworkManager does.

It appears that running the NetworkManager with a log level of ‘Debug’ actually makes it work properly. On ‘Info’ log level then it appears to break. Very odd. I’m going to investigate it a bit and report my findings.

That suggests it is probably a timing issue, as writing all those log lines slows down the editor enormously.

So I did a little bit of experimentation and found that setting a log level of either ‘Info’, ‘Warn’, ‘Fatal’ or ‘Error’ all cause the issues that I have described above. However, log levels of ‘Debug’ and ‘Developer’ allow it to function normally. The timing issue sounds probable actually but I’m not doing anything that is dependent upon timing.