Skip to content

@temporary-escape/mod-sdk / findRandomFreePositionOutward

Function: findRandomFreePositionOutward() ​

ts
function findRandomFreePositionOutward(
   scene: Scene, 
   rng: Random, 
   radius: number, 
   center: Vector3f, 
   distance: number
): Vector3f | null;

Defined in: placement.ts:76

Placement away from a point: picks a random position on a sphere that does not overlap any existing collision body, starting at distance from center. When a whole ring is occupied (e.g. the centre is inside an asteroid field) the next ring is further out, so the search keeps expanding. Use this for spawning relative to a point (a command, a player) rather than filling a known region.

radius is the clearance sphere tested at each candidate. Deterministic for a given RNG stream, so pass a seeded Random when the result must be reproducible.

Returns null when every ring is occupied.

Parameters ​

ParameterType
sceneScene
rngRandom
radiusnumber
centerVector3f
distancenumber

Returns ​

Vector3f | null