Getting a KeyNotFoundException error when trying the tutorial

I've recently moved my prototype from Photon PUN to Photon Truesync, using the tutorial as a reference.

I've replaced my player prefab with TS Transform 2D, etc. The room joining is the same as before.

I can create a room and move the player without problems, but when another player joins the match the server starts showing this error:

KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary`2[System.Byte,TrueSync.TSPlayer].get_Item (Byte key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
TrueSync.AbstractLockstep.OnEventDataReceived (Byte eventCode, System.Object content)
TrueSync.PhotonTrueSyncCommunicator+c__AnonStorey0.<>m__0 (Byte eventCode, System.Object content, Int32 senderId) (at Assets/TrueSync/Unity/PhotonTrueSyncCommunicator.cs:43)
NetworkingPeer.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2599)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (System.Byte[] inBuff)
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands ()
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands ()
PhotonHandler.Update () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:157)

The room code just does what truesync tutorial says. And the game doesn't use RPCs at all.


  • I've found out the problem. If a client joins the game scene, any other client that tries to join later on will give that error.

    You need to create a room, and make sure all clients join that room before loading the game scene. Looks like Truesync doesn't support "hot join" while playing.
  • Hi @SaffronCR, you are right, TrueSync doesn't support a later join, as we move each step of the simulation simultaneously in each player, so they must be previously connected to the room.
Sign In or Register to comment.