Creating A Game
The easiest way to start creating a game is to download and rename the minimal gamemode.
You should also have an adequate coding workspace setup by following one of the following guides:
Every addon is self contained in its own folder in the addons directory. For example an addon called "myaddon" would be in the following path:
This folder should contain an .addon file (which is just json). This tells the game that the folder contains an addon. The .addon file doesn't need to contain anything except sharedassets otherwise your content won't be sent to clients:
After you have your
.addon file you can generate your solution file and dive into coding.
All your code should be contained inside a code folder within your addon folder.
Any C# code within this folder is compiled and used for your game.
All your content can go in folders within your addon folder.
addons/myaddon/config- for fgd files or for defining custom asset types
addons/myaddon/fonts- fonts here are automatically loaded and available for usage in UI
addons/myaddon/maps- maps are added to the menu from here
addons/myaddon/shaders- shaders placed in here are compiled
Every game you make needs a Game class, this is the entry point for all your game logic.
Initially you need to make sure your game class is derived from Sandbox.Game.
This needs to be in a .cs file in your addon code folder, we recommend calling it
With this your game should now show up in the main menu and let you load into a map.
When a client joins a server, by default nothing happens. You need to create a Pawn for that client to control. A Pawn is just an Entity that is controlled by a Client.
To create a first person player you can derive a new entity from the Sandbox.Player and creating it from Game.ClientJoined like so: