Update single graph using GraphUpdateObject

I have two grid graphs and I want to set a bounds as unwalkable in one of those graphs. All the examples I have found for using GraphUpdateObject include passing the GUO to the AstarPath.active.UpdateGraphs() method. The documentation for that method says that it updates ALL graphs and I don’t see an overload for passing a graph mask.

Should I be looking for the singular UpdateGraph method? Or instead should I be getting a reference to the graph I wish to update and pass the GUO to a method of the graph itself?

Don’t mean to be thick but I have been reading through the documentation and I cant find the hints I need.

Thanks

Think I might have figured it out.
This appears to work, it just reads funny because according to the language used in docs I am updating ALL graphs of a single graph object.

aPath.graphs[0].active.UpdateGraphs(mybounds)

Darn, I think I am on the wrong track again.

I have two gridGraphs for two different navigation logic. I want some nodes to be unwalkable in one graph but walkable in the other. I think I have my code right but when I use the runtime inspector and I go to settings there is just a single “Show unwalkable nodes” toggle. So either that toggle only works for the default graph eg. graph[0] or, anything marked unwalkable in one graph is also unwalkable in the other.

Or I am just doing this all wrong :slight_smile:

When my app starts I initialize my second gridGraph to be all unwalkable:

GraphUpdateObject guo = new GraphUpdateObject(mapBounds);
guo.setWalkability= false;
aPath.graphs[1].active.UpdateGraphs(guo);

Then later an object is placed. I want that objects location to be unwalkable in one graph but walkable in the other, so…

aPath.graphs[0].active.UpdateGraphs(InnerCollider.bounds);

GraphUpdateObject guo = new GraphUpdateObject(InnerCollider.bounds);
guo.setWalkability = true;
aPath.graphs[1].active.UpdateGraphs(guo)

In my testing I can see that graphs[0] is updated with the new object and the seeker can not seek through it.

But when I launch another seeker and pass it the graph mask for the second gridgraph and give it a startNode in the middle of the “bounds” it says “Couldn’t find a close node to the startnode”

	aGoPath = GameObject.Find ("Astar Control Object");
	aPath = aGoPath.GetComponent<AstarPath>();
	GraphUpdateObject guo = new GraphUpdateObject(myBounds);
	guo.setWalkability = true;
	aPath.graphs[1].active.UpdateGraphs(guo);
	guo.setWalkability = false;
	aPath.graphs[0].active.UpdateGraphs(guo);

That will unfortunately not work in some circumstances. Sorry for the confusion.
You can however use the GraphUpdateObjects.nnConstraint.graphMask to set exactly which graph(s) to update.
GraphUpdateObject guo = new GraphUpdateObject(myBounds); guo.setWalkability = true; guo.modifyWalkability = true; //Also nice to set, otherwise the "setWalkability" flag will be ignored guo.nnConstraint.graphMask = 1 << 1; //Second graph AstarPath.active.UpdateGraphs(guo); guo.setWalkability = false; guo.nnConstraint.graphMask = 1 << 0; //First graph AstarPath.active.UpdateGraphs(guo);
See http://arongranberg.com/astar/docs/class_pathfinding_1_1_n_n_constraint.php#a63a785ae519f012d295916dd9969170c and http://arongranberg.com/astar/docs/class_pathfinding_1_1_graph_update_object.php#afdffa529fdc9d701116a6bd09b940e16 for more docs.

Ahh great. Thanks for the clarification on how to use masks with the GUO