# AI Animal Control

## Overview

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F6NVt8rPNQdpWClifouz7%2Fimage.png?alt=media&#x26;token=abf763d5-5218-4c50-9d22-427785e2b688" alt=""><figcaption></figcaption></figure>

This component is the bridge between the Animal Controller with the Unity  Navmesh system.&#x20;

The Animal uses the function `Move(Vector3 Direction)` to move around.&#x20;

This component moves the animal by using a target *Position* or *Transform*. It gets the Direction of the Navmesh Agent's desired Velocity and feeds it into the Animal controller.

It is a basic way to move the animal around in an environment, using all the rules of a Navmesh like jumping, falling from a cliff or staying on the Navmesh. It can also interact automatically with Zones.

## Requirements

* The component needs a Navmesh Agent.

![](https://963537199-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lzhr1XSMzMqNXjRnNlb%2F-MYqCRgneXvtmm-tBkt0%2F-MYqE5T0VBaR17R0IEvk%2Fimage.png?alt=media\&token=8bb36217-bea0-42e0-a6a6-ddb7d650fe2d)

* Since the animals have the Pivot of the Root Gameobject on the center of the back feet; it is better to have all the AI Components in a Child Object and move it to the front feet of the Animal.

{% embed url="<https://streamable.com/8pkbtr>" %}

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FqfdGOMAbRlCx5VWpCvTM%2Fimage.png?alt=media&#x26;token=c23c4b1a-13d2-4146-85dd-82ec93dcb23b" alt=""><figcaption></figcaption></figure>

## Parameters \[General]

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F7m8TYhnBvvOt3G7HOc50%2Fimage.png?alt=media&#x26;token=cb6647b9-35e8-4f33-8ac5-b4833cd3d5ba" alt=""><figcaption></figcaption></figure>

### Targets

### Target

The Transform reference used to calculate the direction to move.

### Next Target

Reference of the Next Target stored, (given by the target) when the animal arrives at the current target.

### AI Parameters

### Update Agent

How often the path for the agent should be recalculated - lower numbers mean less performance.

### Stopping Distance

Default stopping distance the Animal will use to arrive at a Target. **Waypoints** and **AI Targets** will have their own stopping distance value.&#x20;

{% hint style="info" %}
You can add the **AI Target** component to any other Object to override this default value.
{% endhint %}

### Slowing Distance

Distance to start slowing the animal before arriving at the destination

### Look at Offset

Distance from the Animals root to apply the LookAt Target logic when the animal arrives to a target

### Point Stop Distance

Stop Distance used on the SetDestination method. This is commonly used on the Point Click component.

### Slowing Limit

Limit for the Slowing Multiplier to be applied to the Speed Multiplier

### Wait Time Multiplier

Multiplier used for Waypoints Wait time. Set it to 0 if you want to ignore waiting on waypoints.

### Disable Input

If **true** then it disables the input component on the animal. This will avoid the AI and Player Input to fight over controlling the Character

## References

### Animal

Reference for the Animal Component

### Agent

Reference for the Nav Mesh Agent

### Stop Agent On

Allows you to determine specific **states** to Stop the Agent working on. E.g. if you have a Fall state here, then it stops the agent working on the fall state.

## Events

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FvNZPJHKQqbnlM46j6wiV%2Fimage.png?alt=media&#x26;token=65909e05-a63d-4257-bdd4-5a384d9fc35c" alt=""><figcaption></figcaption></figure>

### On Enabled

Invoked when the AI Control is enabled

### On Disabled

Invoked when the AI Control is disabled

### On Position Arrived(Vector3)

Invoked when the Animal arrives at a Target Position. E.g. When the Animal is set to a position with the Click Point Component.

### On Target Arrived(Transform)

Invoked when the Animal arrives at a Target Transform

### On New Target Set(Transform)

Invoked when is Assigned a new Target.

## Debug

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FyvuKxdnzHxo8Fobt4Msr%2Fimage.png?alt=media&#x26;token=8554bce4-650b-47bf-b1f1-60bef4e954b5" alt=""><figcaption></figcaption></figure>

When the Editor is Playing all internal variables are shown. This is perfect for debugging the AI main Parameters.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FNTti0wouVEmLpq9MdvAk%2Fimage.png?alt=media&#x26;token=4c40eecc-98cf-417b-8e7c-507b8b1b0245" alt=""><figcaption></figcaption></figure>

### Console

Print to the console all the Notifications of the Animal AI Control.

### In-Game Log

Shows in the scene on top of each AI animal the main values while using the component

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F1vXHyaWKc5KtpnBGiuFT%2Fimage.png?alt=media&#x26;token=89990741-c653-46cf-a5e6-f335f3fb61b8" alt=""><figcaption></figcaption></figure>

### Gizmos

Shows on the Scene all the gizmos of the Animal AI Control
