Search Unity

Can't Load into Game With Many Spawned Objects - KeyNotFoundException

Discussion in 'Netcode for GameObjects' started by Louiebloo, May 3, 2022.

  1. Louiebloo

    Louiebloo

    Joined:
    Jan 26, 2022
    Posts:
    4
    My game has a lot of Network objects that are initially spawned. However if I have too many game objects the clients cannot connect to the game as they receive a KeyNotFoundException - "The given key was not present in the dictionary" error.

    I see a few other threads with this issue and the problem seems to be that it takes too long to load the objects in one frame and it fails:

    https://forum.unity.com/threads/spawning-too-many-objects-at-once-leading-to-errors.1203745/
    https://forum.unity.com/threads/basic-bug-on-client-side-on-version-1-0-0-pre-5.1233610/

    This error is pretty much a nail in the coffin to using this framework. Even basic scenes can have a few tens of objects that are spawned on startup and if the clients can never spawn them then you can never play. Its impossible to develop if there is some magic number of objects I can have in my scene before it fails. I noticed on slower connections its even worse so its client internet specific which further deepens the nightmare. Even if I have some sort of "spawn loop" that loops over objects to spawn 1 at a time in the scene, it still would never work if someone loads in later or there is any sort of reconnect feature.

    Is there any timeline on fixing this? Or a new Netcode release in general? I am very close to jumping ship as I literally cannot use the framework.

    Thanks
     
  2. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    664
    bing2 likes this.
  3. Louiebloo

    Louiebloo

    Joined:
    Jan 26, 2022
    Posts:
    4
    I am trying to update but am running into compiler errors:

    Library\PackageCache\com.unity.burst@1.6.5\Unity.Burst.CodeGen\FunctionPointerInvokeTransform.cs(5,12): error CS0234: The type or namespace name 'Cecil' does not exist in the namespace 'Mono' (are you missing an assembly reference?)

    If I install the com.unity.netcode.gameobjects package my project wont build. Is this a unity version thing?
     
  4. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    664
    I had something similar but it was months ago and I've forgotten how I fixed it. Try googling it and see what you can find out.