Write a code behavior
When data is not enough, write a behavior: a system factory exported from src/behaviors.ts. Every exported
function there is registered by name; list it in a scene’s systems to run it.
This one pulls nearby coins toward the player (a “magnet”), in the fixed phase so it stays deterministic:
Scene: "systems": ["platformerController", "platformerHazards", "coinMagnet"]. Behaviors run before physics.
After editing code, run validate with typecheck: true, then run_headless.
Rules of thumb: read input through the Input resource, randomness through the GameRng resource (never
Math.random), emit events with world.events.enqueue('name', payload) so rules can react, and keep component data
plain JSON.