A* Pathfinding Project

Group select move to same point with RVO


#1

Similar to a real time strategy game, the player can select a group of units and tell them to move to a single point.

PathUtilities.IsPathPossible will tell me if the point is reachable via the navmesh, however it doesn’t tell me if the point is occupied by a friendly stationary unit such that RVO won’t let them move to that point.

Similarly, even if the point is originally unoccupied since the group of units all move to the same point, the first unit will reach that point and stand there while the other units will circle and/or run in place.

OnTargetReached doesn’t help either since it checks for the end of the path and doesn’t consider if the path is blocked.

I could tell the units to not move to the same point but in a formation, but the problem still may exist that another friendly unit is in that formation’s target position.

Since this is a commonplace problem I wanted to ask if there is already a solution for this, and if not do you have any suggestions? Right now what comes to mind is to just keep doing raycasts and stopping the path early if the point is blocked, which isn’t very efficient considering RVO already has the information I need.


#2

Hi

The RTS beta has a solution for this. What it does is to run a check for “inside the circle with the center at the destination I want to go to, and a radius equal to the distance to the destination, what is the density of units there?” and if that density is above some threshold (e.g. 50%) then it stops instead of trying to move closer to the destination. This works quite well.

Here is a video of it: https://www.youtube.com/watch?v=wBUdMXeeej0

You can dowload it at https://www.arongranberg.com/astar/download (click the ‘Show Older Versions’ button).

The script used (SC2Avoidance I think it is called, it is attached to every agent) is a bit cpu heavy with many agents though.


#3

Thanks for the quick and detailed response. I’ll give it a shot.