I have problems building p3recastnavigation, PandAI is …em… well not for me, and my own previous attempts at pathfinding are a bit meh… so I’ve made something new.

This time the idea is to model a navigation mesh - that is any mesh at all that resembles the walk-able area of your level - and the script will build a graph such that a node is created for each triangle and connected to other nodes in the same way that neighbouring triangles where connected.

Once you have a graph, run A* on it to find a path.

In the code there’s also something to actually move along the found path and something else that smooths the path out, but that’s just a bonus thing. In a real game it would be best to run some collision detection and keep actors on the surface and out of walls.


It would be nice if someone would test it with some custom mesh to see if/how it explodes, that’s all I’m asking in return (unless you know how to fix my shadows) :mrgreen:

I made a bit of an update.
I’ve made the whole thing much faster (up to 300x when loading a mesh, up to 30x on the pathfinding) and much simpler, you can use it like this:

from pathfollower import PathFollower
from navgraph import NavGraph
path=graph.find_path(start=(0,0,0), end=(1.23, 123., 0.0))
if path:

On my PC it can find a path in 0.0005-0.0165 seconds (depending on the length of the path) in a graph with 14k nodes.
Tested both on Py3.6 and Py2.7