Skip to content

Shooter

Fires copies of a Prefab with no code: turrets, cannons, a boss’s spread, or the player’s own gun (see Action). Each shot’s Body is sent off at Speed and it’s turned to face the way it’s going. With Beats set, it fires on the beat of a BeatClock.

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 = “Bullet”. The prefab to fire, e.g. “Bullet” (Assets/Prefabs/Bullet.prefab). It needs a Body to fly. (Names a prefab.) (Field: a name.)
  • interval: a number = 1. Seconds between shots (unless it steps to the Beats). (Field: a number.)
  • delay: a number = 0. Seconds before the first shot. (Field: a number.)
  • speed: a number = 8. How fast shots fly, in world units per second. (Field: a number.)
  • target: text = null. The name of an entity to aim at, e.g. “Player”. Empty fires in Direction. (Names an entity.) (Field: an entity’s name.)
  • direction: [x, y] = [1,0]. Which way to fire without a target (or an aim, for the player). (A direction, x right and y up: [0, 1] is up, [1, 0] right, [1, 1] up and to the right. The Inspector has a compass of the eight ways; with Distance Handles the Scene view draws it as an arrow to drag round.) (Field: its own editor: Direction.)
  • range: a number = 10. With a Target, only fire when it’s this close. 0 fires at any distance. (Only used when target is set.) (A distance: the Scene view draws it as a circle around the entity, with a handle to drag.) (Field: a number.)
  • needsSight: true or false = false. With a Target, only fire when nothing solid is in the way: no shooting through walls. (Only used when target is set.) (Field: on or off.)
  • count: a whole number = 1. Shots in each volley, fanned out across Spread. (Field: a number.)
  • spread: a number = 0. Degrees the volley fans across; with one shot, how far off aim it may randomly go. (Field: a number.)
  • offset: [x, y] = [0,0]. Where shots appear relative to the entity, in world units. (A point offset from the entity, in world units: with Distance Handles the Scene view puts a knob on it to drag.) (Field: a vector.)
  • sound: text = null. A sound played with each volley, e.g. “Sounds/shoot.wav”. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)
  • action: text = null. An input action, e.g. “Fire”: it then fires only while the player holds it, towards the right stick or the mouse (or Direction when neither aims anywhere). Empty fires by itself. (Names an input action.) (Field: a name.)
  • running: true or false = true. Untick it to hold fire. Switches tick and untick it. (Field: on or off.)
  • beats: a whole number = 0. Steps to the music of a BeatClock: fires on every this many beats instead of every Interval seconds, once Delay has passed (and, with an Action, while it’s held). 0 goes by seconds. (Field: a number.)
  • beatOffset: a whole number = 0. Steps this many beats later: with two turrets 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”).

  • Fire. Fires one volley now, running or not: at its Target if it has one in the scene, otherwise its way.

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