• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
Question by ElDo · Oct 25, 2015 at 07:17 PM · networkingplayerprefs

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?

Comment
Noob235
Guhanesh

People who like this

2 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
Best Answer

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

Comment

People who like this

0 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ElDo · Oct 27, 2015 at 05:47 AM 0
Share

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 Kind 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

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

38 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Network Behaviour 0 Answers

Can't sync previous connected clients' color. 0 Answers

how can i transfer my leap motion data from serve to client ? 0 Answers

Simple ClientRpc Whats wrong with it? 0 Answers

navmeshpath serialization via reflection for network RTS game 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges