# How to use Vehicles AI

The Vehicle AI is very similar to the enemy AI in operation, it also uses Waypoint Path and calculates paths through NavMesh. The Vehicle AI can be used on any vehicle in the JUTPS Vehicle class.

There's no secret, just add the Vehicle AI script to your vehicle and configure the variables.

<figure><img src="/files/Z7P0iCb7bjDGBrMDtr2g" alt=""><figcaption><p>Vehicle being controlled completely by AI</p></figcaption></figure>

See the parameters to configure below

| Vehicle AI Parameters                                             | Description                                                                                              |
| ----------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| Enable Pathfinding                                                | Enable NavMesh Pathfinding                                                                               |
| Recalculate Path Refresh Rate                                     | Time to recalculate path                                                                                 |
| Destination                                                       | Destination                                                                                              |
| Waypoint Path                                                     | Waypoint Path                                                                                            |
| Distance to Continue Path                                         | Distance to go to next waypoint/path index                                                               |
| Vehicle Desaceleration Intensity                                  | Deceleration in curves                                                                                   |
| Front Check                                                       | Front sensor                                                                                             |
| Check Nearest Point On Path                                       | Checks the nearest point on the waypoint/path and prevents the AI from going back to a previous Waypoint |
| On End Path \[ Stop, Reverse, Restart ]                           | What the vehicle will do after finishing the path                                                        |
| 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                                                                     |


---

# 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/how-to-use-vehicles-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.
