Black Trigram (흑괘) - Korean Martial Arts Combat Simulator API - v0.7.11
    Preparing search index...

    Function clampToArenaBounds

    • Clamp a 2D position to stay within arena boundaries in meters.

      This function works in a projected 2D arena space where:

      • position.x corresponds to world X (horizontal)
      • position.y corresponds to world Z (depth)

      Arena coordinates are centered at origin (0, 0) and extend from -worldWidthMeters/2 to +worldWidthMeters/2 in X (position.x), -worldDepthMeters/2 to +worldDepthMeters/2 in Z/depth (position.y).

      This is used for physics calculations like knockback to ensure players stay within the playable area.

      Parameters

      • position: { x: number; y: number }

        2D projected position in meters (X, depth-as-Y), which may exceed arena bounds

      • bounds: PhysicsArenaBounds

        Arena bounds with meter dimensions

      Returns { x: number; y: number }

      Position clamped to arena boundaries in the same 2D projection

      const bounds = { worldWidthMeters: 10, worldDepthMeters: 7.5, ... };
      const position = { x: 6, y: 4 }; // Outside arena in X/Z-projected space
      const clamped = clampToArenaBounds(position, bounds);
      // Result: { x: 5, y: 3.75 } - clamped to boundaries