Hi, I’m struggling with understanding how to convert some algebra into code. I have an RTS game where I can select units and click at a point to move them. I would like to make it so every unit is spaced apart a constant value (units are all the same size) from eachother unit. I would like this spacing to be angle aware, meaning that the units will be spaced relative to the perpendicular angle of the closest unit.

Known: Fist unit’s position, target move position, max number of units in one line, current x and z iteration.

I tried a bunch of different things, but my current attempt was

```
float dx = firstUnit.currentPos.x - targetPos.x;
float dy = firstUnit.currentPos.z - targetPos.z;
float dist = math.sqrt((dx*dx)+(dy*dy));
dx /= dist;
dy /= dist;
for(int i=0 i<selectedUnits.Count; i++)
{
float3 target = targetPos;
target.x += (currentX*1.6f) * dy;
target.z += currentZ*1.6f * dx;
}
```

```
I'm rather stumped on how to get pos2 through 9. Any help is appreciated. Also Unity Forums has this nice code formatter block thing, but I'm not seeing it here on Unity Answers. I apologize for the long codesnippet.
EDIT: Removed magority of content in codesnippet due to unreadability.
```