# Unity - Moving X amount of units to destination, RTS style movement

I have a reached a point now where I can select X amount of units, and move them to where I click. My problem is, they all try to get to the same point.

I use Unity's own Navmesh + agent.

I set destination like so:

public bool MoveToPoint(Vector3 point)
{
if (SamplePosition(point))
{
agent.SetDestination(point);
return true;
}

return false;
}


I tried a system where I send an event when ANY agent reaches the point, then all agents stop, but realised quickly that will never work well.

I've read the material I can find through Google but nothing really helps me get started.

If I have a List of units, all with an attached agent, how can I move these to a point while keeping some sort of logical formation, no matter how far apart they started?

It does not have to be very fancy, I just want them to stop bumping into each other and doing that weird "Spassing out" thing they do when they can't reach their destination cus they are in each others way.

• Well maybe I am doing it wrong, but I am moving units to their locations like follows: I calculate locations for each unit based on the chosed formations e.g. (line, triangle..) and making them to move to the point all as one until the last path segment, when the movement is executed on the last path segment the units will move to their precalculated locations (each will generate a simple little path). – ColdSteel Dec 8 '19 at 10:02
• drive.google.com/file/d/1x4MPTSwyEtNeSRd1YHjr4nzOG41cp5Sc/view – ColdSteel Dec 8 '19 at 10:03
• @ColdSteel thanks, I ended up buing Astar project :) – Green_qaue Dec 8 '19 at 19:15