Headless Server

Often times you will want to run a server that uses less resources. To run a Unity application like this you will want to launch it with arguments -batchmode -nographics. You can do this in command line, for example "myGame.exe -batchmode -nographics". Your game then needs to check if it is running headless.

With this script in your initial scene, you can enter "myGame.exe -batchmode -nographics -map Level1" and it will launch a server for your scene Level1. Of course you can customize this to use a port you enter, a different game mode, etc by making more argument checks.

You will also want to disable things in the game when running headless such as locking the cursor, spawning a player, and music. For the tutorial there is "Screen.lockCursor = true" in PlayerCamera.cs, you can modify the script to only lock the cursor if not in headless mode. The same goes for Player.serverPlayer.InstantiateEntity() in ServerCallbacks.cs

 To Document Top