Finding a single path over floors and walls


#1

Hello,

I just started using A* Pathfinding Project, and for my current project I need to be able to find paths that include vertical parts.
When I create a Navmesh Graph from a single mesh, it finds all surfaces walkable, and creates connections, but there don’t seem to be connections between vertical and horizontal surfaces. These also get different colors in the viewport.

So when I use an AIPath to calculate a path for me, it only creates a path in the same colored “area”.

Is there any simple way to find paths/create connections between these floors and walls?


#2

Hi

Are you sure the vertices of the triangles line up perfectly? If they do not line up then the graph will treat them as disconnected from each other. The different colors that you can see are the different connected components of the graph, meaning that if node A has the same color as node B, then there exists a path between those nodes.


#3

That sounds interesting. I do notice that the vertex count in Unity seems higher than in Maya (although I’m not sure how Unity computes that). But I exported it as a single mesh to obj (from Maya), so I’m not sure there’s much I can do. I will try in a bit if I can see if there are actually extra vertices, or if Unity is counting more because of normals or something.
Are you sure there isn’t any setting I need to change? Maybe a slope.
Or is there some way of forcing the navmesh graph to be just a single graph?


#4

Hi

It might be that your normals on the walls have been flipped.
The graph by default tries to make sure the normals point up, however for walls that direction is a bit ambiguous.
If you open the NavmeshBase.cs script, then find these lines

// Make sure the triangle is clockwise in graph space (it may not be in world space since the graphs can be rotated)
if (!VectorMath.IsClockwiseXZ(node.GetVertexInGraphSpace(0), node.GetVertexInGraphSpace(1), node.GetVertexInGraphSpace(2))) {
	int tmp = node.v0;
	node.v0 = node.v2;
	node.v2 = tmp;
}

and comment them out / delete them.
That should make all normals the same as in the source mesh.

If this does not work. Do you think you could enable ‘Show Outline’ and post a screenshot of that?


#5

That works! Thank you! This would have taken me a long while to find in the code :slight_smile:
Thanks!


#6

This change will be included as an option in the next version.