Support Forum

Finding a partial path

Hello, I have a graph with some tags to denote that my enemy’s can’t walk through certain areas. I’d like my enemies to pursue the player up to what over those restricted areas, then stop. What I’m finding is the enemy will find a path to the player that bypasses the unwalkable area plus other unwalkable areas – so basically a nonsense path. Any help figuring out the right way to approach this is appreciated!

My setup:

  • 2D graph grid
  • Seeker on enemy
  • “Closest Node on Graph” for start/stop
  • Constructing a path with ABPath, Default constraint, and Calculate Partial set to true

Here’s a screenshot that hopefully illustrates the problem:

Still searching for an answer :slight_smile:

Hi

The agent will normally find the path to the closest point it can reach.
This may not be the “semantically” closest point, though. I.e. it might be closer to be on the other side of an unrelated wall, than being on the other side of a closed door.

You could solve this with some code. Essentially you should allow the agent to traverse those tags (but probably add a large penalty for doing so), but then you can make a custom path modifier which trims all the nodes it couldn’t actually reach from the end of the path. So essentially you go through the path and remove all nodes after the first time it tries to step on an unwalkable node. You’ll probably also need to adjust the end point of the path.
See also Documentation