Skip to content

FightingCharacter

A fighting game’s fighter with no code: walks forward and back, jumps (up, forward or back) and crouches on the directions, faces its opponent by itself, and does its Moves, each written in numpad notation (5P a standing punch, 2K a crouching kick, 236P a quarter circle forward and punch, 623P a dragon punch, [4]6P a charge) and played from an animation clip whose hitboxes (drawn in the Clip Editor) are the part that hits, over the startup, active and recovery frames the move gives. Holding back blocks: a blocked hit does only chip damage and holds it in blockstun, and lows must be blocked crouching, overheads standing. A hit holds it in hitstun (its Hitboxes’ Hitstun), where it can do nothing, and the hits an opponent lands while it’s still stunned count up as a combo. A button pressed a few frames early still comes out the moment it can (the input buffer), and moves cancel into the ones they’re allowed to once they’ve connected. Edit its moves in Entity > Edit Moves, or keep them in a table.

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.

It plays its Animation’s Idle, Walk (or Run), WalkBack, Crouch, Jump, Block, CrouchBlock and Hurt clips when it has them, and KO (or Hurt) once its Health runs out, doing nothing more. Everything is counted in steps (frames, at 60 a second) and kept with the scene, so the same input does the same thing every time, and a rewind carries on mid-motion and mid-move. It reads the controls of whoever plays it; in a network game the host runs it, as it lands every hit.

Requires: Body; Collider; Hitboxes

Works with: Animation (plays each move’s clip, and Idle, Walk, Crouch, Jump, Block and Hurt); Health (takes the damage of hits, and chip damage of blocked ones)

Needed by: ComputerFighter

