Search Unity

Unity server instance without the 3d graphics?

Discussion in 'Multiplayer' started by sperry, May 2, 2009.

  1. sperry

    sperry

    Joined:
    Apr 24, 2009
    Posts:
    13
    Reading the forum and the documentation it´s not clear to me if there is a way to run a headless instance of a unit game scene. Some mention the "-batchmode" command line argument, some mention the "Run in Background" option. But I could not find any definitive answer.

    So the question:

    Is it possible to run an Unity game instance as a server, without the 3d Graphics and GUI, in a "headless" mode?

    Main reasons for wanting this:

    1) Spare server CPU, GPU and memory resources, thus allowing more server instances per machine and/or more players per server.
    2) Have the game logic and physics replicated in a semi authoritative server.
    3) Maybe be able to run the server inside an emulated/virtual environment in a Linux server.

    Thanks in advance.
     
  2. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Im afraid not, nope.

    However, there is some sort of a headless mode on mac...unsure about the details though )Maybe thats the batchmodeindeed). Plus, I would want my server to run on linux..or in the worst case windows.

    Run in background would be required for servers, but is unrelated to headless mode.
     
  3. sperry

    sperry

    Joined:
    Apr 24, 2009
    Posts:
    13
    That's lame.

    Because it means:
    * less clients per server.
    or
    * that I will have to code a server from scratch having to worry about physics and with how to run the server side game logic.

    Thanks anyway.
     
  4. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Note that you *can* disable the rendering. Just turn off all cameras. You're still stuck with the application window though.
     
  5. sperry

    sperry

    Joined:
    Apr 24, 2009
    Posts:
    13
    That could help.

    On other hand, I figure that turning of the cameras will not prevent the render assets from being loaded.
     
  6. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Totally worthless at least for the only real hosting option, Windows
    Still runs 50%-70% of a 3.2Ghz P4 with no single client connected and a totally empty scene (the network test loader with all gui removed and reduced to tps auth switching only) and camera disabled (whole object including cam component and listener)

    Prepare to roll your own server solution with raknet and the unity packet ids mentioned in a different thread by zumwalt, if you want a dedicated server or to use Photon / Neutron / SmartFoxServer


    As for the headless: thats only for the editor to run buildscripts, its no client option
     
  7. BearishSun

    BearishSun

    Joined:
    Dec 1, 2008
    Posts:
    175
    Do Application.targetFramerate = 10 and it runs with pretty low CPU usage. Windows executable usually tries to run as many FPS as possible, so decreasing the draw calls doesn't really do much unless you limit the framerate.

    Still not good for professional server, but better if you don't want to make your own from scratch.
     
  8. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Actually Unity games could once run headless, at least on the Mac (actually it should work right now but last time I tried it, I couldn't make it work). I hope that this will make it into current Unity builds some day soon - and hopefully also for Windows (since I'm not gonna rent Mac servers ;-) ).

    You might want to vote for it:

    http://feedback.unity3d.com/pages/15792-unity/suggestions/164004-networking-headless-server-support

    (Aras also explains how to start a headless game server on Windows there, so you might give it a try ;-) ).
     
  9. bloodtiger10

    bloodtiger10

    Joined:
    Nov 9, 2008
    Posts:
    619
    yeah vote my idea up! :) I need this too. I am using networking except for these issues. lol
     
  10. sperry

    sperry

    Joined:
    Apr 24, 2009
    Posts:
    13
    I just voted for it!

    We can't use unity without headless server for windows or linux.
     
  11. Kai

    Kai

    Joined:
    May 28, 2009
    Posts:
    24
    I voted as well. This is really essential for any serious multiplayer effort.
     
  12. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
  13. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
  14. Ethan

    Ethan

    Joined:
    Jan 2, 2008
    Posts:
    501
    i gave it 3 votes.
    with the next release everything will be better :roll:
     
  15. Scorch

    Scorch

    Joined:
    Jan 12, 2011
    Posts:
    20
    I know this thread is old, but I just found the answer now, maybe this will help someone else. Run your app with -batchmode -nographics
     
  16. Edwige

    Edwige

    Joined:
    Nov 25, 2010
    Posts:
    35
    Thanks Scorch, I had the same issue, I will try that :)
     
  17. wolfgangmeyers

    wolfgangmeyers

    Joined:
    Mar 30, 2012
    Posts:
    2
    I have found myself with the same need. I did discover SmartFoxServer, which supports up to 20 concurrent users with the free version of the latest release. The unlimited concurrent users license seems worth the money to me.
     
  18. okiwanben0bi

    okiwanben0bi

    Joined:
    Sep 13, 2014
    Posts:
    13
  19. p0ck3t5

    p0ck3t5

    Joined:
    Aug 4, 2015
    Posts:
    1
    Yay for thread necro!

    There's information at https://docs.unity3d.com/Manual/CommandLineArguments.html that is helpful, here. Check out the command-line parameter "-nographics". It would appear that we can totally write headless servers, there's just not enough pointers to the information so we can figure out how.

    Posting this purely because this was one of the first google responses on the subject, so it deserves a refresh.

    Oh, and some more words for search engines to key on: dedicated server, noGUI, no graphics initialization
     
  20. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847

    To run as headless use command-line parameters "-batchmode -nographics", or with a Linux build you can just check the headless build check box on the build settings window.

    When running headless you need to set Application.targetFrameRate to a sane value (60 for example), because the Update loop is no longer waiting for graphics work between frames to slow it down. If you don't you'll see your build run at 100% CPU usage as it runs through the Update loop as fast as possible, which could be hundreds or thousands of frames per second.

    https://docs.unity3d.com/ScriptReference/Application-targetFrameRate.html
     
    IgorAherne and CloudyVR like this.