Skip to main content

Controller

One per character that is staggering, ragdolled or getting up, on every peer. Stagger creates them through a Binder and hands each a Trove that is cleaned when the stagger ends or the character leaves.

Only the driver does real work: the network owner of the character, which is the player's own client for player characters and, for NPCs, the client of the nearest player (the server when nobody is near). The driver runs the Balance model every Heartbeat, turns it into Humanoid:Move pulses (the little catch-up steps), writes the procedural pose into each joint's Transform during PreSimulation (leaning, arms out, leg swings, head counter-rotation), and reports the outcome. Other peers hold the controller only so Stagger.GetState and the signals work; they see the result through ordinary physics replication.

You do not construct these yourself; read them with Stagger.GetController.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Called by the Binder. `rig` is what the Binder's predicate returned.",
            "params": [],
            "returns": [],
            "function_type": "static",
            "private": true,
            "source": {
                "line": 92,
                "path": "packages/src/Stagger/Controller.luau"
            }
        },
        {
            "name": "SetDriver",
            "desc": "Tells the controller who simulates the character: `nil` for the server (or the character's\nown player), a Player for an NPC driven by that player's client. [Stagger] calls it as the\nstate packets arrive, before [Controller:SetState].",
            "params": [
                {
                    "name": "driver",
                    "desc": "",
                    "lua_type": "Player?"
                }
            ],
            "returns": [],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 624,
                "path": "packages/src/Stagger/Controller.luau"
            }
        },
        {
            "name": "SetState",
            "desc": "Moves the controller into `state`, tearing down what the previous state set up on this peer.\nCalled by [Stagger] on every peer as the server's state packets arrive.",
            "params": [
                {
                    "name": "state",
                    "desc": "",
                    "lua_type": "State"
                },
                {
                    "name": "payload",
                    "desc": "Required when entering Staggering: direction, seed, intensity, preset and config.",
                    "lua_type": "Payload?"
                }
            ],
            "returns": [],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 646,
                "path": "packages/src/Stagger/Controller.luau"
            }
        },
        {
            "name": "Destroy",
            "desc": "Cleaned by the Binder's Trove; re-enables controls if this peer disabled them.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 823,
                "path": "packages/src/Stagger/Controller.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Controller",
    "desc": "One per character that is staggering, ragdolled or getting up, on every peer. [Stagger]\ncreates them through a [Binder](/api/Binder) and hands each a Trove that is cleaned when\nthe stagger ends or the character leaves.\n\nOnly the **driver** does real work: the network owner of the character, which is the\nplayer's own client for player characters and, for NPCs, the client of the nearest player\n(the server when nobody is near). The driver runs the\n[Balance] model every `Heartbeat`, turns it into `Humanoid:Move` pulses (the little\ncatch-up steps), writes the procedural pose into each joint's `Transform` during\n`PreSimulation` (leaning, arms out, leg swings, head counter-rotation), and reports the\noutcome. Other peers hold the controller only so [Stagger.GetState] and the signals work;\nthey see the result through ordinary physics replication.\n\nYou do not construct these yourself; read them with [Stagger.GetController].",
    "source": {
        "line": 19,
        "path": "packages/src/Stagger/Controller.luau"
    }
}