How to deal with static obstacles in Point Graph?

  • A* version: 5.2.2
  • Unity version: 6000.0.29f1

I’m developing a city-building game. I have been using the point graph since the start of the development, as it is easy to include new nodes in the buildings I place, and I’m using AIPath + Seeker to move the agents. The problem is, that the nodes define preferable points for the AI to walk through, but they are not limited to the points, which is good, as I want the agents to be able to find a path even if I place something far from the roads, but this also means that my agents do not avoid obstacles. I’m not talking about other agents, RVO controller does a good job for that, but static buildings and dynamic objects that come, stay in a position for a while, then move (like a parked car). Adding collision doesn’t fix the path, they keep walking towards the object instead of searching a path around it. I was thinking about constraining them to the graph, but that doesn’t really seem to work for the point graph, and it’s also pretty heavy.

Another option I’ve tried was to add a recast graph that covers the entire map, and keep the point graph with the nodes I already have with my buildings. This way I could add penalty to the recast, so they would prefer to walk in the sidewalks, but a single path going through multiple graphs isn’t a thing (can you confirm that please?);

For this second setup, with a point and a recast graph, I had progress meaning they were mostly walking through sidewalks by making them recalculate paths more often and cutting the recast navmesh around the sidewalks, but that also created some failing edge cases, where they recalculated so quick and were stuck going to one way, and then another infinitely.

I would try just recast, as I can cut the navmesh easily in runtime, but I believe defining the sidewalks wouldn’t work very well. Also, There are animals in the game that should not prioritize the sidewalks, so different agents need different setups.

I think maybe using 2 graphs and writing my own path-seeking entity would prolly be the most accurate choice, and that’s an option for the near future, but I have a very important playtest coming soon so I need to solve this ASAP, even if it is not perfect.

Can you post your point graph settings for us to take a look at? Looking into how point graphs handle obstacles myself. I did find this in the documentation:

Lastly it will check if there are any obstructions between the nodes using raycasting which can optionally be thick.

That said I’m having issues with it myself but I’ll get it going :slight_smile: Hit us up with those point graph settings so I can try and replicate it better.

Sure, I can. But I’m pretty sure this raycasting only impacts the building of the graph, it uses raycast to see if there’s anything that blocks a node connection (BTW, I have also tried setting up barriers and then using their layers in the raycast to block the connection, and it did work, connections were blocked, but like I said, the agents don’t care that much about walking strictly in the graph). Right now my raycast layer is nothing, but Like I said, I have used it before. I would love to discover that I’m wrong, though. Lol

image

Hi

Point graphs are indeed pretty hard to deal with when it comes to larger worlds with lots of obstacles. I assume that you update the graph as you move your static obstacles still? (see Graph Updates during Runtime - A* Pathfinding Project)

I would recommend using just a recast graph for this, instead. It will be much more manageable.
You can have two recast graphs if you want different behaviors for different creature types. See Multiple agent types - A* Pathfinding Project for more info.

That’s the main issue with point graphs. They don’t define a surface that the agent can walk on, just a few safe points. This means it’s very hard for the agent to reason about where it can and cannot walk. A recast/navmesh or grid graph will do much better.