Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Basic Multiplayer Game Setup With Ubuntu Server

Discussion in 'Multiplayer' started by fieldforensics, Jan 23, 2018.

  1. fieldforensics

    fieldforensics

    Joined:
    Aug 23, 2017
    Posts:
    14
    I setup a private home server with the spare desktop I had a while ago with which I use to host a couple things such as a website. I'm curious however how I could use my linux server to run a Unity program 24/7 in which anyone who connects to a specific port, preferably 4096 since I've already port-forwarded it. I'm familiar with creating a very basic executable server.jar file and running that on the server while also creating a client executable jar file that allows me to interact with the server. I'm curious as to how I could use unity with a similar approach, or if unity isn't setup to function like that, how I would manage to create a project where I can execute a server script for a game. I'm not entirely sure how I can build my game to run with linux when the only available build option for me is to build an executable file which can't be run on an Ubuntu Linux server. Any ideas? I plan on programming this game in C#, in fact I already have a basic single player 2D platformer game that I hope to transform into a multiplayer game.
    Thanks!
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Unity builds run fine on Ubuntu. Just build to Linux x86_64 with the headless build option checked, copy the build over, and set execute permissions on the main binary (chmod +x ./your_game_binary). Then launch your game server as a background task with an ampersand (&) at the end of the command (./your_game_binary &).

    UNET or any other networking API will work the same in your server build from Unity as it does in Windows/Mac clients, so just follow the same manual pages and tutorials as you otherwise would. .

    I suggest 7-zip for Windows to make a .tar file of your build to make it easy to copy over to your server.
     
    Last edited: Jan 24, 2018
  3. fieldforensics

    fieldforensics

    Joined:
    Aug 23, 2017
    Posts:
    14
    How would I build it to Linux x86_64 with the headless build option checked? When I check build settings, I don't have any option to export with windows nor anywhere does it show the headless option. I'm still not yet extremely familiar with all of Unity's features therefore it's probably hidden in plain sight.


     
  4. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Please download the Unity Installer and select "Linux build" or something along those lines. Make sure the installer is for the same version as your editor. This will not change anything of your current setup other than add the ability to build to Linux.

    This can be found here: https://unity3d.com/get-unity/download/archive
    The Headless build option is currently on avalible for Linux builds. But any build can be ran in a similar fasion to a headless version using the arguments -batchmode and -nographics (https://docs.unity3d.com/Manual/CommandLineArguments.html).
     
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Yeah like TwoTen said, it looks like you didn't install Linux build support when you originally installed Unity.