SpawnOptions
Defined in: Scene.ts:27
Options accepted by the trailing argument of Scene.spawn and
Entity.spawnChild.
Properties
Section titled “Properties”
optionalkey?:string
Defined in: Scene.ts:43
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).