Have units stopped by obstacle but not by cutting the navmesh

In my game there’s a center of the player’s base that they’re defending. AI come in from all directions and pathfind to the base. Along the way if they encounter any walls the defenders placed down they’ll destroy them. They won’t go out of their way to seek these walls, only if they’re near them on their way to the center.

The problem with this is that they can then go through these walls because they aren’t cutting the navmesh. They aren’t cutting the navmesh because I want AI to take the same path regardless of if the player has placed down a wall or not because the AI can simply break the wall, if I cut the navmesh the AI will go to the other side of the map instead of taking the path they would’ve taken just because the player placed down some low-tier wall.

Any possible solutions? My solution was to not cut the navmesh which made so AI path as they should but now when they arrive at the wall sometimes they’re going too fast and get pushed through it or end up on top of it because other AI pushed them.

You could place graphupdatescene on the walls, and set a different tag per wall. The tag would give a penalty to the path of the agent. So if it’s a low tier wall and walking around doesn’t take much longer it will walk around. But if the detour is too far it would keep it’s original path. You can read more about tags here: https://www.arongranberg.com/astar/docs/tags.html

For multiple agents avoiding each other RVO usually works best, this local avoidance system will deal with it. Though a custom system to decide which agent goes where would still be required.

Thanks for responding. RVO is currently active however due to the bulk of units they still end up pushing each other regardless.

Regarding setting the tag to something harder to walk through, this will still result in them walking through it as if it weren’t there if they get pushed so this doesn’t solve my problem.


Possibly you could use off-mesh links (see the NodeLink2 component, sorry about the terrible naming) over the walls instead. That would enable your agents to still be constrained to the navmesh while also allowing them to path “through” the wall.