How to use AstarPath.GetNearest() with radius?

  • A* version: 5.3.8
  • Unity version: 6000.1.5

I’m spawning enemies into a scene, and want to avoid placing them inside walls/objects, so I’m using GetNearest() to get a valid position to fit them, but it doesn’t account for their size, meaning they can still start clipped into a wall. How could I avoid for this?

Hi

The navmesh is defined as every position where the center of the agent can be, so it should already account for the agent’s size. If not, you should adjust your graph settings.

If you have multiple significantly different agent types, check out this tutorial: Multiple agent types - A* Pathfinding Project