Can't set unwalkable node next to penalty node

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:

walkability-penalty_nodes

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

Hi

Your second GraphUpdateObject has updatePhysics implicitly set to true. This will make the nodes be recalculated from scratch (except the penalty, which you have explicitly disabled). You can set updatePhysics to false on both of them to prevent this.

Thanks for such a quick reply, Aron, that fixed it. Cheers to a great product!

1 Like