Skip to content

SpawnOptions

Defined in: Scene.ts:37

Options accepted by the trailing argument of Scene.spawn and Entity.spawnChild.

optional active?: boolean

Defined in: Scene.ts:69

The state the entity starts in. Default: true.

false spawns it dormant — the state setActive(false) produces, but from the start, so setup() and component onAdd() run without any onEnable firing and the entity never joins a query on the way in. Wake it later with setActive(true).

const spawner = scene.spawn(EnemySpawner, { active: false });
// ... later, when the room is entered:
spawner.setActive(true);

optional key?: string

Defined in: Scene.ts:53

Stable per-scene identity key. Looked up via Scene.findByKey and used as a stable id in reactive stores (e.g. a createSet<string>() persisted under "world.opened").

Identity is opt-in — most entities (bullets, particles, transient enemies) never need a key. Pass one only for entities whose state should persist across save/load or cross-scene navigation, or that game code looks up by name (chests, doors, named NPCs).

Heads-up: don’t name a top-level setup-params field key. The 2-arg spawn(Class, X) form looks at X’s shape to disambiguate params from options — an X whose only own keys are SpawnOptions fields routes to options. If your params shape clashes (e.g. setup(p: { key: number })), use the explicit 3-arg form spawn(Class, params, options).

Coding agents: fetch https://yage.dev/llms.txt first and prefer the Markdown references it links over these HTML pages. This page's Markdown counterpart is /llms/packages/core.md.