Small World Engine API Reference - v0.78.00
    Preparing search index...

    Interface StageMovementBehaviorOptions

    Configuration options for StageMovementBehavior.

    interface StageMovementBehaviorOptions {
        customUvToWorld?: (u: number, v: number) => StageWorldPlacement;
        facingOffset?: number;
        input: InputInterface;
        onStateChange?: (state: "IDLE" | "WALK" | "RUN") => void;
        onZoneChange?: (zone: StageZone) => void;
        projection: StageProjection;
        rotationSpeed?: number;
        runMultiplier?: number;
        speed?: number;
        startFacing?: "back" | "front" | "left" | "right";
        startFacingNudge?: number;
        startUV?: { u: number; v: number };
        zones?: StageZone[];
    }
    Index
    customUvToWorld?: (u: number, v: number) => StageWorldPlacement

    Only consulted when projection.mode === "custom" -- required in that case (the constructor throws otherwise), ignored for "flat-plane". Not serialized by WorldWriter: a closure can't round-trip through glTF, so a "custom" scene is loadable but not re-saveable with its original projection intact (see StageProjection's own doc comment).

    facingOffset?: number

    Constant radians added to every computed facing angle, to re-center this behavior's "0 = facing -Z (the engine's forward convention, and directly toward the camera when the scene's camera looks down -Z)" assumption onto whichever direction a specific character asset's neutral pose (rotation.y = 0) actually faces. Mixamo/FBX-derived rigs frequently don't face -Z at rest -- e.g. the flakturm-tunnel scene's rig faces along local X instead, needing Math.PI / 2 here, confirmed by directly forcing rotation.y through 0/±90/180 and observing which one actually shows the character's front. Defaults to 0 (no correction needed) for a rig that IS authored facing -Z.

    Input interface to query keys.

    onStateChange?: (state: "IDLE" | "WALK" | "RUN") => void

    Callback fired when character transitions between locomotion states.

    onZoneChange?: (zone: StageZone) => void

    Callback fired when character moves into a different stage zone.

    projection: StageProjection

    Declarative stage-space-to-world mapping -- see StageProjection. Deliberately NOT a camera unprojection -- a simple, fixed, artist-tunable formula (e.g. linear), so dragging zone points on screen never risks the numerical blowup a real perspective inverse has near the camera's horizon.

    rotationSpeed?: number

    Rotation smoothing speed in radians per second (default: 10.0).

    runMultiplier?: number

    Speed multiplier when holding Shift to run (default: 2.0).

    speed?: number

    Movement speed in normalized stage-space (u, v) units per second (default: 0.15).

    startFacing?: "back" | "front" | "left" | "right"
    startFacingNudge?: number

    Extra radians added only to the INITIAL facing angle (on top of startFacing/facingOffset), never to angles computed from movement. Purely cosmetic: a startFacing that lands the character's stance exactly in line with a fixed, non-orbitable camera (e.g. dead-on from behind) can make one leg fully self-occlude the other in the idle pose -- correct geometry, but a jarring first impression since a fixed camera never lets the player see past it. A few degrees of nudge breaks that exact alignment without otherwise changing the intended starting orientation. Defaults to 0 (no nudge).

    startUV?: { u: number; v: number }

    Starting stage-space position (default: { u: 0.5, v: 0.5 }).

    zones?: StageZone[]

    Walkable stage zones defining the navigation mesh, in normalized (u, v) space.