Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/facepunch/sbox-public/llms.txt

Use this file to discover all available pages before exploring further.

Creating your first s&box project takes only a few minutes. The editor handles project scaffolding, scene management, and code compilation — you focus on placing GameObjects, attaching components, and pressing Play. This page walks through the complete flow from an empty editor to a running game.
Make sure you have the s&box editor installed before continuing. See the Installation guide if you haven’t set it up yet.

Create a new project

1

Open the editor

Launch s&box from Steam (or run the editor binary if you built from source). The main menu appears with a list of your existing projects.
2

Create a project

Click New Project. Give your project a name and choose a folder on disk. The editor generates the project structure — a .sbox project file, a code/ folder for C# source, and an Assets/ folder for scenes, materials, and other assets.
3

Open the project

Double-click the new project in the project list. The editor loads and opens the scene viewport.

Set up a scene

Every s&box game runs a Scene — a hierarchy of GameObject nodes. When you create a project, the editor starts with a blank scene. Set it up with the basics:
1

Add a directional light

In the Scene panel (the hierarchy on the left), right-click and choose Add GameObject. Name it DirectionalLight. In the Inspector panel on the right, click Add Component and search for DirectionalLight. This illuminates your scene.
2

Add a camera

Add another GameObject named Camera. Add a CameraComponent to it. The active camera determines what the player sees at runtime.
3

Add a ground plane

Add a third GameObject named Ground. Add a ModelRenderer component and set its model to the built-in models/dev/plane.vmdl (or any flat model). Add a BoxCollider component so objects don’t fall through it.
4

Save the scene

Press Ctrl+S to save the scene as a .scene file in your project’s Assets/ folder. Name it main.scene.

Write your first component

Components are C# classes that extend Component. They live in your project’s code/ folder and hot-reload when you save.
1

Create a script

In the Assets browser at the bottom of the editor, navigate into code/. Right-click and choose New Script. Name the file Spinner.cs.
2

Write the component

Open Spinner.cs in your IDE. Replace the contents with the following:
using Sandbox;

public sealed class Spinner : Component
{
    [Property]
    public float Speed { get; set; } = 90f;

    protected override void OnUpdate()
    {
        Transform.Rotation = Transform.Rotation
            * Rotation.FromAxis( Vector3.Up, Speed * Time.Delta );
    }
}
OnUpdate is called every frame while the component is active. Time.Delta is the time in seconds since the last frame — multiply by it to keep movement frame-rate independent.
3

Attach the component to a GameObject

Save the file. The editor recompiles automatically. In the Scene panel, select your Ground GameObject (or create a new one). In the Inspector, click Add Component, search for Spinner, and add it. You’ll see the Speed property appear because it’s marked with [Property].

Run the game

1

Press Play

Click the Play button in the toolbar (or press F5). The editor enters Play mode. The scene begins executing: OnStart runs once per component, then OnUpdate runs every frame.
2

Observe the result

If you attached Spinner to your Ground object, it will rotate around the Y axis at 90 degrees per second. You can adjust the Speed property in the Inspector while the game is running — changes take effect immediately thanks to hot-reloading.
3

Stop and iterate

Click Stop (or press F5 again) to exit Play mode. The scene resets to its saved state. Edit your component, save, and press Play again. There is no compile-and-restart step.
You can check Game.IsEditor inside a component to run editor-only logic without affecting the shipped game:
protected override void OnUpdate()
{
    if (Game.IsEditor)
    {
        // draw debug gizmos
    }
}

Component lifecycle reference

The table below shows the order in which the engine calls component methods:
MethodWhen it runs
OnAwakeOnce, when the component is first initialized
OnEnabledWhen the component (or its GameObject) becomes active
OnStartOnce, just before the first OnUpdate call
OnUpdateEvery frame while enabled
OnFixedUpdateOn a fixed interval, aligned with the physics tick
OnPreRenderEvery frame, just before the scene is rendered (client only)
OnDisabledWhen the component (or its GameObject) becomes inactive
OnDestroyOnce, when the component is destroyed

Next steps

Scene & GameObjects

Learn how the scene hierarchy works and how GameObjects relate to each other.

Components

Explore the full component API, including properties, tags, and component queries.

Scripting basics

Deeper dive into C# scripting patterns used in s&box.

Networking overview

Add [Sync] properties and RPCs to make your game multiplayer.

Build docs developers (and LLMs) love