Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Have some problems with Linux Server

Discussion in 'Multiplayer' started by SmackBlue, May 25, 2014.

  1. SmackBlue

    SmackBlue

    Joined:
    May 25, 2014
    Posts:
    7
    Hi community,
    i want to make a multiplayer game in unity. First time i tried it with a local connection and it works. Now i have a linux server. I want to inatialize the master server on it and make a c# script in unity to connect clients and play on this server.

    My server has this software: CentOS 6 with Parallels Plesk Panel 11.5 (64 Bit)
    But i can choose between this, too:
    • CentOS 6 Minimalsystem (64 Bit)
    • ubuntu 12.04 LTS Minimalsystem (64 Bit)
    • openSUSE 12.3 Minimal (64 Bit)
    • openSUSE 12.3 with Parallels Plesk Panel 11.5 (64 Bit)
    • openSUSE 13.1 Minimal (64 Bit)
    • Debian 7.0 Wheezy Minimalsystem (64 Bit)

    I tried to follow this little "tutorial": http://answers.unity3d.com/questions/64297/unity-master-server-on-linux.html but if i write "make ./MasterServer" in the console it says that there is nothing to done.
    Then i tried to connect to the server with unity and this little script:

    Code (csharp):
    1. public class NetworkManager : MonoBehaviour {
    2.     public GameObject playerPrefab;
    3.     private string serverip = "******";
    4.     private int serverport = 25000;
    5.    
    6.     void Start()
    7.     {
    8.  
    9.     }
    10.    
    11.     void OnGUI()
    12.     {
    13.         if (Network.peerType == NetworkPeerType.Disconnected)
    14.         {
    15.             if(GUI.Button(new Rect(100, 100, 100, 100), "Connect"))
    16.             {
    17.                 Network.Connect(serverip, serverport);
    18.             }
    19.         }
    20.     }
    21.    
    22.     void OnConnectedToServer()
    23.     {
    24.         SpawnPlayer();
    25.     }
    26.    
    27.     private void SpawnPlayer()
    28.     {
    29.         Network.Instantiate(playerPrefab, new Vector3(0f, 0.5f, 0f), Quaternion.identity, 0);
    30.     }
    31. }
    But there is an error like this: "The connection request to ******:25000 failed. Are you sure the server can be connected to?"

    Now i have some questions:
    1. Which server software should i use, which i named or should i change to a windows server?
    2. What am i doing wrong? I'm very new on this special field: "multiplayer".
    3. Do you know a tutorial which helps me making a master server?

    Sorry for my bad english, i tried my best! I hope someone can help me :)
     
  2. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    You can't use the master server to connect a Unity client in this way. A master server is not a Unity Server.
    The master is meant to connect Unity clients to Unity servers. Nothing more then that. It's a list of servers that clients can connect to and provides means to connect to it.
     
  3. SmackBlue

    SmackBlue

    Joined:
    May 25, 2014
    Posts:
    7
    Okay, first thank you for your answer.
    But what did i need to do, to create a gameserver for a multiplayer game in unity?
    Which server-software is usefull and which files did i need?
    Is there a good tutorial for that?
    Im a little bit confused ..
     
  4. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    Yes, look at the network class to see how it's done.
    Or look at 3rd party solutions like Photon server/Photon cloud/SmartFoxServer or others.
     
  5. SmackBlue

    SmackBlue

    Joined:
    May 25, 2014
    Posts:
    7
    Okay, i made a local server with the network class, but can i use it for a linux server, too?
    So i can use a script like this, and execute it on server, so i will have a game server which can be connected to?

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class NetworkManager : MonoBehaviour {
    5.     private int serverport = 25000;
    6.    
    7.     void Start()
    8.     {
    9.         LaunchServer ();
    10.     }
    11.  
    12.     void LaunchServer() {
    13.         bool useNat = !Network.HavePublicAddress();
    14.         Network.InitializeServer(32, serverport, useNat);
    15.     }
    16.    
    17.     void OnServerInitialized() {
    18.         Debug.Log("Server initialized and ready");
    19.     }
    20. }
    If that's true, i need to got a windows server, make a console exe with visual studio which initialize the server and execute it on server? Because i dont know how to do that with linux ...