In my game I have grid graph nodes that I set penalties/walkability on dynamically. I’m running into a problem where if I try to place unwalkable nodes right next to nodes with a penalty, the nodes don’t become unwalkable, they just have a penalty applied. Please see attached picture:
If I don’t add penalties, setting the nodes to unwalkable works as intended. Here are my calls to add penalties and walkability. I have 2 grids graphs so I use a constraint with the graph mask.
// Walkability
PathfindingConstraint constraint = new PathfindingConstraint();
constraint.graphMask = graphMask;
var guo = new GraphUpdateObject(bounds)
{
updatePhysics = true,
modifyWalkability = true,
setWalkability = false,
nnConstraint = constraint
};
AstarPath.active.UpdateGraphs(guo);
AstarPath.active.FlushGraphUpdates();
// Penalty
PathfindingConstraint constraint = new PathfindingConstraint();
constraint.graphMask = graphMask;
var guo = new SetPenaltyGraphUpdateObject(bounds)
{
modifyWalkability = false,
setPenalty = (uint)penalty,
resetPenaltyOnPhysics = false,
nnConstraint = constraint
};
AstarPath.active.UpdateGraphs(guo);
AstarPath.active.FlushGraphUpdates();
Any help trying to figure this problem out would be greatly appreciated!
Eric