Skip to content

BoxCollider

A box for collisions, centered on the entity (plus Offset) and scaled by its transform. It stays upright whatever the entity’s rotation, unless its BodyBody.Rotates: then it turns with the entity. Without a Body the box is static: walls, floors, platforms.

Works with: Body (to make it move and fall)

Needed by: Block, Body, Bouncer, Breakable, Bumper, Checkpoint, Crumble, DamageOnTouch, Dialogue, Door, Drain, FightingCharacter, FirstPersonMovement, GridMovement, Ladder, Lane, Patrol, Pickup, PlatformerMovement, Plunger, Pushable, Switch, Target, TopDownMovement, WireButton, WireSensor

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.

  • size: [x, y] = [1,1]. Width and height, in world units before the transform’s scale. (Field: a vector.)
  • offset: [x, y] = [0,0]. How far the shape’s center is from the entity, before the transform’s scale. (Field: a vector.)
  • isTrigger: true or false = false. Triggers don’t block movement; they report OnTriggerEnter/Exit instead. (Field: on or off.)
  • oneWay: true or false = false. Only blocks bodies landing on top: jump up through it from below, stand on it from above. (Field: on or off.)
  • layer: text = null. A name for what kind of thing this is, e.g. “Player”, “Enemy” or “Bullet”, for Collider.IgnoreLayers and physics queries. Empty is the “Default” layer. (Names a collision layer: this entity’s own, which other fields can name.) (Field: a name.)
  • ignoreLayers: text = null. Layers this collider passes through, e.g. “Bullet, Enemy”: no blocking, no collisions, no triggers. It works both ways, so only one side has to list the other. (Names collision layers: their names, separated by commas.) (Field: a name.)

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

  • worldShape: [[x, y], [x, y], [x, y]]. The box in the world as it is: its middle, half its width and height, and which way its own X axis points (a unit vector, (1, 0) unless it Collider.Turns; its Y axis is that turned a quarter anticlockwise).
  • worldCorners: [[x, y], [x, y], [x, y], [x, y]]. Its four corners in the world, anticlockwise from the bottom left (as it’s turned, if it Collider.Turns).
  • turns: true or false. True when the shape turns with its entity: its Body (the entity’s own, or else the nearest one it’s inside) Body.Rotates. Otherwise it stays upright whatever the entity’s rotation, as colliders always have.

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