A* Pathfinding Project

AI moving to same target, but won't share the diameter


Hi all,

Is there any way for neighboring AI to share the diameter of the target, rather than trying to bundle all onto the same point?

My AI move to the target but just push into eachother and can never reach the target position as they’re blocking one and other, is there a way to make them crowd AROUND the target, and not just push towards one single vector?


There are various ways to handle this.

First off there is local avoidance (which you may or may not already be using): https://arongranberg.com/astar/docs/local-avoidance.php

The easiest is probably to simply don’t order the units to the same point, instead pick points around the target point (which can be done in numerous ways). There are some built-in functions for this in the package:

See https://www.arongranberg.com/astar/documentation/dev_4_1_5_3cb9f189/class_pathfinding_1_1_path_utilities.php#a9c4c3707859372ea83afdeee9124db8e

I also shared another script with another user recently that does this in a different way (take a look at the linked script, it has a few comments): Which options of the asset are best for RTS (like Starcraft II)