Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Problem with Initializing RPCS

Discussion in 'Netcode for GameObjects' started by KaiserTino, Aug 6, 2023.

  1. KaiserTino

    KaiserTino

    Joined:
    Apr 22, 2022
    Posts:
    7
    ArgumentException: An item with the same key has already been added. Key: 1665640498
    System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <46a5f68c38604d68a85231bbf55f6b8f>:0)
    System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <46a5f68c38604d68a85231bbf55f6b8f>:0)
    Unity.Netcode.Components.NetworkAnimator.InitializeRPCS_NetworkAnimator () (at <fbb171f72f3b4eb0b3b9a1a2dd9e4b07>:0)


    I get this error when I start the Play Mode in the Editor (2023.1.7f1) with Netcode 1.5.2

    I do not only get this Error but one for almost every RPC I have in my scripts. That makes up to a Number of about 25.

    I already tried reinstalled the package and upgraded to the newest Editor version I could find.

    Any Ideas?
     
    DoN2kcz and Krooq like this.
  2. Nyphur

    Nyphur

    Joined:
    Jan 29, 2016
    Posts:
    91
    Is it possible that the object you have these scripts on accidentally has two NetworkAnimators on it? That would probably do it.
     
  3. KaiserTino

    KaiserTino

    Joined:
    Apr 22, 2022
    Posts:
    7
    Thanks to your reply but my Player didnt even have a NetworkAnimator attached to it. Also I forgot to mention that I get those errors when I start the game in the Editor regardless of Scene and player as well as NetworkManager. I get them when I simply start the (offline) Scene.
     
  4. Balphagore

    Balphagore

    Joined:
    Jul 18, 2019
    Posts:
    81
    I am having the same problem.
    2023.1.7f1 with Netcode 1.5.2
    Occurs even on an empty scene without any scripts. But only on the second start of Playmode. The first run after opening the project occurs without these errors.
     
  5. Krooq

    Krooq

    Joined:
    Jan 30, 2013
    Posts:
    194
    I get the same thing in 2022.3.5
    Looks like a new bug introduced in Netcode for GameObjects 1.5.2
    I suspect they are working on patching it as we speak.
     
    Goreduc, stevekrile and kilo32 like this.
  6. stevekrile

    stevekrile

    Joined:
    Jul 17, 2023
    Posts:
    5
    Running in to the same thing here. If I change ANY code with Visual Studio that triggers a rebuild by Unity, then all works as expected on the FIRST run. If I stop, and restart the game, the error comes back and the game no longer functions. If I do anything that triggers a rebuild of the code (a space, and save on any .cs file does the trick) and I'm back in business.
     
    marstanjx and victorhs_studio like this.
  7. stevekrile

    stevekrile

    Joined:
    Jul 17, 2023
    Posts:
    5
    Just noticed that my version of Unity (2022.3.4f1.0.14531) is not supported according to the documentation.

    Netcode for GameObjects targets the following Unity versions:

    • Unity 2020.3, 2021.1, 2021.2 and 2021.3
     
  8. YurySedyakin

    YurySedyakin

    Joined:
    Jul 25, 2018
    Posts:
    62
    This means a temporary workaround is to enable domain reload when playing in the editor (that's what I did) until we get a proper fix from netcode devs
     
    gurth and stevekrile like this.
  9. stevekrile

    stevekrile

    Joined:
    Jul 17, 2023
    Posts:
    5
    @YurySedyakin Nice! For the curious, to set Domain Reload to true:

    Edit > Project Settings > Editor > Enter Play Mode Settings > Reload Domain = Ticked
     
    gurth likes this.
  10. neviovalsa

    neviovalsa

    Joined:
    Jun 24, 2019
    Posts:
    33
    Getting the same error:

    Unity 2022.3.0
    Netcode 1.6.0
     
  11. KaiserTino

    KaiserTino

    Joined:
    Apr 22, 2022
    Posts:
    7
  12. neviovalsa

    neviovalsa

    Joined:
    Jun 24, 2019
    Posts:
    33
    Thanks for replying and yes, that works.
    I just wanted to add that the bug still persists with the latest Netcode version.
     
  13. vegardkv

    vegardkv

    Joined:
    Mar 18, 2022
    Posts:
    2
    Getting the same error for Unity 2022.3.6f1, Netcode 1.5.2.
    Downgrading to Netcode 1.5.1 seems to fix the problem.
     
  14. neviovalsa

    neviovalsa

    Joined:
    Jun 24, 2019
    Posts:
    33
    YurySedyakin likes this.