Skip to content
Benjamin Sommerfeld edited this page Jan 29, 2026 · 6 revisions

The Pathfinder is the workhorse. You built it in the factory, gave it a brain (Configuration), and now you use this interface to tell it where to go.

It is thread-safe (mostly), non-blocking (if you listened to us and enabled async), and ready to run.


Executing a Search

The main event.

  • findPath(start, target) Calculates the path. If you configured async, this returns immediately and computes in the background.

  • findPath(start, target, context) The Overload. Use this if your NavigationPointProvider needs runtime data (like "Which team is this unit on?" or "Is the door locked for this specific player?").

// Fire and forget
PathfindingSearch search = pathfinder.findPath(start, target, myContext);

search.ifPresent(result -> {
    // This runs when the math is done.
    moveEntity(result.getPath());
}).orElse(result -> printFailure(result)); // A path has not been found.

Lifecycle

How to use this class without hurting yourself:

  1. Build it: Get an instance from the PathfinderFactory. Keep this instance; don't create a new one for every path.

  2. Fire it: Call findPath(...).

  3. Wait for it: Handle the PathfinderResult in the callback.

Clone this wiki locally