# 02 How Pathfinding Works

Plain English version.

## The algorithm

OWP uses **A\*** — the same algorithm Unreal's NavMesh uses. From start node to goal node, it explores the cheapest combination of paths.

## What "cheap" means

Each path has a **cost** that the pathfinder sees. Roughly:

```
Cost = Length / Speed × Cost Multiplier × (zones, conditions, congestion)
```

Translation:

* **Long paths** cost more.
* **Fast paths** cost less.
* **Cost Multiplier > 1** makes a path less attractive.
* **Zones** (Speed/Blocked/Danger) modify cost in their volumes.
* **Conditions** can add penalties or block entirely.
* **Congestion** (path filling up) raises cost when many AIs are on it.

## Blocked vs. Penalized

* **Blocked** path is invisible to the pathfinder — never used, even as a last resort.
* **Penalized** path is still legal — used if no cheaper alternative exists.

## Disconnected networks

If start and goal are not connected, pathfinding fails with `Unreachable`. Use **Validator** or **Merge Networks** to fix.

## Free Pathfind

Normal pathfinding works node → node. **Free Pathfind** lets you go from any world point to any other world point: it adds NavMesh entry/exit segments. Great for vehicles joining a road from a parking lot and leaving it later.

## Should I worry about performance?

Probably not. A\* runs in microseconds for typical networks (hundreds to a few thousand nodes). Don't call **Find Path** every frame from Tick — call it once when the goal changes and reuse the result.


---

# 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://onesteppack.gitbook.io/openworldnavigation-doc/02-basics/02-how-pathfinding-works.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.
