Brackeys’ Player Dictionary Errors

Updated on October 13, 2017 in [A] Multiplayer
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
0 on October 13, 2017

Exception in OnStartClient: An element with the same key already exists in the dictionary


There is no NetworkIdentity on this object. Please add one.


I have adapted his multiplayer scripts to work in a 2D, .io style game. 



As seen in the image above, I have a capsule collider2D (with the following script) that activates correctly and has correct collisions with other players, but upon calling a GetPlayer method, I receive the “no network identity error”. The player DEFINITELY has a network identity. 

If not guessed already, I am attempting to make the sword deal damage to other players.


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class HitBox : NetworkBehaviour {
           private Player player;
           public PlayerWeapon weapon;
// Use this for initialization
           void Start () {
                      player = GetComponentInParent();
           void OnTriggerEnter2D(Collider2D col)
                      if (col.CompareTag("Player"))
                                 CmdPlayerShot(, weapon.damage);
           void CmdPlayerShot(string _playerID, int _damage)
                      Debug.Log("we hit " + _playerID);
                      Player _player = GameManager.GetPlayer(_playerID);


Also, the dictionary is not giving the players unique names, throwing the first error.


How does one fix these?

  • Liked by