# \[Old Versions] How to use Enemies AI

## Standard first steps to use Character AI

1- [Create a JU Character in Simple Setup](/ju-tps-documentation/quick-start/how-to-create-a-ju-character-reskin-default-character-setup-new-characters.md#creating-a-ju-character)

2- Turn on [IsAI option](/ju-tps-documentation/quick-start/how-to-create-a-ju-character-reskin-default-character-setup-new-characters.md#controller-options) and <mark style="color:yellow;">**set tag**</mark> to Enemy(<mark style="color:yellow;">or any other tag that is not "Player"</mark>)

3- Add a **JU Health** component and **JU Inventory**

4- [Bake a NavMesh ](https://docs.unity3d.com/Manual/nav-BuildingNavMesh.html)

**Your JU Character is now an NPC who can die and also keep items.**

## Hit Box

To be able to deal damage by punches, make the Hitbox setup:

<div align="center"><figure><img src="/files/Bu0fh8GFHo1M1PFGsdvz" alt=""><figcaption></figcaption></figure></div>

Adjust the size of the hit boxes the way that best fits your character

## Zombie AI

The Zombie AI component makes the character walk to a destination or a Waypoint, follow the player and attack him with punches. Your character doesn't necessarily have to be a zombie, you can use this script to make an aggressive NPC for example.

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

As you can see in the GIF above, it only takes 3 clicks to setup a zombie enemy.

You can also adjust the parameters below to better adapt to what you want

| Default AI Class Parameters                                       | Description                                                                                              |
| ----------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| Destination                                                       | Destination                                                                                              |
| Waypoint Path                                                     | Waypoint Path                                                                                            |
| Distance To Finish One Point                                      | Distance to go to next waypoint/path index                                                               |
| Check Nearest Point On Part                                       | Checks the nearest point on the waypoint/path and prevents the AI from going back to a previous Waypoint |
| On Start Path \[<mark style="color:blue;">Unity Event</mark>]     | Event called when AI start path                                                                          |
| On Following Path \[<mark style="color:blue;">Unity Event</mark>] | Event called when AI walk along the path                                                                 |
| On Ended \[<mark style="color:blue;">Unity Event</mark>]          | Event called when AI reaches the end                                                                     |

| Zombie AI Parameters                                                  | Description                                                     |
| --------------------------------------------------------------------- | --------------------------------------------------------------- |
| Target Tags                                                           | Filter targets by tags                                          |
| Field Of View                                                         | AI field of view, it is by this sensor that will detect targets |
| Sensor Layer Mask                                                     | Layer Mask of **Field of View**                                 |
| Start Running At Distance                                             | Runs when the target is greater than this distance              |
| Attack At Distance                                                    | Attack at distance                                              |
| Aim Up Offset                                                         | Target direction height                                         |
| Look At Target Speed                                                  | Look at rotation speed                                          |
| Min Time To Attack                                                    | Min Time To Attack                                              |
| Max Time To Attack                                                    | Max Time To Attack                                              |
| On Follow Waypoint \[<mark style="color:blue;">Unity Event</mark>]    | Event called when AI follow a **WAYPOINT** path                 |
| On Follow AI Path \[<mark style="color:blue;">Unity Event</mark>]     | Event called when AI follow a **NAVMESH** path                  |
| On See Target \[<mark style="color:blue;">Unity Event</mark>]         | Event called when AI sees a target                              |
| On Stop Seeing Target \[<mark style="color:blue;">Unity Event</mark>] | Event called when AI stop seeing a target                       |

{% hint style="info" %}
Patrol AI's parameters are similar to Zombie AI's, so you can use the parameters above to configure Patrol AI in the same way.
{% endhint %}

## Patrol AI

The Patrol AI has an extremely similar setup to the Zombie AI, with the difference that it adds a **Inventory** and an **Item Switch Manager**. You can [add a weapon](/ju-tps-documentation/game-development/how-to-use-inventory-and-add-items.md) normally and the AI will start using it, and in the **Item Switch Manager** you can set the ID of the item it will equip by default.

<div align="left"><figure><img src="/files/xN5KOYap2PHYp4SWNXGJ" alt=""><figcaption></figcaption></figure></div>

You can create a Waypoint Path and assign it to the Patrol AI, and you will have a Patrol Enemy:

<div align="left"><figure><img src="/files/y2Wi3ZiW1gjztXJnto1R" alt=""><figcaption></figcaption></figure></div>

<figure><img src="/files/ZjkfGcDb1eumf68D7qfE" alt=""><figcaption><p>✅ Patrol AI configured successfully</p></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://julhiecio.gitbook.io/ju-tps-documentation/game-development/old-versions-how-to-use-enemies-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.
