Hey hey people,
The standard navmesh physics type has proven to be quite unstable in the build I’m using, so I thought I would try coding some similar behavior from scratch. Got it done by building a BVH tree from a mesh and sorting out faces like so,
nns = bvh.find_nearest_range(target, 24.0) points = np.asarray([ 0 for p in range(len(nns)) ], dtype=object) i = 0 for n in nns: co, normal, index, dist = n centroid = Vector([0,0,0]) if dist > 0.01: poly = nav.meshes.getPolygon(index) isNeighbor = 0 polyVerts = [vi for vi in range(3)] for v in range(3): vertex_co = (nav.meshes.getVertex(0, poly.getVertexIndex(v)).getXYZ() ) if vertex_co in currPolyVerts: isNeighbor += 1 polyVerts[v] = vertex_co centroid += vertex_co co = (centroid/3)+nav.worldPosition if isNeighbor > 1 and index not in path: points[i] = [co, polyVerts, index] i += 1 adjacent_points = points[points != 0]
This way I get neighboring faces to the one I’m pathfinding to, the rest is measuring distance and cost. Simple enough.
Now, what I’m wondering is if there’s a better way around. I got this approach working okay without much hassle and it’s optimal enough, but perhaps someone else has already figured out something more fancy?