> For the complete documentation index, see [llms.txt](https://lightbug14.gitbook.io/ccp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lightbug14.gitbook.io/ccp/how-to.../implementation/actions/create-your-own-ai-logic.md).

# Create your own AI movement logic

When the character brain is set to AI, the actions stop being updated by the input handler (input devices). Now these actions **need to be defined by code**. This is what AI is all about, simulating a machine "pressing buttons".&#x20;

In order to set up an AI character from zero you need to:

1. **Change the brain mode to "AI"** in the *CharacterBrain* component.
2. **Add an&#x20;*****CharacterAIBehaviour*** component to the character (wherever you want).
3. **Assign the&#x20;*****CharacterAIBehaviour*** to the *CharacterBrain*.

{% hint style="info" %}
Human and AI move around using the same components, there is no need to add a NavMeshAgent or something similar. Also you don't need a NavMesh for this to work, although you can use one if you want (see the AI Follow behaviour).
{% endhint %}

## The AI behavior

The brain will read and use the `CharacterActions` data from the current AI behavior. To create an AI behavior you need to derive your class from `CharacterAIBehaviour` and implement the desired behaviour.

For example, here is a behaviour that simulate an NPC running forward:

```csharp
public class RunForwardBehaviour : CharacterAIBehaviour
{        
    // abstract (mandatory)
    public override void UpdateBehaviour( float dt )
    {
            // Run is a Bool action (e.g. a button or a key)
            characterActions.run.value = true;
            
            // Movement is a Vector2 action (e.g. WASD)
            characterActions.movement.value = new Vector2( 0f , 1f );
    }    
}
```
