Guides / How to Move Groups of Units in Unity
Unity Development Guide

How to Move Groups of Units in Unity

Learn practical techniques for moving groups of units in Unity while preserving formation offsets, facing, regrouping and smooth group behaviour.

Why group movement is different

Moving several units to the same destination is easy. Making them arrive as a readable group is harder. Each unit needs a target position relative to the formation, while the whole formation needs a shared destination, orientation and movement speed.

Keep formation positions relative to the group

A robust approach is to store each unit's position as an offset from a formation anchor. The anchor can be a leader, an empty GameObject or a logical point controlled by your movement system. Units then receive world-space targets generated from the anchor transform.

Convert local offsets to world positions

For a formation offset `(x, 0, z)`, transform it through the anchor rotation and position. In Unity, `TransformPoint` is a simple way to do this because it converts a local-space point into world space.

A simple C# target calculation

Vector3 GetUnitTarget(Transform anchor, Vector3 localOffset)
{
    return anchor.TransformPoint(localOffset);
}

The important idea is that the formation layout does not need to know where the group is in the world. It only describes relative positions.

Move the anchor, not every formation rule

When the player gives a new destination, update the formation anchor toward that destination. Each unit follows its calculated target. This separation makes it possible to change movement speed, steering or pathfinding without rewriting the formation generator.

Rotate the formation with its movement

If the group should face its travel direction, rotate the anchor toward the desired velocity. Because unit targets are generated from the anchor transform, the entire formation rotates naturally without manually recalculating every offset.

Regrouping and temporary separation

Real groups rarely remain perfectly aligned. A unit may avoid an obstacle, become stuck or take a longer path. Give every unit a persistent formation slot, but allow a small arrival radius and local steering. Once the unit is clear, it can converge back toward its assigned slot.

Obstacles and pathfinding

Do not make the formation system responsible for every navigation detail. A useful architecture is: formation system produces desired positions; navigation or steering moves units toward those positions; local avoidance handles nearby collisions. This keeps the systems replaceable.

Performance for large groups

Avoid rebuilding expensive data every frame. Cache formation slots, update the anchor at the group level, and recalculate individual targets only when the anchor changes significantly. For very large armies, consider batched jobs or Unity's DOTS-based approaches where appropriate.

Putting it together

The basic pipeline is simple: create an anchor, assign local offsets, move and rotate the anchor, convert offsets to world targets, and let each unit's movement system approach its target. The formation layout remains independent from the movement implementation.

Dynamic Formation System for Unity

If you need this workflow without building the whole system yourself, RomaSoft's Dynamic Formation System combines procedural formation layouts with runtime behaviours, path and waypoint movement, group steering and formation morphing. It is designed to let you experiment with group movement without hard-coding every formation.

Conclusion

Good group movement comes from separating responsibilities. Keep formation slots in local space, let an anchor define the group's world position and orientation, and let navigation and steering solve the individual movement problem. This approach scales from simple squad movement to more advanced RTS and tactical systems.

Practical tip: Keep the formation layout, group movement and unit navigation as separate systems. This makes the architecture easier to debug and reuse.

Related Guide

Read: Unity Formation System: How to Build Dynamic Unit Formations