[GridGraph] Agent pathing diagonally through un-walkable nodes

As you can see, agent is pathing diagonally through un-walkable nodes. Question is, how to prevent it?
Red Nodes marked on screenshot are marked as Walkable set to false

Agent components:

Grid Graph settings:


I’m not quite sure, but I think this is because you are using a very large amount of smoothing on your path. Do you think you could try to reduce the simple smooth → max segment length value?

If not. Are you modifying the walkability of the nodes at runtime? If you do that you need to make sure the nodes get their connections recalculated. See this page for more details: Graph Updates during Runtime - A* Pathfinding Project

1 Like

Big thanks @aron_granberg, the nodes were changed, but the graph connections were not recalculated!

For anybody else with this issue, to update connections:

gridGraph.GetNodes(node => gridGraph.CalculateConnections((GridNodeBase)node));

1 Like

Hello @aron_granberg, would you please advice me how to do the update with the newest A star beta version?

The obsolete call is:

gridGraph.GetNodes(node => gridGraph.CalculateConnections((GridNodeBase)node));

which is also causing exceptions now:

That line can typically be replaced with a single call to gridGraph.RecalculateAllConnections().

You will want to make sure your update runs inside a work item (see AstarPath.active.AddWorkItem). Previously it didn’t check this, but now it runs more validation checks.

1 Like

Working like a charm, thank you!