Effective Spatial Queries

  • A* version: Pro 5.1.4
  • Unity version: 2022.3.22f1

Hi!

I’ve been wondering about the recommended solution to the common problem of finding a large enough open area on the graph. Suppose I have a recast graph updated at runtime. I would like to find a random point on the graph within an open area of minimum dimensions (X, Y, Z).

In my game, players can build walls and modify the environment, which can obstruct views and alter the navmesh. I need a reliable method to locate these open areas even as the navmesh changes during gameplay.

What is the best approach using A* Pathfinding Pro and is there anything built-in to help? Or are there any specific algorithms that you can recommend?

Regards,

I combed through the documentation for a more official solution just to make sure there wasn’t one, but I didn’t particularly see one. What I did in my game for this same idea was to select a random node, then do a Physics.OverlapSphere to see if anything was in the way. You can use NavGraph.RandomPointOnSurface to get a random point as well. So long as this isn’t happening very often like on a frame-to-frame basis it should be fine but let us know if this doesn’t work for your setup :+1: