Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
2
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
Add comment
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

· Add your reply
  • Sort: 
avatar image
0
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
Add comment · 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 $$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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

39 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 avatar image

Related Questions

Network Behaviour 0 Answers

Unet disable button from client 2 Answers

Why my custom network script automatically adds a NetworkIdentity component every time I add it to my NetworkManager object? 1 Answer

How Would I Make A Round Based System Like Csgo 1 Answer

Which API and class do I need for networking to a central server(always on)? 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