Description
Describe the bug
If too many network objects are spawned at once, they are spawned for the host, but not for the client (with Unity Transport).
To Reproduce
Steps to reproduce the behavior:
- Create a Prefab with a NetworkObject component and add it to the NetworkPrefabs in the NetworkManager
- Increase SendQueueBatchSize (tested with 6144000)
- Start two instances (Host and Client) and spawn e.g. 1000 objects:
public void Spawn(int spawnCount)
{
for (int i = 0; i < spawnCount; i++)
{
NetworkObject no = Instantiate(prefab);
no.Spawn();
}
}
- The objects are spawned for the host, but not for the clients, no errors/warnings on both instances
Actual outcome
- The objects are spawned for the host, but not for the clients
- no errors/warnings on both instances
- existing NetworkObjects (e.g. with NetworkTransform) that were already spawned before are still synchronized from Client to Host, but not from Host to Client
Expected outcome
Ideally all objects are spawned on the client and everything is working.
If that is intended and NGO does not support that many objects, imo at least an exception should be thrown to indicate that something went wrong.
Environment (please complete the following information):
- OS: Windows 10
- Unity Version: 2021.2.7f1
- Netcode for GameObjects Version: 1.0.0-pre.4
- Unity Transport for Netcode for GameObjects Version: 1.0.0-pre.4
Additional context
If the Prefab contains only a NetworkObject, it works for up to 700 objects (750 does not).
If the Prefab also contains a Collider with gravity enabled (so all objects are moving at once when spawned), it only works for 200 objects (250 does not).
It does work with more objects, if I use the UNet Transport, but then the max MessageBufferSize (max 65535) is the limit and I cannot use the Relay Service with it.
I also considered spawning objects over time (e.g. max. 500 at once). It does work, if the client is already connected while spawning the objects, but I have the same problem, if a client connects afterwards (because all objects are spawned automatically when connecting).