PointGraph + NavMeshGraph cause problems

I managed to create pointgraph nodes. The idea is that a NavMeshgraph serves as the graph for pedestrians in a city, and the pointgraph is for vehicles traffic (point nodes at every curve or intersection, all one way per lane). The NavMeshGraph (Pedestrians) is tagged “Ground” (0), while the PointGraph (Vehicles) is tagged “Street” (1). The theory is that pedestrians have only the valid node tag “Ground” while the vehicles have only the valid node tag “Street” so they use completely seperate nodes and even graphs.

As long as I don’t generate the NavMeshGraph (so it has no nodes), my test vehicle successfully uses the PointGraph nodes for pathfinding. However, if the NavMeshGraph also has nodes, it’s pathfinding gives an error :smile:

Yay, we got a path back. Did it have an error? True

What coudl be the problem?

If the vehicle’s valid tags are set to Ground (the NavMeshGraph’s), it works as it should; only the combination of the PointGraph tagges as Street with the Vehicle also only using Street nodes and the presence of NavMeshGraph nodes causes the error.

Two pictures for clarification:

  1. Just the tagged street nodes… The vehicle successfully finds a path and moves from node to node!

Pic 1

  1. Add the NavMeshGraph nodes… error!

Pic 2

Hi

Instead of using tagging, you can use a graph mask for this purpose. It was specifically added for when users have different graphs for different units.

In the StartPath call to the Seeker, you can add an additional parameter which is a bitmask containing the graphs that should be valid to start and end on.

// Search only the first graph (first bit set)
seeker.StartPath(from, to, null, 1 << 0);

// Search only the second graph (second bit set)
seeker.StartPath(from, to, null, 1 << 1);

I am not really sure why your solution did not work however… Can you check if A* Inspector -> Settings -> Full Get Nearest Node Search is enabled (which I think it should be by default)?

Also. To get more informative error messages, enable A* Inspector -> Settings -> Path Log = Enabled.

Thansk a lot for your help, again! The Full Get Nearest Node Search was disabled, I enabled it and now it works as intended.

About the GraphMask; I use the old AstarAI script that isn’t included in the newer version of the APP, I like it for it’s implicity, and it also has a graphMask variable (int). I set it to 1 (the right graph is the second one), but it doesn’t seem to make a difference. That being said, I don’t have much experience with bitmasks, so if I have the graphMask value set to 1 and pass that to StartPath instead of the “1 << 1”, would it be the same?

Hi

1 << 1 = 2
More generally a << b = a raised to the power of b.

Ok… I don’t understand nothing of this, looks like I have to do some serious reading :smile:
Thanks again, you are awesome.

If anyone is interested, I added a LayerMask-sort-of functionality to the pathfinding script:

[HideInInspector]public LayerMask graphMask;
public List<int> validGraphs = new List<int>();
void Start) {
   foreach(int i in validGraphs) {
		graphMask |= (1 << i);
		Debug.Log(graphMask.value);
	}
  seeker.StartPath( transform.position, targetPos, OnPathComplete, graphMask.value);
}

It still seems to search all graphs, though.