Why do I get "A connection has already been set as ready." Error
So I implemented my own NetworkManager because I wanted to spawn different PlayerPrefabs depending on some selection and tell the Player Name. For now I want to get it to work to send the PlayerName over the Network from Client to Server. So These are the Code lines:
 public override void OnClientConnect(NetworkConnection conn) {
     Debug.Log("OnClientConnect");
     StringMessage msg = new StringMessage(_playerName);
     ClientScene.AddPlayer(conn, 0, msg);
 }
 public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId, NetworkReader extraMessageReader) {
     Debug.Log("OnServerAddPlayer");
     string customParameters = "";
     if (extraMessageReader!=null) {
         customParameters = extraMessageReader.ReadString();
     }
     _playerName = customParameters;
     GameObject o = Instantiate(spawn) as GameObject;
     MyPlayerCharacter mpc = o.GetComponent<MyPlayerCharacter>();
     mpc.playerName = _playerName;
     NetworkServer.AddPlayerForConnection(conn, o, playerControllerId);
 }
but now I get the following Error allready when I start to Host a Server:
A connection has already been set as ready. There can only be one. UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()
this Error disappears when I comment out the following line of Code:
ClientScene.AddPlayer(conn, 0, msg);
So could anybody explain me what I'm doing wrong or what I've missed out?
Answer by Noob235 · Oct 26, 2015 at 07:32 PM
try:
         if (string.IsNullOrEmpty (this.onlineScene) || this.onlineScene == this.offlineScene)
         {
             ClientScene.Ready (conn);
             if (this.autoCreatePlayer)
             {
                  ClientScene.AddPlayer(conn, 0, msg);
             }
         }
instead of only
      ClientScene.AddPlayer(conn, 0, msg);
this is the code used by the standard networkManager
This partially solved my Problem. The "Connection has already been set as ready" error disappeared and therefor I accept your Answer. But now after a Host started a game and a Client tries to connect, the game stops with following error:
"HLAPI CRC channel count error local: 1 remote: 2 UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()"
as I figured out right now this seems to be caused by some $$anonymous$$ind of sync loss because the Server has 2 Network Identities while the Client only has 1 or something. Still Need to dive into this one. Thanks for your Answer.
What also solved the "Connection set as ready error " and causing the same sync error is to override OnClientSceneChanged(NetworkConnection conn) that I could find on this thread
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                