CMCharacter Modules 0.1.0

How a character works

A character is a GameObject with a Character Motor, and one child GameObject per module.

Every step, at a fixed rate (60 steps a second for third-person characters, 125 for the arena shooter):

  1. A command source reads the input: where to move, where to look, which buttons are held. A player, a bot and a test are the same to the character.
  2. The sensors look at the world: the ground under the feet, the water, ladders and triggers around.
  3. The motor asks every state whether it may run, and runs the highest-priority one. A state owns the body: it decides the velocity.
  4. The modifiers adjust: they forgive a late jump, add speed to a running jump, keep the character on the ground.
  5. The solver moves the character's hull (its collision shape) through the level, sliding along walls and stepping up stairs.

Because every step is the same length, the same input always gives the same result. A recorded run replays exactly, and the gyms' bots can test a jump to the centimetre.

KindWhat it doesExamples
Command sourceTurns input into commands.Input System Command Source
HullThe character's collision shape.Capsule Hull, Box Hull
SolverMoves the hull through the level.Step Slide Solver
SensorReads the world.Hull Ground Sensor, Trigger Sensor
StateA mode or an action; one runs at a time.Walk, Jump, Ledge Grab
ModifierChanges states, never owns the body.Coyote Time, Sprint
GameplayHealth, damage, respawning.Health, Fall Damage
PresentationWhat the player sees.Third Person Orbit, Facing Visual

Additional resources