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
0
Question by teuba · Feb 27, 2016 at 03:53 PM · unity multiplayer

How can have more than 8 players connected to my server

Hello everyone !

I have a private server with public ip and i'm making some uNet tests. So I can connect to this server with no problems thanks to NetworkManager.StartServer() and NetworkManager.StartClient() methods.

But, when I have 8 players on the server, I can't connect the nineth. I set 100 to the NetworkManager.maximumConnection, so i don't really understand why this happen...

In my Unity Service Mulyplayer account, i create a new project and set to 100 the CCU in a session too

Here is my code, I hope someone help ! :)

 using UnityEngine;
 using UnityEngine.Networking;
 using UnityEngine.Networking.Match;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine.Networking.Match;
 
 public class ServerConnection : NetworkManager
 {
     [Header("!!!!! Set it true to build the server !!!!!")]
     public bool serverMode = false; // Is it the server build ? (Auto launch server if true)
     [Space(20)]
     public Vector2 logWindowSize = new Vector2(300, 150); // Size of the log window
 
     private NetworkClient myself; // My own client connection
     private List<string> allLogs = new List<string>(); // All logs in the window
     private Vector2 logScrollBar = Vector2.zero; // scrollbar in the log window
 
     void Start()
     {
         AddLogs("Not Connected");
         if (serverMode)
         {
             maxConnections = 100;
             StartServer();
             return;
         }
     }
 
     /// <summary>
     /// Launch a connection
     /// </summary>
     void OnClickConnect()
     {
         myself = StartClient();
         StopCoroutine("TestConnectionTimeout");
         StartCoroutine("TestConnectionTimeout");
     }
 
     void OnGUI()
     {
         // Server connection
         if (myself == null || (myself != null && !myself.isConnected))
         {
             GUILayout.BeginHorizontal();
             if (GUILayout.Button("Connection Reseau Local") )// <= When i connect using my pc as a server
             {
                 networkAddress = "127.0.0.1";
                 OnClickConnect();
             }
 
             if (GUILayout.Button("Serveur Local")) // <= When i connect to the server from server network
             {
                 networkAddress = "192.168.1.33";
                 OnClickConnect();
             }
 
             if (GUILayout.Button("Serveur Internet")) // <= When i connect to the server from another network
             {
                 networkAddress = "MyPublicLinuxIp"; // I keep it secret
                 OnClickConnect();
             }
             GUILayout.EndHorizontal();
         }
 
         // I am connected
         if (myself != null && myself.isConnected)
         {
             if (GUILayout.Button("Deconnection"))
             {
                 StopClient();
             }
         }
 
         GUI.Window(0, new Rect(0, Screen.height - logWindowSize.y, logWindowSize.x, logWindowSize.y), LogsDisplayer, "Informations");
     }
 
     /// <summary>
     /// Windows which display logs
     /// </summary>
     void LogsDisplayer(int id)
     {
         GUILayout.BeginVertical();
         logScrollBar = GUILayout.BeginScrollView(logScrollBar);
 
         for (int i = 0; i < allLogs.Count; i++)
             GUILayout.Label(allLogs[i]);
 
         GUILayout.EndScrollView();
         if (GUILayout.Button("Clear Logs"))
             allLogs.Clear();
         GUILayout.EndVertical();
     }
 
     /// <summary>
     /// Add a log in log displayer
     /// </summary>
     /// <param name="msg">Log à ajouter</param>
     void AddLogs(string msg)
     {
         allLogs.Add(msg);
         logScrollBar.y += 100;
     }
 
     /// <summary>
     /// Check if connection is timeOut
     /// </summary>
     IEnumerator TestConnectionTimeout()
     {
         yield return new WaitForSeconds(3.0f);
         if (!myself.isConnected)
         {
             AddLogs("Connection failed...");
         }
     }
 
 
     // EVERY FUNCTIONS DOWN ARE MESSAGES FROM UNITY AND UNET
     // I SUPPOSE WE DON'T CARE HERE...
 
     #region Match Messages
 
     public override void OnMatchCreate(CreateMatchResponse matchInfo)
     {
         base.OnMatchCreate(matchInfo);
         print("OnMatchCreate()");
     }
 
     public override void OnMatchList(ListMatchResponse matchList)
     {
         base.OnMatchList(matchList);
         print("OnMatchList");
     }
 
     #endregion
 
     #region Client Messages
 
     public override void OnClientConnect(NetworkConnection conn)
     {
         base.OnClientConnect(conn);
         StopCoroutine("TestConnectionTimeout");
         AddLogs(string.Format("Connection successfull to {0} port {1}", myself.serverIp, myself.serverPort));
         logScrollBar.y += 30;
         //StartCoroutine(DoesMatchMakingExist());
     }
 
     public override void OnClientError(NetworkConnection conn, int errorCode)
     {
         base.OnClientError(conn, errorCode);
         AddLogs("Error " + errorCode + " avec le client " + conn.connectionId);
         logScrollBar.y += 30;
     }
 
     public override void OnStartClient(NetworkClient client)
     {
         base.OnStartClient(client);
         AddLogs("Try to connect to " + networkAddress + " ...");
         logScrollBar.y += 30;
     }
 
     public override void OnClientDisconnect(NetworkConnection conn)
     {
         base.OnClientDisconnect(conn);
         AddLogs("Disconnected from server...");
         logScrollBar.y += 30;
     }
 
     public override void OnClientNotReady(NetworkConnection conn)
     {
         base.OnClientNotReady(conn);
         AddLogs("Disconnected ...");
         logScrollBar.y += 30;
     }
 
     public override void OnStopClient()
     {
         base.OnStopClient();
 
         // On repasse le curseur de la souris normal 
         Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
 
         // On kill le GUI du player
         foreach (PlayerController p in myself.connection.playerControllers)
         {
             if (p.unetView.isLocalPlayer)
             {
                 Destroy(p.unetView.GetComponent<Player>().playerUI);
             }
         }
 
         if (myself != null)
             myself.Disconnect();
         AddLogs("Disconnection successful");
     }
 
     #endregion
 
     #region Server Message
 
     public override void OnStartServer()
     {
         base.OnStartServer();
         AddLogs("Server is ready to be connected to");
     }
 
     public override void OnServerConnect(NetworkConnection conn)
     {
         base.OnServerConnect(conn);
         AddLogs(string.Format("Connection number {0} establish", conn.connectionId));
     }
 
     public override void OnServerRemovePlayer(NetworkConnection conn, PlayerController player)
     {
         base.OnServerRemovePlayer(conn, player);
         AddLogs(string.Format("Server remove player {0} from connectionId {1} ", player.playerControllerId, conn.connectionId));
     }
 
     #endregion
 }


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

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How can I send app unity between two devices via bluetooth (2 smartphone android) 0 Answers

Cameras focused on Host (Unity Multiplayer) 0 Answers

Any way to spawn 2 different Game Objects when doing multiplayer? 1 Answer

Multiplyaer FPS sprint speed does not work 1 Answer

Coroutine in Awake function on Network project doesn't work 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