Prerequisites
You need a working s&box installation. See Installation if you haven’t set that up yet.Create a project and scene
Open the editor
Launch s&box from Steam (or from the
game/ folder if you built from source). You will land on the project browser.Create a new game project
Click New Project and choose the Empty Game template. Give your project a name and an ident — for example
mygame.shooter. The editor creates a project folder and opens the asset browser.Create a scene
In the asset browser, right-click an empty area and choose Create → Scene. Name the file
main.scene. Double-click the file to open it in the scene editor.Write a component
Components are C# classes that inherit fromComponent. The engine calls lifecycle methods — OnAwake, OnStart, OnEnabled, OnUpdate, and others — automatically at the right time.
Create a C# file
In the asset browser, right-click and choose Create → C# Script. Name it
Spinner.cs. The editor opens the file in your configured code editor.Write the spinning component
Replace the file contents with the following:Key points:
[Property]exposesSpeedas an editable field in the Inspector.Transformis a shortcut forGameObject.Transform, which controls position, rotation, and scale.Time.Deltais the frame delta — always multiply per-frame changes by it to keep behaviour framerate-independent.
Add the component to the GameObject
Save the file. The engine hot-reloads the script automatically. Back in the editor, select the Spinner GameObject, click Add Component in the Inspector, and search for
Spinner. Click it to attach the component.You should see the Speed property appear in the Inspector. You can edit it without restarting.Component lifecycle reference
The full set of overridable methods onComponent:
| Method | When it is called |
|---|---|
OnAwake | Once, when the component is first activated |
OnStart | Once, before the first OnUpdate |
OnEnabled | Each time the component becomes active |
OnUpdate | Every frame while enabled |
OnFixedUpdate | At a fixed physics interval while enabled |
OnPreRender | Every frame, just before rendering (not called on dedicated server) |
OnDisabled | Each time the component becomes inactive |
OnDestroy | Once, when the component or its GameObject is destroyed |
OnValidate | After deserializing and after property changes in the editor |
Next steps
Components
Learn how components interact with GameObjects and each other.
Component lifecycle
Understand the exact order in which lifecycle methods fire.
Scenes and GameObjects
Explore the scene hierarchy, object parenting, and prefabs.
Hot reload
Edit code while the game is running and see changes applied instantly.