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.

Action Graphs are s&box’s node-based visual scripting system. They let you build game logic by connecting nodes in the editor without writing C# code — and they integrate seamlessly with components, so you can call graphs from code and wire code events into graphs. This page explains the ActionGraphResource asset, how to create graphs in the editor, and how to use them from C#.

What is an Action Graph?

An Action Graph is a GameResource asset with the .action file extension. Each graph is a directed node graph — nodes represent operations (math, scene queries, component calls, flow control) and edges carry values between them. The engine provides nodes for every class and method marked with [ActionGraphNode], including the full Input API, GameObject manipulation, scene queries, and more. Graphs are serialized as JSON and loaded via the ResourceLibrary, so they hot-reload alongside your C# code.

Creating a graph in the editor

1

Open the asset browser

In the s&box editor, open the Asset Browser panel. Navigate to the folder where you want to store the graph.
2

Create the asset

Right-click in the asset browser and choose New Asset → Action Graph. The new .action file appears in the browser.
3

Open the graph editor

Double-click the .action file. The Action Graph editor opens, showing a blank canvas with an entry node.
4

Add nodes

Right-click the canvas to open the node picker. Search by name or category. Drag connections between output and input pins to link nodes together.
5

Set the graph title and description

In the graph properties panel, set Title, Description, Category, and optionally an Icon (a Material Icon name). These fields appear in the asset browser and in the DisplayInfo shown to the editor.
6

Save

Press Ctrl+S or use File → Save. The graph is serialized to the .action file.

ActionGraphResource

ActionGraphResource is the C# class that wraps a graph asset. It exposes the deserialized ActionGraph object, lazy-loaded on first access to avoid deserializing before game types are registered.
using Sandbox.ActionGraphs;

// Load a graph from the resource library
var resource = ResourceLibrary.Get<ActionGraphResource>( "graphs/my_graph.action" );

// Access graph metadata
string title = resource.Title;
string description = resource.Description;
string category = resource.Category;
string icon = resource.Icon; // Material Icon name, e.g. "account_tree"
The underlying ActionGraph object is on resource.Graph. You typically do not need to access it directly — instead, use the component integration described below.

Using graphs from component properties

The most common way to use a graph is as an Action property on a component. The editor renders an Action Graph picker for any Action-typed [Property], letting designers assign a graph without touching C#.
public sealed class DoorTrigger : Component
{
    /// <summary>
    /// Graph to run when a player enters the trigger.
    /// </summary>
    [Property] public Action OnPlayerEntered { get; set; }

    protected override void OnUpdate()
    {
        if ( SomeCondition() )
        {
            // Invoke the graph (or a C# delegate — same API)
            OnPlayerEntered?.Invoke();
        }
    }
}
The engine also exposes built-in Action properties on every Component for the standard lifecycle events:
PropertyWhen invoked
OnComponentEnabledAfter OnEnabled
OnComponentStartBefore the first OnUpdate
OnComponentUpdateEach frame, after OnUpdate
OnComponentFixedUpdateEach fixed tick, after OnFixedUpdate
OnComponentDisabledAfter OnDisabled
OnComponentDestroyAfter OnDestroy
Assign a graph to any of these properties in the inspector without writing a single line of C#.

The ActionsInvoker component

For cases where you want a pure visual-script object with no custom C# at all, add the built-in Actions Invoker component (Sandbox.ActionGraphs.ActionsInvoker). It exposes Action properties for all standard lifecycle events:
// ActionsInvoker exposes these as [Property] Action fields:
// OnEnabledAction, OnUpdateAction, OnFixedUpdateAction,
// OnDisabledAction, OnDestroyAction
Add it to any GameObject and wire graphs into its lifecycle hooks directly from the inspector.

Invoking a graph from code

If you need to invoke a graph imperatively (rather than via a property), load the resource and call through the ActionGraph API:
using Sandbox.ActionGraphs;

public sealed class CutsceneManager : Component
{
    [Property] public ActionGraphResource IntroGraph { get; set; }

    protected override void OnStart()
    {
        IntroGraph?.Graph?.Invoke( GameObject );
    }
}
ActionGraphResource.ActionGraphTargetType is typeof( GameObject ), so the graph’s execution context has access to the owning GameObject and all its components.

Calling C# from a graph

Any static method or member decorated with [ActionGraphNode] appears as a node in the picker. The engine exposes thousands of nodes this way, including the full Input API (input.down, input.pressed, input.released, input.analog.look, input.analog.move) and scene manipulation methods. To expose your own methods as nodes, add [ActionGraphNode]:
[ActionGraphNode( "mygame.spawn.projectile" ), Category( "MyGame" ), Icon( "rocket_launch" )]
public static GameObject SpawnProjectile( Vector3 origin, Vector3 direction, float speed )
{
    // ...
}
The node appears in the picker under MyGame with the icon rocket_launch.

Graph metadata fields

FieldTypeDescription
TitlestringDisplay name in the asset browser and editor
DescriptionstringShort description shown in the editor
CategorystringGroups the graph in asset browsers
IconstringMaterial Icon name (default: account_tree)

Tips and limitations

Hot-reloadable

Graphs reload when you save the .action file — no restart required. C# type changes that affect node signatures also hot-reload.

Debuggable

The Action Graph editor highlights the currently executing node when the game is running inside the editor, making it easy to step through logic visually.

No allocations for simple graphs

Graphs that use only value types and avoid closures are handled efficiently. Prefer action properties on components over runtime Invoke calls in tight loops.

Not a replacement for complex logic

Action Graphs excel at event-driven, designer-facing logic. For complex algorithms, numerical simulations, or performance-sensitive paths, write C# components instead.

Scripting basics

Writing C# components and exposing properties to the editor.

Input system

Input nodes are available directly inside Action Graphs.

Build docs developers (and LLMs) love