# 01 Pathfinding

| Node                         | Returns                  | What it does                                           |
| ---------------------------- | ------------------------ | ------------------------------------------------------ |
| **Find Path**                | Path Result              | A\* between two nodes.                                 |
| **Find Path By Location**    | Path Result              | A\* between two world points (snaps to nearest nodes). |
| **Find Path With Waypoints** | Path Result              | A\* through an ordered list of node waypoints.         |
| **Find Free Path**           | Path Result + entry/exit | A\* with NavMesh entry/exit (any-to-any world point).  |

## The Path Result struct

| Field            | Type          | What it is                                                     |
| ---------------- | ------------- | -------------------------------------------------------------- |
| **bSuccess**     | bool          | True if a route was found.                                     |
| **Query Result** | enum          | Detailed reason: Success, Unreachable, NoNetwork, etc.         |
| **Nodes**        | array of Node | Ordered waypoints (Nodes\[0] = start, Nodes.Last() = goal).    |
| **Paths**        | array of Path | Connecting paths. Paths\[i] connects Nodes\[i] to Nodes\[i+1]. |
| **Total Cost**   | float         | Sum of A\* edge costs.                                         |

## Common usage

### Find a route

```
[Find Path]
    Start = MyStartNode
    End = MyGoalNode
    ↓
Branch on bSuccess
    True → use Result.Nodes / Result.Paths
    False → switch on QueryResult
```

### Handle failure

| Query Result | What to do                                           |
| ------------ | ---------------------------------------------------- |
| Success      | All good.                                            |
| Unreachable  | Networks are split — pick a fallback or bridge them. |
| NoNetwork    | Your level has no OWP actors.                        |
| InvalidInput | A null pointer slipped in.                           |
| OutOfRange   | Start or goal too far from any node.                 |

## Tips

* **Don't call Find Path every frame.** Once when the goal changes — cache the result.
* The **Traveler** input (optional) lets you pass tags, speed, danger tolerance — used by your conditions and zones.
* For "where would my AI go from anywhere to anywhere with NavMesh entry?" → use **Find Free Path**.


---

# 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/06-blueprint-functions/01-pathfinding.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.
