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…
Randomized Clothing for NPC Citizens using Dresser.Randomize() on Prefabs
Overview This demonstrates how to create NPC citizen prefabs with randomized clothing using the built-in component. Each time the prefab spawns or is enabled, i…
Multiplayer and Networking
Complete guide to multiplayer setup in s&box. Creating a Lobby Joining a Lobby Spawning Networked Players Host/Client Checks Connection Events Networked Object …
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…
WebSockets
Use WebSockets for real-time communication with external servers. Basic Setup With Auth Token Common Use Cases Custom networking — External matchmaking, chat se…
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…
PlayerInventory Weapon Switching
PlayerInventory Weapon Switching Weapon switching with host authority and IPlayerEvents delegation. Key Features Sync'd ActiveWeapon with Change callback for ne…
Sandbox: ToolMode system — creating custom Tool Gun modes
ToolMode System — Creating Custom Tool Gun Modes is the base class for all Tool Gun tools in Sandbox. Tools are components on the Toolgun and are enabled/disabl…
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…
Sync Properties for Networked State
Sync Properties for Multiplayer The attribute automatically synchronizes property values to all clients when they change. Basic Sync Sync Flags Customize sync b…
Sandbox: ControlSystem — vehicle seat and contraption control with IPlayerControllable
ControlSystem — Vehicle Seat and Contraption Control is a that drives components on contraptions. When a player sits in a , the system walks the connected contr…
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…
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 , , …
Sandbox: NPC system — Schedule, Task, and Layer architecture
NPC System — Schedule, Task, and Layer Architecture The Sandbox NPC system uses a layered architecture: Layers handle continuous behaviours (navigation, senses,…
Sandbox: Physgun — grab, freeze, launch, and pull mechanics
Physgun — Grab, Freeze, Launch, and Pull Mechanics The Physgun () is a that lets players grab, move, freeze, and launch physics objects. It uses a struct to tra…
Sandbox: LimitsSystem — server-side per-player spawn and tool limits via ConVars
LimitsSystem — Server-Side Spawn and Tool Limits is a that enforces configurable per-player limits on props, constraints, and tool entities. It listens to and .…
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 …
Sandbox: BaseWeapon — ammo system, reload, shoot delay, and IPlayerControllable
BaseWeapon — Ammo, Reloading, and Firing Pattern extends and adds ammo management, reloading, and a shoot delay system. It implements so it can also be used fro…
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…
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…