Character brain
CharacterBrain
is a component responsible for handling all character actions, regardless of whether they come from the player or not.
If you are familiar with the Unity's "new" input system, you probably know what an action is. An action is just a link between an input signal (e.g. press the jump button) and an output result at the gameplay level (e.g. jump).
All the available actions are predefined in a structure and then updated by the CharacterBrain component at runtime. This approach create a level of abstraction between the inputs (GetKey, GetButton, etc.) and the character actions themselves (jump, move forward, etc.).
Actions
Types
CCP's Implementation supports three types of actions
Note that the BoolAction value is true or false (a bool). If you need to know if that action was "started" or "canceled" (e.g. was the jump button pressed?), you need to get the Started or Canceled property respectively.
Character actions struct
These actions are predefined and grouped together inside a struct. Each public field represents a particular action.
You can visualize the actions values in runtime in the inspector (Human or AI).
CCP includes a ScriptableObject asset whose only job is to modify this CharacterAction struct. The actions included by default were generated using the Default Character Actions asset.
Have in mind that adding/removing actions might affect the scripts from the Demo content since these scripts are using the default CCP actions.
Brain types
Human brain
If the brain is set to Human, actions will get updated based on input devices (keyboard, mouse, joystick, UI, etc). The component responsible for this is called InputHandler
, and it must be implemented specifically for each input system needed.
By default, the brain allows the user to use two input handlers that come with the asset, or a custom one.
AI brain
In this mode, the brain defines actions through code by using a AIBehaviour
.
Last updated