Skip to content

Spawner

Spawns copies of a prefab every Interval seconds at its position, with no code: enemy waves, falling rocks, collectibles that come back. Limit it with Count and MaxAlive. With Beats set, it spawns on the beat of a BeatClock instead.

Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.

  • prefab: text = null. The prefab to spawn, e.g. “Enemy” (Assets/Prefabs/Enemy.prefab). (Names a prefab.) (Field: a name.)
  • interval: a number = 2. Seconds between spawns (unless it steps to the Beats). (Field: a number.)
  • delay: a number = 0. Seconds before the first spawn. (Field: a number.)
  • count: a whole number = 0. How many to spawn in all; 0 keeps going forever. (Field: a number.)
  • maxAlive: a whole number = 0. How many of its spawns may be around at once; 0 is no limit. When one is destroyed it makes room, and the next spawns as soon as it’s due. (Field: a number.)
  • radius: a number = 0. Spawns land at a random spot up to this far from the spawner. (A distance: the Scene view draws it as a circle around the entity, with a handle to drag.) (Field: a number.)
  • running: true or false = true. Untick it to stop spawning for now. Switches tick and untick it. (Field: on or off.)
  • needsFlag: text = null. A flag that has to be set before it starts spawning, e.g. “AlarmRaised” (set by a trigger’s Set Flag, a dialogue’s “[set AlarmRaised]” or a script’s Game.SetFlag), or “not AlarmRaised” to spawn only while it isn’t. Its count down waits until then; its Spawn action still spawns one. (Names a flag: “Name” holds while it’s set, “not Name” while it isn’t.) (Field: a name.)
  • beats: a whole number = 0. Steps to the music of a BeatClock: spawns on every this many beats instead of every Interval seconds, once Delay has passed. A spawn that has no room waits for the next. 0 goes by seconds. (Field: a number.)
  • beatOffset: a whole number = 0. Steps this many beats later: with two spawners on every 2 beats, one 1 beat later, they take turns. (Only used when beats is set.) (Field: a number.)
  • clock: text = null. The entity whose BeatClock it steps to. Empty follows the first in the scene. (Only used when beats is set.) (Names an entity.) (Field: an entity’s name.)

What anything can make it do with no code: a Trigger’s do when its message arrives, a Contraptions Wire’s input as its signal comes on, a script’s Game.Do(entity, “Name”).

  • Spawn. Spawns one now, running or not: a wave on a message, a crate from a button. Not once it has spawned its Count, or while MaxAlive of its spawns are around. Its own timing carries on as it was.

Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.

  • spawned: a whole number. How many it has spawned.
  • isFinished: true or false. True once it has spawned Count.

Scripts use it as Spawner: its methods, events and values that aren’t saved with the scene.