# 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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://malbersanimations.gitbook.io/animal-controller/main-components/ai/animal-brain.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
