> For the complete documentation index, see [llms.txt](https://malbersanimations.gitbook.io/animal-controller/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://malbersanimations.gitbook.io/animal-controller/main-components/ai/animal-brain.md).

# Animal Brain

## Overview

The Animal brain component is used to give life to animals that are not controlled by player Input.

It is heavily based on the Unity Tutorial: [**Pluggable AI with Scriptable Objects**](https://youtu.be/cHUXh5biQMg)

Based on[ **AI States**](/animal-controller/main-components/ai/animal-brain/ai-states.md) and [**Decisions** ](/animal-controller/main-components/ai/animal-brain/decisions.md)you can give [**Tasks** ](/animal-controller/main-components/ai/animal-brain/tasks.md)to the animal to wander, attack the player on sight , be your companion.. etc.

<figure><img src="/files/32bHwls47KGFnt8u663D" alt=""><figcaption></figcaption></figure>

## Parameters

### Eyes

Reference for a GameObject that it will be used on Tasks and decisions alike to cast rays  and execute logics using a reference point.

### Current AI State

Starting AI State the brain will execute

### Transition Cool Down

Time needed to make a new transition. Necessary to avoid Changing to multiple States in the same frame

### Remove AI on Death

Removes all AI Components when the Animal Dies. (Brain, AiControl, Agent).

## Events

<figure><img src="/files/WGvDwehmcumB3jntUSTq" alt=""><figcaption></figcaption></figure>

### On AI State Changed

Invoked when a new State starts. It uses the AI State ID as parameter

### On Task Started

Invoked when a new Task starts. It uses the AI State ID as parameter.

It is only Invoked if the Task ID is different of zero\[0].

### On Task Done

Invoked when a task has completed. It uses the AI State ID as parameter

### On Decision Succeeded

Invoked when a decision succeeded. It uses the AI State ID as parameter.

## Debug

<figure><img src="/files/tg0nGoQfLAwPz69R3ZPR" alt=""><figcaption></figcaption></figure>

### Debug On Screen

Shows the debug window on the screen for the animal when playing:<br>

<figure><img src="/files/znhahxq6RZshmGubBVia" alt=""><figcaption></figcaption></figure>
