dacha
    Preparing search index...

    Class Interpolation

    Component that smooths rendering of actors moved during fixed updates.

    Interpolator keeps local-space snapshots of the actor's Transform around each fixed step and blends them into the render-facing renderX/renderY/renderRotation values every render frame using Time.alpha. The renderer prefers these values over the Transform.

    The Transform component always holds the authoritative simulation state. Interpolated values are only visible to the renderer and to consumers of InterpolatorAPI, so simulation code can never accidentally read a visually smoothed but physically incorrect position.

    actor.setComponent(new Interpolation({ mode: 'interpolate' }));

    // After teleporting the actor, skip smoothing for the jump:
    actor.getComponent(Transform).world.position.x = 500;
    actor.getComponent(Interpolation).snap();

    Hierarchy (View Summary)

    Index
    _currRotation: number

    Local-space rotation from the latest fixed step

    _currX: number

    Local-space position X from the latest fixed step

    _currY: number

    Local-space position Y from the latest fixed step

    _initialized: boolean

    Whether snapshots have been initialized since (re)enabling

    _prevRotation: number

    Local-space rotation from the previous fixed step

    _prevX: number

    Local-space position X from the previous fixed step

    _prevY: number

    Local-space position Y from the previous fixed step

    _snapRequested: boolean

    Whether smoothing should be skipped at the next opportunity

    actor?: Actor
    disabled: boolean

    Whether smoothing is turned off. The renderer falls back to Transform.

    How render values are produced. interpolate blends between the last two fixed steps (smooth, adds up to one fixed step of visual latency). extrapolate projects the latest step forward using the rigid body velocity (no added latency, may briefly overshoot on impacts).

    extrapolate uses the world-space rigid body velocity against local-space snapshots, so it is intended for root-level actors.

    renderRotation: number

    Render-facing local-space rotation, written by Interpolator

    renderX: number

    Render-facing local-space position X, written by Interpolator

    renderY: number

    Render-facing local-space position Y, written by Interpolator

    snapThreshold: number

    Maximum distance in world units treated as continuous movement between two fixed steps. Larger jumps snap instead of gliding. 0 disables the automatic snap detection.

    componentName: string
    • get initialized(): boolean

      Whether the render-facing values hold a valid snapshot yet. false until the Interpolator takes its first snapshot after the component is (re)enabled.

      Returns boolean

    • Requests an immediate jump to the Transform instead of smoothing towards it. Call right after teleporting the actor.

      Returns void