Using multiple grid graphs

I’ve been working on implementing this A* pathing solution in an RTS I’m working on.

What I’m attempting to do is set up two graphs - one for enemies, and one for allies. The enemy graph would consider allies as obstacles, and the ally graph would consider enemies as obstacles. This way they try and avoid opponents, and path around them (this also helps avoid collisions amongst opposing units).

I see on the AStarPath inspector that you can set up multiple graphs, however I can’t figure out how to specify which graph to use when constructing a path. How could I go about doing this? The reason why I’ve decided on using multiple graphs was because when I had it on one graph pathing would mess up a lot, seeing as seekers would see themselves as obstacles.

Sadly I see a couple problems with using 2 graphs:

First would be the fact that every path would need to update at a regular interval (This is usually not acceptable in RTS games due to the large unit count).

second that sometimes the pathfinding would cast a Target is not reachable exception when the enemies units are temporarily blocking a path.

Well here are your options for having enemies and allies path around each other:

#1 Local Avoidance: This is how most RTS’s implement unit to unit path-finding, allowing you to lock and unlock units as you see fit (Locking works like Hold position works in Starcraft, forcing other units to move around the locked unit)

#2 Soft colliders: This is by no means better then using Local Avoidance, but if you do not have access to A* pro… You can always use unity’s colliders

I’ve tried out a couple local avoidance solutions, most of them seem to have troubles with units keeping battle formations. Like when a unit goes to move through the middle of a group of allies, they move out of the way correctly, but they don’t go back to their battle position afterwards. I’ll probably use some sort of grouping system along with rigidbodies to help them not go inside one another.