- Home /
The question is answered, right answer was accepted
UNET NetworkServer.Spawn intermittently not called on clients
I'm having issues where roughly 50% of the time, a NetworkServer.Spawn() call on the server will not spawn the corresponding prefab on clients. After three 10 hours days straight of trying to resolve this issue, as well as trawling the forums for existing bug reports, I'm turning to the forums for the first time :)
I've verified that my ClientScene.Prefab() call is being made.
The object being spawned has NetworkIdentity component at its root.
The object being spawned has a NetworkBehaviour child script at its root.
I've verified that the NetworkServer.Spawn() call is being made correctly with a non-null prefab on the Server side.
Once the Spawn call is made on the server, nothing appears on clients and I receive the following warning on clients "Did not find target sync message for X" where X is an integer.
It's probably worth noting that I'm working in a prototype Scene of a much larger project and I'm using the build-in Unity classes (e.g NetworkManager) to obtain the initial connections.
I appreciate that code snippets would aid greatly, although the project itself is tens of thousands of lines, which would mean posting highly edited code for the sake of brevity. That could result in the editing out of the cause.
Any ideas are greatly appreciated!
You are instantiating the Objects before NetworkServer.Spawn, right?
.Prefab() isnt a listed function. Its either .Prefabs() for the Dictionary of registered prefabs or its .RegisterPrefab()
http://docs.unity3d.com/ScriptReference/Networking.ClientScene.html
Does the Network$$anonymous$$anager have the prefab for the object being spawned added to the list of registered spawnable prefabs?
is there a scene change happening? The objects could be getting spawned on the client and deleted immediately as the scene changes.
Have you tested on a stable connection?
$$anonymous$$aybe refer to NetworkTransport layer to deter$$anonymous$$e Packet Loss on that particular connection?
Hi all, thanks for your replies :) After a whole lot of tweaks and testing bits, I discovered the issue. I hadn't realised that the spawn call makes use of the standard QoS channels set on Network$$anonymous$$anager object. Switching my first channel to an assured delivery channel fixed the issue. I'll drop a summary below for anyone else that my come across this.
Answer by staddonl · Jul 17, 2015 at 09:04 PM
For anyone that comes across this in the future:
The NetworkServer.Spawn call makes use of the QoS channel set as '0' in your NetworkManager object. Ensure that this is set to an assured delivery channel (such as reliable sequenced) or override the channel used by the script performing the spawn call to point to an assured delivery channel.
Hi, I appreciate that you posted your solution. I am new to Unet and don't know much about networking overall, therefore I still can't solve that issue. Could you or anyone else describe in a little more detail how to change the channel?
Channels should be part of Network$$anonymous$$anager
http://docs.unity3d.com/ScriptReference/Networking.Network$$anonymous$$anager.html
Networking is explained in full, here: