# Creating a Pet AI

{% hint style="info" %}
**Note:** It is recommended that users have fully setup an AI's Player Tag, Animation Profile, and other basic steps before proceeding.
{% endhint %}

## Creating a Pet AI

Pet AI are intended for non-combat usage and will follow their user set Target to Follow. They cannot be detected by other AI and will not flee or attack. They have no other behavior settings other than a Target to Follow option.

To make a Pet AI, simply set the Current Behavior Type to Passive within the Behavior Component and assign the desired Target to Follow.

<figure><img src="https://content.gitbook.com/content/v03IiZPaMe8fX49a9MnO/blobs/zKbOzp0UYF1oUmlNzQjA/PetBehavior.png" alt=""><figcaption></figcaption></figure>

## Setting a Target to Follow Through Code

There are two ways to assign a Target to Follow through code, if desired.

### Through the EmeraldAPI

The first method is to assign a Target to Follow through the static EmeraldAPI class. The TransformToFollow would be the target you would like the owner of the EmeraldComponent to follow.

```csharp
EmeraldSystem EmeraldComponent = GetComponent<EmeraldSystem>();
EmeraldAPI.Detection.SetTargetToFollow(EmeraldComponent, TransformToFollow);
```

### Through the Detection Component

The second method is through the AI's own detection component. The TransformToFollow would be the target you would like the owner of the EmeraldComponent to follow.

```csharp
EmeraldSystem EmeraldComponent = GetComponent<EmeraldSystem>();
EmeraldComponent.DetectionComponent.SetTargetToFollow(TransformToFollow);
```


---

# 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://black-horizon-studios.gitbook.io/emerald-ai-wiki/emerald-components-required/behaviors-component/creating-a-pet-ai.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.
