Implementing a safe zone

My 2d game has two types of agents: hero and enemy. A few circle area as safe zones, where the hero is allowed to enter but not enemies.

The first approach is using two grid graphs

  • Create a circle collider 2d, and set Unity tag to safezone.
  • Create a grid graph for enemies and treat the Unity tag safezone as obstacles.
  • Create another almost same grid graph for hero and ignore the Unity tag safezone.
  • Setup seeker for hero and enemy using different graphs.

This approach works. It’s easier to use collider to setup obstacles. But using two graphs seems be a bit overkill.

The second approach is using GraphUpdateScene and tag.

  • Remove the collider.
  • Attach a GraphUpdateScene to each my safe zone. And draw a shape manually. Modify tag to safezone.
  • Setup seeker for enemy to treat tag safezone as not traversable.

This approach semi-works

  • It only uses one graph,
  • The process to draw shape around my collider is verbose. It could be a feature to automatically create a shape based on a collider, or simply use the collider to update a graph?
  • I found my enemy get stuck (stop moving) when it was closer enough to my safe zone.

So I wonder which way is suggested to implement the safe zone. And if tag is the way to go, is there simpler way to create the tagged shape based on collider? And how to avoid agent get stucked at the edge of a non-traversable tagged shape.