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
Clamp a 2D position to stay within arena boundaries in meters.
This function works in a projected 2D arena space where:
position.xcorresponds to world X (horizontal)position.ycorresponds 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.