- Home /
Pathing multipe agents to a single rally point with navmesh?
I'm trying to use the navmesh to resolve my path finding but I'm having some trouble when I need to have multiple agents path to the same point. Whoever gets there first will stay there and the other agents will just get caught up on each other and start to form a line. I'd like them to try to path around each other as well, so they will all try to get as close as possible to the rally point and end up forming more of a circle around the rally point instead of a line.
At first, I tried having every agent keep checking the position of every other agent to see if one of the other agents was at this agent's rally and then have this agent adjust its rally, But this is N squared and I also had a lot of issues getting it to work. I'm hoping there might be a better solution.
Answer by Dibbie · Jun 25, 2016 at 02:35 PM
The NavMesh has a Stopping Distance.
Manipulate that value so they dont stop right on, but close to the point, other units with the NavMesh will do the same. You may run into a similar issue once you have too many units around the point, which you can continue to solve with a box collider (trigger or not) - in your OnTriggerEnter or OnCollisionEnter function, youd check if you collided with another unit, then check the Path Status for "Complete", and if true, set that current units status to the same, so he wont bash the others to get to the point, or try to form a line, as you mentioned.
Here is the documentation to NavMeshAgent as well that could be helpful: https://docs.unity3d.com/ScriptReference/NavMeshAgent.html
Your answer
![](https://koobas.hobune.stream/wayback/20220612083641im_/https://answers.unity.com/themes/thub/images/avi.jpg)