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, and inside your game you need to check if it is running headless.

You can take as base the BoltInit.cs script that comes with the Bolt samples, and add or update the Start function like shown below:

With this script update, 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