Support Forum

AI path agent want to move into obstacle/other unit

I am trying to implement rts like unit movement. I am using AIPath and setting multitarget path around targets so that different faction1 units can surround faction2 units. I have attached a screenshot below where after I enabled RVOCollider on stop (custom rvo collider using 12 edged polygon), faction 1 units still trying to walk into the collider (highlighted with red arrow). Where it should go around like yellow arrow in the image.

I have tried with RVO Collider and without (just local avoidance with each other), either stopped them from trying to walk into their friendly units.

My agent radius is 1, 1.5 and 2.5. My grid graph is current set to node size = 1 (I tried 0.5 as well). I tried the grid graph collision testing to include and exclude units, but I don’t think it works as the graph is already scanned and I didn’t trigger update after initialization.

I have followed this post below to set Max Nearest Node Distance to 0.01 but it didn’t help.

By the way, the pathing is also incorrect when the destination doesn’t have enough space/the path toward it is to narrow to cross. For now, I think it is related to this collider issue.

I searched around and found this post: RVO and Path not working well together where it says the RVOCollider isn’t design to affect pathing. I then try to use the DynamicGridObstacle, but it doesn’t seem to work with a CapsuleCollider (it is not a simple Bound). I am going to try out just using a box collider and see what the quality of the pathfinding would be.

I tried using a BoxCollider and DynamicGridObstacle on each unit when they stop moving so that other units will try to walk around them. But with low amount of grid nodes, the precision is quite bad. My unit radius is 1. With higher amount of nodes 300x300 (0.2x0.2 unit per node), it is quite laggy even on my PC to recalculate graph on the fly. I guess the next thing I am going to try is to use recast graph and navmesh cutting, which I feel is somewhat similar to unity navmesh.

Please let me know if this is the right way to go. Thanks!


Yes, RVO does not affect pathfinding.
The best option for surround in my opinon, is to use the beta version, and then mark agents which have reached their target point (I’m assuming some units are attacking their opponent when in melee range) as locked (this is a field on the RVOController). The beta version has better support for avoiding locked agents.

1 Like

Thanks for the reply. And just to confirm, I can still use grid graph, right?

Yes. RVO work independently of graph type.

I have tried beta version and the surrounding behavior is great. However, I started to encounter another problem because of this. When using local avoidance, the AI path won’t stop even if all target is not-reachable, as the target point is occupied by another locked agent but the graph is not being cut. This causes agent to run around randomly, which is somewhat okay. But when the walkable area is rather small, and a lots of agents are pushing each other, it can push some agents off grid and cause them to snap back to the center of the map.

I have attached screenshots below. Blue circled units are fighting and locked (the RVO controller option), they occupies the entire width of the battleground. All units other than the blue circled ones now have no path to an enemy realistically, but they still have path generate (image 2), so they walk around and pushes each other out of the grid (green arrow). Because I have Constrain Inside Graph option turned on, they will be snapped into the center of the battleground (overlapping agents in the center of image 1). If I turn off Constrain Inside Graph, they will just be left outside of the walkable area and stuck there.

Any suggestions on how to solve it? I feel like using Recast graph and navmesh cutting could be a walkaround solution as the cutting the graph will stop AIPath generate a path so they would just hold still.

Any updates please? Thanks!


You are correct, without using navmesh cutting or some other kind of graph update, the moving agents have no way of realizing that they cannot reach their destination, and so will try to move around the locked agents in any way they can.