Takes the player’s input only while it has focus (its Controllable): its Focus action hands it the input and takes it from everything else the same player plays.

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.

  • moves: lines of text: an array of strings, or one string with line breaks = []. Its moves, a line each: a name and a colon, the input in numpad notation as the fighter faces right (6 forward, 2 down, 5 neither; j. in front for the air; [4] for back held as a charge), then any of clip Name (the clip it plays: its name without spaces if left out), frames 3/2/6 (steps of startup, active and recovery; left out, the clip’s own speed), low or high, blockstun 10, chip 0.25, push 2,0 (forward and up as it hits), message Name, sound Path and last cancels special (or move names). E.g. Jab: 5P frames 3/2/6 cancels special, Fireball: 236P frames 12/4/30. When two fit, the longer motion wins, then the one whose last direction came nearest the button, then the one listed first. (Moves, a line each: a name and a colon, the input in numpad notation (236P), then clip, frames startup/active/recovery, low or high, blockstun, chip, push, message, sound and cancels, e.g. “Fireball: 236P frames 12/4/30”. The Inspector lists them with their inputs as arrows; the Move List (Entity > Edit Moves, the Fighting.EditMoves command) edits them.) (Field: its own editor: Move List.)
  • movesTable: text = null. A table of more moves, a row each, after its own: the row’s name, and columns Input, Clip, Startup, Active, Recovery, Hits (Low or High), Blockstun, Chip, Push, Cancels, Message and Sound. Empty for its own moves only. (Names a table.) (Field: a name.)
  • buttons: text = “P Punch, K Kick”. The buttons its moves name and the input action each is, e.g. “P Punch, K Kick” or “L Light, M Medium, H Heavy” (with those actions added in Controls). Up to eight. (Buttons and the input action each is, separated by commas: a letter its moves name and the action, e.g. “P Punch, K Kick” (up to eight). The Inspector lists them a row each with the action picked from the game’s.) (Field: its own editor: Buttons.)
  • opponent: text = null. Who it fights, by name: it faces them. Empty for the nearest other fighter not on its team. (Names an entity.) (Field: an entity’s name.)
  • faceOpponent: true or false = true. Turns to face its opponent whenever it’s on the ground and free, so forward is always towards them. (Field: on or off.)
  • walkSpeed: a number = 3. How fast it walks forward, in units a second. (Field: a number.)
  • backWalkSpeed: a number = 2.4. How fast it walks back, in units a second. (Field: a number.)
  • jumpHeight: a number = 2.6. How high a jump goes, in units. 0 can’t jump. (Field: a number.)
  • jumpSpeed: a number = 3.5. How fast a jump forward or back goes sideways, in units a second. (Field: a number.)
  • friction: a number = 30. How quickly it stops sliding on the ground (after a knockback or a push), in units a second per second. (Field: a number.)
  • holdBackToBlock: true or false = true. Holding back (away from the opponent) blocks; down-back blocks crouching. Off, it never blocks unless AutoBlock says. (Field: on or off.)
  • autoBlock: one of Never, Standing, Crouching, Always = “Never”. Blocks by itself: never, everything standing, everything crouching, or always (for a training dummy). (Field: one of its values.)
  • chipDamage: a number = 0.1. How much of a blocked hit’s damage it still takes (chip damage), 0 to 1. A move’s own chip says otherwise. (Field: a number.)
  • blockPushback: a number = 0.5. How much of a hit’s knockback a blocked one still pushes it back with, 0 to 1. (Field: a number.)
  • blockSound: text = null. A sound played as it blocks a hit, e.g. “Sounds/block.wav”. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)
  • blockEffect: text = null. A prefab spawned where a blocked hit meets it: a spark. (Names a prefab.) (Field: a name.)
  • blockMessage: text = null. A message sent as it blocks a hit, with the chip damage as its data. (Names a message.) (Field: a name.)
  • bufferFrames: a whole number = 8. How many steps (frames, at 60 a second) a press is remembered: one made that early still comes out the moment it can (as a move ends, or lands), once. 1 takes only presses made as it can act. (Field: a number.)
  • motionFrames: a whole number = 16. How many steps a motion (a quarter circle, a dragon punch) may take, from its first direction to the button. (Field: a number.)
  • chargeFrames: a whole number = 40. How many steps a charge must be held (back for [4]6P, down for [2]8K) before it’s let go. (Field: a number.)
  • controllable: true or false = true. Untick it to ignore the player’s input (a training dummy, a cutscene); it still blocks by AutoBlock, and its Perform action still does moves. Its Focus action ticks it and unticks it on everything else the player plays. (Field: on or off.)
  • move: text = null. The move it’s doing, by name; empty when it’s free. Set by the game. (Plain text: the move under way: the game sets it.) (Field: text.)
  • moveFrame: a whole number = 0. Steps into the move it’s doing. Set by the game. (Field: a number.)
  • connected: true or false = false. True once the move it’s doing has hit or been blocked: what lets it cancel. Set by the game. (Field: on or off.)
  • blockstun: a whole number = 0. Steps of blockstun it has left: after blocking a hit, it can do nothing else until they’re up. Set by the game. (Field: a number.)
  • crouching: true or false = false. True while it’s crouching. Set by the game. (Field: on or off.)
  • held: true or false = false. True while something holds it still and deaf to its controls (a versus match before a round’s “Fight!” and after its K.O.): it stands, falls and recovers, but walks, jumps, blocks by hand and starts no moves. Set by the game. (Field: on or off.)
  • blocking: true or false = false. True while it’s blocking: holding back on the ground and free, or in blockstun. Set by the game. (Field: on or off.)
  • justBlocked: true or false = false. True on the step it blocks a hit. Set by the game. (Field: on or off.)
  • combo: a whole number = 0. How many hits its current combo has: each hit it lands while the one it’s hitting is still in hitstun from the last adds one; it’s 0 again once they recover (ComboHits shows it from the second hit on). Set by the game. (Field: a number.)
  • comboDamage: a number = 0. The damage its current combo has done. Set by the game. (Field: a number.)
  • bestCombo: a whole number = 0. The longest combo it has landed. Set by the game. (Field: a number.)
  • onGround: true or false = true. True if it stood on something after the last step’s physics: what it walks, jumps and blocks by (kept with the scene, so a rewind knows it’s on the ground before physics has run again). Set by the game. (Not sent in a network game: each machine has its own.) (Field: on or off.)
  • comboOn: text = null. Who its combo is on (an id). Set by the game. (Plain text: who its combo is on: the game sets it.) (Not sent in a network game: each machine has its own.) (Field: text.)
  • history: text = “”. What it has pressed lately, oldest first: a direction a step as it faced (with any buttons pressed then), a run of the same written once with how many (“5*40 2 3 6P”). What motions and the input buffer read. Set by the game. (Plain text: what was pressed lately: the game writes it.) (Not sent in a network game: each machine has its own.) (Field: 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”).

  • Perform (done with a name, its move: a trigger’s with). Does the move called move next step if it’s free then, as if its input were pressed: for a trigger, a wire or a computer player.
  • ResetCombo. Ends its combo count (the HUD’s “hits” goes back to 0).
  • NextAutoBlock. Changes its AutoBlock to the next: Never, Standing, Crouching, Always, and round again (a training dummy’s guard).
  • Focus. Gives its entity the player’s input: whatever there and inside it has focus, and everything else the same player plays loses it (a platformer’s player stops on the arrow keys while a board takes them).

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.

  • AutoBlock (a name). Its AutoBlock in words, for a training menu’s label: “Never”, “Standing”, “Crouching” or “Always”.
  • Move (a name). The move it’s doing, by name; empty when it’s free. Set by the game.
  • Blockstun (a whole number). Steps of blockstun it has left: after blocking a hit, it can do nothing else until they’re up. Set by the game.
  • Crouching (true or false). True while it’s crouching. Set by the game.
  • Held (true or false). True while something holds it still and deaf to its controls (a versus match before a round’s “Fight!” and after its K.O.): it stands, falls and recovers, but walks, jumps, blocks by hand and starts no moves. Set by the game.
  • Blocking (true or false). True while it’s blocking: holding back on the ground and free, or in blockstun. Set by the game.
  • Blocked (true or false). True on the step it blocks a hit. Set by the game.
  • Combo (a whole number). How many hits its current combo has: each hit it lands while the one it’s hitting is still in hitstun from the last adds one; it’s 0 again once they recover (ComboHits shows it from the second hit on). Set by the game.
  • ComboHits (a whole number). Its combo’s hits for a HUD: from the second hit on (one hit is no combo yet), 0 before.
  • ComboDamage (a number). The damage its current combo has done. Set by the game.
  • BestCombo (a whole number). The longest combo it has landed. Set by the game.
  • Phase (a name). Which part of its move it’s in: Startup, Active (its hitboxes hit), Recovery, or None when it’s free.
  • Free (true or false). True while it can do something new: not in a move, hitstun or blockstun.

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

  • autoBlockName: text. Its AutoBlock in words, for a training menu’s label: “Never”, “Standing”, “Crouching” or “Always”.
  • comboHits: a whole number. Its combo’s hits for a HUD: from the second hit on (one hit is no combo yet), 0 before.
  • phaseName: text. Which part of its move it’s in: Startup, Active (its hitboxes hit), Recovery, or None when it’s free.
  • phase: one of None, Startup, Active, Recovery. Which part of its move it’s in.
  • isFree: true or false. True while it can do something new: not in a move, hitstun or blockstun.

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