Skip to content

Hitboxes

Hitboxes and hurtboxes for each frame of the entity’s animation, with no code: a fighter’s punch hits only on the frames its fist is out, and its head takes more than its legs. Each of its Boxes is on one frame of one clip: a hitbox (it deals damage, knockback and hitstun) or a hurtbox (where it can be hit, with a multiplier). Draw them over the frames in the Clip Editor (Art > Animation Clips). While the entity plays a frame, it has that frame’s boxes, mirrored as its sprite is flipped, and one of its hitboxes touching another’s hurtbox is a hit: the hurtbox’s Health takes the damage, its body flies off with the knockback, it’s in hitstun for the stun’s steps, and both send their messages. A swing hits each thing once per group, however many frames touch it.

Part of the Fighting module: Fighting games: Hitboxes, hitboxes and hurtboxes for each frame of an animation’s clips (drawn in the Clip Editor), that land hits with damage, knockback and hitstun; fighters (FightingCharacter) that walk, jump, crouch, block and do moves written in numpad notation (quarter circles, dragon punches, charges) with an input buffer, cancels and combos; a computer to fight (ComputerFighter); a CharacterSelect where players at one machine each pick their fighter, and a VersusMatch of rounds against the clock; a sparring pair and a training pair to make from the Entity menu (Genres, Fighting); and the Fighter template, a whole versus fighting game.

Things on its Layers with a Health but no boxes of their own are hit through their colliders, so a hero’s sword drawn on the frames of its swing hits a platformer’s slimes too. With an Attack (no Hitbox needed), the Attack action plays its Attack clip, whose frames hit. Hits are worked out after physics each step, frame by frame as the game steps, where the game is run (offline, or the host), so the same input always lands the same hits. Its outputs (Hit and Got Hit on the step it lands or takes one, its Hits, its Hitstun) are for a wire, a Counter or a Bar.

Works with: Animation (its clips’ frames have the boxes); Health (takes the damage of hits on its hurtboxes); Body (knockback sends it flying); Attack (its action plays the Attack clip, whose frames hit)

Needed by: FightingCharacter

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.

  • boxes: lines of text: an array of strings, or one string with line breaks = []. Its boxes, a line each: the clip and its frame (counting from 0; * for the animation’s own frames, or with no animation), hit or hurt, where it is and how big from the entity’s middle facing right, and what it does, e.g. Punch 2 hit at 0.6,0.3 size 0.5x0.25 damage 3 knockback 4,2 stun 12 or Idle 0 hurt at 0,0.7

    radius 0.3 multiplier 1.5. Draw them in the Clip Editor rather than typing them. (Boxes, a line each: the clip and its frame, hit or hurt, where and how big, and what it does, e.g. "Punch 2 hit at 0.6,0.3 size 0.5x0.25 damage 3". The Inspector lists them by clip and frame; the Clip Editor (Art > Animation Clips, the Art.Clips command) draws them over the frames.) (Field: its own editor: Frame Boxes.)
  • team: text = null. Its team, the one every genre shares (see Teams): its hitboxes hit only what isn’t on its team, so teammates don’t hit each other. Empty takes the team of whatever else puts it on one (a Team, a turn taker), or with none hits anyone else. (Names a team: this entity’s own, which other fields can name.) (Field: a name.)

  • layers: text = null. The collision layers of things it hits through their colliders, when they have a Health but no boxes of their own, e.g. “Enemy” for a hero’s sword. Empty hits only hurtboxes. (Names collision layers: their names, separated by commas.) (Field: a name.)

  • hitStop: a number = 0.05. Freezes the game for this many seconds when one of its hitboxes lands, so it hits hard. 0 for none. (Field: a number.)
  • hitSound: text = null. A sound played as one of its hitboxes lands, e.g. “Sounds/punch.wav”. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)
  • effect: text = null. A prefab spawned where a hit lands, e.g. “Sparkle”: a burst of particles, a damage number. (Names a prefab.) (Field: a name.)
  • hitMessage: text = null. A message sent with Game.Send as one of its hitboxes lands, with the damage it dealt as its data. (Names a message.) (Field: a name.)
  • gotHitMessage: text = null. A message sent as one of its hurtboxes is hit, with the damage it took as its data. (Names a message.) (Field: a name.)
  • hitstun: a whole number = 0. Steps of hitstun it has left (frames, at 60 a second): set by the stun of a hit it takes, counting down one a step. What a fighter can’t act through. Set by the game. (Field: a number.)
  • hits: a whole number = 0. How many hits its hitboxes have landed. Set by the game. (Field: a number.)
  • justHit: true or false = false. True on the step one of its hitboxes lands (for a wire into an action, which does it once). Set by the game. (Field: on or off.)
  • justGotHit: true or false = false. True on the step one of its hurtboxes is hit. Set by the game. (Field: on or off.)
  • swingClip: text = null. The clip of the swing under way (what Struck is for). Set by the game. (Plain text: the swing under way: the game sets it.) (Not sent in a network game: each machine has its own.) (Field: text.)
  • swingTime: a number = 0. How far into its clip the swing under way was last step, in seconds: a clip starting over is a new swing. Set by the game. (Not sent in a network game: each machine has its own.) (Field: a number.)
  • swingLoop: a whole number = 0. How many times a looping clip has gone round in the swing under way: each time round is a new swing. Set by the game. (Not sent in a network game: each machine has its own.) (Field: a number.)
  • struck: lines of text: an array of strings, or one string with line breaks = []. What the swing under way has hit, by group, a line each (“1 id”): it hits each thing once per group. Set by the game. (Plain text: what the swing has hit: the game writes it.) (Not sent in a network game: each machine has its own.) (Field: lines of text.)

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”).

  • Stun (done with a number, its frames: a trigger’s with, 1 without one). Puts it in hitstun for frames steps, as a hit with that stun would.
  • Recover. Ends its hitstun now.

What anything can read with no code: a Counter’s, Bar’s or Text’s output, a Contraptions Wire’s output as its signal; Text shows names too, the rest read numbers, true as 1.

  • Hitstun (a whole number). Steps of hitstun it has left (frames, at 60 a second): set by the stun of a hit it takes, counting down one a step. What a fighter can’t act through. Set by the game.
  • Hits (a whole number). How many hits its hitboxes have landed. Set by the game.
  • Hit (true or false). True on the step one of its hitboxes lands (for a wire into an action, which does it once). Set by the game.
  • GotHit (true or false). True on the step one of its hurtboxes is hit. Set by the game.
  • Stunned (true or false). True while it’s in hitstun.

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

  • stunned: true or false. True while it’s in hitstun.

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