Character Controller Design Document


The Character Controller is the interface that allows a Player to control a Character. It consists of three separate components: the Animator, the Physics Controller, and the Character Data, which interact to turn the Player’s peripheral input into feedback in the form of in-game Character movement.


This graph depicts the flow of data between the three main components of the controller.

PhysicsController:
This component contains a custom physics loop which reads the State Variables Physics Flags to determine the Character’s location, rotation, and velocity in WorldSpace.

It was necessary to write this, instead of using Unity’s similar Rigidbody and Collider components, to remove any non-deterministic behavior and tie the Character’s movement directly to Player input. Being able to replicate movements precisely is a key part of the fighting game genre.

Animator:
Unity’s Animator component contains a state machine which can be used for more than just selecting animations. Each state or sub-state machine can contain an Animation and a number of AnimationBehavior scripts. In this Controller these behavior scripts are used to read current Character Data and determine the proper response. The InputManager and AnimatorParameterManager assist in using the Animator and AnimationBehavior scripts for this purpose.

  • InputManager: Writes Player peripheral input to Input Variables in Character Data
  • AnimatorParameterManager: Pipes Character Data to the Parameters within the Animator component. The state machine requires up-to-date Character Data in order to determine the proper transition from state to state, however it can only access these internal parameters and not the Character Data directly.
  • AnimationBehavior: Determines the actions available to the Player in a given state.

Character Data:
Data Objects which contain all information needed to determine the actions of the Player and the in-game reaction of the Character.

  • Input Variables: Current state of input for the given Character. Written to by the InputManager, read by AnimationBehavior scripts.
  • Physics Flags: Written to by the PhysicsController, read by the Animator. Contains information about the Character’s state in world space.
  • State Flags: Read/Written by the AnimationBehavior scripts within the Animator. Used to determine what actions are available to the Player. Contains cooldowns, status effects, buffer/interrupt windows, etc.
  • State Variables: Written by the Animator, read by the PhysicsController. These objects describe the physical state of Character according to the Animator’s state machine: rotation, acting forces, etc.

Files

controller-demo_02.zip 28 MB
Jul 02, 2018

Get Third-Person Fighter Prototype