Problem with Initializing RPCS

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 :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?


Is it possible that the object you have these scripts on accidentally has two NetworkAnimators on it? That would probably do it.

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.

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.

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.


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.


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

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


@YurySedyakin Nice! For the curious, to set Domain Reload to true:

Edit > Project Settings > Editor > Enter Play Mode Settings > Reload Domain = Ticked

1 Like

Getting the same error:

Unity 2022.3.0
Netcode 1.6.0

@neviovalsa have you tried setting Domain Reload to true? (See @stevekrile `s post)

Thanks for replying and yes, that works.
I just wanted to add that the bug still persists with the latest Netcode version.

Getting the same error for Unity 2022.3.6f1, Netcode 1.5.2.
Downgrading to Netcode 1.5.1 seems to fix the problem.

Netcode1.7.0 fixed the problem for me

  • Errors are no longer thrown when entering play mode with domain reload disabled (#2720)
1 Like