Skip to content

Pushable

A crate that bodies push along by walking into it, with no code: sideways in a platformer, any way in a top-down game (when its Body’s Gravity Scale is 0). It pushes crates in front of it in turn, and stops at walls. Needs a Body and a solid collider. Give it a layer (say “Crate”) to have it hold a pressure plate down. With a GridMovement too it’s a Sokoban crate: a grid mover stepping into it pushes it a cell (gliding along with it), unless a wall or another crate is in the way, and resting on a puzzle’s Goal covers it. A crate whose body Body.Rotates doesn’t need one: whatever walks into it knocks it along (and over), by their weights.

Requires: Body; Collider (solid, not a trigger)

Works with: GridMovement (pushed a cell at a time by grid movers); Goal (places on the grid to push it to)

Changes how its entity is drawn (a tint, a shake or drawing it on top).

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.

  • layers: text = “Player”. The collision layers that can push it, e.g. “Player”. Empty lets any body push it. (Names collision layers: their names, separated by commas.) (Field: a name.)
  • speed: a number = 0.6. How fast it goes compared to whoever pushes it: 1 is as fast, 0.5 half as fast (a heavy crate), 0 won’t budge. On a grid it always keeps pace with its pusher, and 0 still won’t budge. (Field: a number.)
  • pushesRow: true or false = false. On a grid, pushing it into another crate pushes that one too, so a row slides together. Off, a crate behind it blocks it, as in Sokoban. (Field: on or off.)
  • kind: text = null. What kind of crate it is, e.g. “Red”: a Goal’s Accepts names the kinds that cover it. (Names a crate kind: this entity’s own, which other fields can name.) (Field: a name.)

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

  • onGoal: an entity: its name, id or path. The goal it rests on, or null. Kept up to date while the game runs.
  • goalTint: a color, “#RRGGBB” or “#RRGGBBAA” or null. The color the goal it rests on turns it, drawn instead of its sprite’s own (not saved, so a rewind never keeps it).

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