Simple Pathfinding Example

Don’t worry, it’s just a race condition. It’s easily fixed - just enable the icon to the left of the DELETE CONTROLLER X on the “motion.init” python controller for each object using the script.

navmesh.zip (361 KB)
Fixed navmesh path finding for uniform grids, added support for python mesh wrapper.

This may run a little slower. The original “static” mesh code has been returned, which is closer to twice as fast as the modifiable mesh code. If you’re going to distort the mesh in game, add a “modifiable_mesh” property to the navmesh object and set it to True, otherwise it will use the faster fixed-mesh information.

The main use case for a pure-python navigation API is that one can add their own weights for the navmesh and access the coarser - grained A* result from the path finding algorithm if needs be.

I’ve included some code from my network library. The only files you need to change for your own purposes are navmesh.py and path.py.
There are some compiled pyd files for windows which offer slight speed improvements but they’re disabled by default.

Cool stuff so you sey it works on all meshes without +navigation mesh and there no need to change psychics?

Indeed it does. It also works on them too.

Can we update this to pass a built kdtree and a target, and a startpoint?

Path = Navigate(KdTreeOfNodes, Goal_Pos, Agent_Pos)?

I was generate the local kdtree to the agent that is the closest X nodes to the agent.
(so I make a small tree from data from the big tree)
This also allows me to mark nodes occupied / empty

I have outgrown the bge pathfinding solution.

I updated the code recently for some cleanups, but effectively this is what it already does. Inspect the code :slight_smile: