UndoSystem: Per-player undo functionality
UndoSystem: Per-Player Undo Functionality This example shows the UndoSystem which provides per-player undo stacks for tracking spawned objects and allowing play…
GameObject.FindNetworkRoot() extension method
GameObject.FindNetworkRoot() Extension Method This example shows an extension method for finding the network root of a GameObject hierarchy. Usage Example Key F…
UIDecal Component - Render Razor UI as a Decal
A Render Component for s&box that allows you to project Razor UI onto surfaces as a Decal. Great for sticking UI onto rounded walls, curved surfaces, or any geo…
Sandbox: BaseConstraintToolMode — two-stage constraint creation with IToolActionEvents
BaseConstraintToolMode — Two-Stage Constraint Creation Pattern is the base for all two-point constraint tools (Weld, Rope, BallSocket, Elastic, Hydraulic, NoCol…
Prefab Spawning and Cloning
Prefab Spawning and Cloning Prefabs are reusable GameObject templates that can be instantiated at runtime. Creating Prefabs Create a GameObject in the scene wit…
Sandbox: UndoSystem — per-player undo stack with bounded history (128 steps)
UndoSystem — Per-Player Undo Stack The is a that maintains a per-player undo stack. Each entry holds a set of s that get destroyed when the undo is triggered. U…
Physics Tracing Code Examples
Physics Tracing Code Examples Raycast and shape trace examples using — the builder pattern for physics queries. TraceResult Properties Builder Pattern Methods
Sandbox: BaseCarryable — unified AimRay, WeaponModel resolution, and seat-aware damage
BaseCarryable — Unified Weapon Base with AimRay and Seat Support is the root class for all holdable items. It handles viewmodel/worldmodel management, a unified…
Reusable World-Space Interaction Prompt Framework
A small, compartmentalized interaction framework can be built from three pieces: : the base component placed on objects the player can use. : the player-side ra…
BaseWeapon and BaseCarryable Weapon Framework
BaseWeapon and BaseCarryable - Weapon Framework Base classes for creating weapons in s&box. Provides ammo management, view/world models, and input handling. Bas…
Sandbox: Ownable component — prop protection with IPhysgunEvent and IToolgunEvent
Ownable Component — Prop Protection and Physgun/Toolgun Access Control The component tracks which spawned a . It implements and to enforce ownership checks when…
Ownable Component Pattern for Prop Ownership
Ownable Component - Prop Ownership and Permission System A component that tracks which player spawned an object and enforces ownership-based permissions. Useful…
CleanupSystem Pattern for Map Reset and Scene Management
CleanupSystem - Scene State Management and Map Cleanup A that captures the baseline scene state and allows resetting the map to its original state. Removes spaw…
IPlayerControllable example: ThrusterEntity
IPlayerControllable Example: ThrusterEntity ThrusterEntity demonstrates how to implement IPlayerControllable for a thruster that responds to player input while …
VerletRope — rope physics with attachment, slack, and stiffness
VerletRope simulates rope physics using Verlet integration. The rope hangs from the GameObject's position and optionally attaches its end to another GameObject.…
Code Cheat Sheet: Quick Reference for GameObjects, Components, and Transforms
Quick reference for common s&box operations covering debugging, transforms, GameObjects, and Components. Useful when you know what you want to do but not the ex…
Camera and View Control
Working with cameras and player viewpoints in s&box. Main Camera Access Creating a Player Camera First-Person Camera Screen to World Ray World to Screen Camera …
Sandbox: ISpawner interface — custom spawner pattern with ISpawnEvents
ISpawner Interface — Custom Spawner Pattern The interface defines the contract for anything that can be spawned via the spawn menu. Implementations include , , …
Physgun Grab State with Permission Checks
Physgun Grab State Pattern Implementation pattern for physgun object grabbing with ownership checks and IPhysgunEvent permissions. Key Features Sync'd GrabState…
Sandbox: Duplicator tool — copy, paste, and save contraptions with DuplicationData
Duplicator Tool — Copy, Paste, and Save Contraptions The Duplicator tool copies a contraption (a connected graph of GameObjects) to JSON and pastes it back. It …