Most optimized way to block moving units' paths from units that are not moving

Hello.

I’m using a Grid graph and the plan is to block paths by re-scanning the graph via code every time a unit moves to another GridNode. Basically I want to set the node nearest to every unit’s position’s to be UNWALKABLE for others, either by using Tags or blocking it completely with the unit’s collider (not sure which is best).

Is it recommendable to do this for what I’m trying to achieve? Or is there a better way? I don’t want this to be a problem in the future once I’m working with hundreds of units in a single large Grid graph.
Maybe Mesh-cutting is faster than Grid graph?
I just really need an advice.

Not sure if it’s relevant but my game is 2D and I’m using a custom Movement script that I wrote.
Also I tried Local Avoidance and I’m very sure that is not what I’m looking for. What I want is to manipulate the paths of the units being “ordered” (RTS-style) to go around the unmoving units instead of bumping them.

Ah never mind. I read the documentation again and learned a few things.

I solved it by using traversal providers.
Customized my own so instead of using SingleNodeBlock, I saved each node from where each unit is standing to a Dictionary. So when making a path, it then scans and check whether the path is traversing to a blocked unit node with the exception of its own. Therefore re-scanning the grid graph every movement isn’t necessary.
The only problem is that when the Target position is exactly on the position of a blocked node, the creation of path will fail (returning an error).
But I think this is easily solvable by using Constraints while targeting nearest node anyway so it’s not a big deal.

For those who are reading this and still can’t find a solution for the same problem, I followed this post and everything is working correctly now :https://forum.arongranberg.com/t/turn-based-grid-difficulties/7037/4?u=natalia14

In my case, to avoid Units from being blocked by their own occupancy, I used Dictionary instead of HashSet in order to save my Units as values. Then check whether the Unit that is occupying the detected node is NOT the same as the walking Unit.

1 Like