How to apply penalty to some graphs but not all

I use 2 grid graphs for 2 sets of agents. I want to apply varying amounts of penalties at runtime to one of the graphs so that the agents using that graph avoid dynamically generated dangerous zones, but the second set of agents ignore the penalties since the danger doesn’t apply to them. How can I achieve this?

I’m using the following code:
`int dangerValue = … // Each danger zone calculates its own value
var dangerZoneBounds = new Bounds();

var graphUpdate = new GraphUpdateObject(dangerZoneBounds);
graphUpdate.addPenalty = dangerValue;

AstarPath.active.UpdateGraphs(graphUpdate);
`

Hi

You can use the graphMask on the graph update object.
graphUpdate.nnConstraint.graphMask = 1 << graphIndexToUpdate;
The graphMask is a bitmask so you can update multiple graphs if you want.

See http://arongranberg.com/astar/docs/class_pathfinding_1_1_n_n_constraint.php#a63a785ae519f012d295916dd9969170c

If you want to keep them on the same graph, you can use tags to specify that one agent should have a high penalty for some nodes, but the other agent might have a low penalty for the same nodes.
See http://arongranberg.com/astar/docs/tags.php