Grid graph diagonal pathing through obstacles

  • A* version: [5.2.5 pro]
  • Unity version: [6000.0.29f1]

I’m having a problem with pathfinding on a grid graph. These are my settings:

And this is the issue:

In both cases the pathfinding takes a path through the solid walls even with “Cut Corners” turned off.

Is there a way I can set this up so that the pathfinding has to go up or down levels to get around the blocked diagonal?

Hi

If the agent can normally walk up those cubes, then it doesn’t really differentiate this situation from just flat ground. There’s no built-in way to filter out that diagonal connection.

You can use the ITraversalProvider interface to filter out some connections, if you want, though.
See Agent-Specific Pathfinding - A* Pathfinding Project

I was wondering about using IConnectionFilter, but honestly it doesn’t matter whether the block is in the pathfinding step or the graph generation step. I’ll see what I can do with ITraversalProvider.

Sure, using IConnectionFilter also works for this.