Flagging areas as "pathable out of, but not into"?

(I know how annoying this question is because my last job involved writing the pathfinding system, and this is a question I kept answering with “handle it at a higher level”, but I find myself being on the other side of the fence now!)

Is there some built-in way of flagging an area of a graph (specifically nodes on a grid graph) as “pathable out of, but not into”? By that, I mean a path starting outside of it will NOT pass through those nodes, but a path starting inside it CAN pass through those nodes, and the end point of a path will be clamped to be outside of the area.

The intention is to be able to toggle this on an area to make agents leave it eventually.

Hi

Sorry for the late answer.
Technically yes. Without some of coding: no.
You could cheat in a bunch of ways. If you mark all those nodes with a tag, you could - when making a path request - check the tag of the node the agent is standing on (using AstarPath.GetNearest) and add that to the Seekers valid tags list just when making that path request. Then if your agent was outside the tagged region, it will not have that tag enabled and will thus not be able to traverse that region, but if it starts inside of it, it can move freely.
You can also do a bunch of stuff like modifying the nnConstraint on the path object. That is used to search for the closest nodes to the start and end points. If you override that class and the SetStart method, you could in that method remove the tag you used for the region, then the end point will be forced to be outside the region.

So it is possible, but some coding and trickery is required.

Ok, I thought that may be the case. The way I would have done it in my last codebase would have been special logic when choosing neighbour nodes to expand to, essentially only connecting adjacent nodes in one direction. Which of course is a very intrusive change so I resisted! I’ll try the things you’ve suggested, thanks!