Unity Formation Movement

February 8, 2026 ยท View on GitHub

Description

A formation system for Unity that positions and moves units in dynamic layouts (e.g. Wedge, Circle, etc) formations. Suitable for RTS, TD and other strategy game genres. Supports historical and live positioning modes.
The implementation provides integration for both Unity NavMesh and A* Pathfinding Project packages. The system supports manual integration without requiring A* Pathfinding or Unity NavMesh packages. Read more on Technical Overview and Manual Integration sections.

Features

Dynamic Formation Changes
Follower Removal
Visual Leader (cosmetic)
Adaptive positioning fallback
Simulation Types Support
  • Historical
  • Live
ScriptableObjects Formation Layouts
  • Arc
  • Circle
  • Triangle
  • Wedge
  • Matrix
  • Horizontal Line
  • Shield Wall
  • Vertical Line

Note: Click on above items to expand.

Quick Start Guide

Requirements: Unity 6000.0 or later, although 2022.3 LTS or lower should work.

  1. Download and import A* Pathfinding Project or Unity NavMesh package.
  2. Download and import Formation Movement package.
  3. Delete from the FormationMovement imported folder, the integration you are NOT using:
    • Using A* Pathfinding Project, delete NavMesh folders.
    • Using Unity NavMesh, delete AStar folders.
  4. Search and open FormationExample scene for a ready-to-use setup.
  5. Press play and see your formation in action!

Notes for Unity NavMesh Users

In order to avoid Followers struggling to avoid each other when a formation change happens, tweak Formation Scriptable Objects values.

Notes for A* Pro Users

This implementation supports all A* Pro package features, like Local Avoidance and Movement Scripts. Generate your desired Graph type and replace the AIPath component from both FormationLeader and Followers prefabs with desired movement script (ex. RichAI, FollowerEntity etc.) component.

Technical Overview

The system creates formations using virtual Formation Grid Points positioned relative to a hidden Formation Leader. Followers move toward their assigned Formation Grid Point to maintain formation.

  • Formation: Holds formation related data such as Formation Grid Point, Formation Follower and handles formation changes (e.g. spawning, placement, switching and related functionality).
  • Formation Leader: The brain unit, always placed ahead of formation. Generates Formation Grid Point for each Follower and records movement history. It is invisible.
  • Visual Leader: Any unit that appears to "lead" the formation (optional, purely cosmetic).
  • Follower: Unit that follows their assigned FormationGridPoint to maintain formation layout.
  • Formation Grid Point: Virtual targets defining where each Follower should move. Constantly updated by the Formation Leader.
  • FormationTypeSO: ScriptableObject system used to define different formation layouts in a modular way.

Positioning Modes: Historical and Live

  • Historical - Formation Grid Points use sampled historical positions of the Formation Leader. This results in smooth and natural Follower movement.
  • Live - Followers track real-time offsets relative to the Formation Leader. Suitable for simple, tight formations (e.g. Wedge, Circle, Arc).
  • Switching between modes can be made from formation scriptable object (e.g. WedgeFormation) found in ScriptableObjects folder.

Manual Integration

To use the system without A* or Unity NavMesh, manual integration is required. This requires that a movement system for units is already implemented which will be hooked to the Formation Movement system.

  1. Create two new classes, one Follower and the other Leader. They should hold your movement system.
  2. Inherit FormationAI class on both Follower and Leader classes. Link class overrides to your movement system.
  3. Inherit IFormationLeader on Leader and IFormationUnit on Follower. Link interfaces overrides to your movements systems, altough, in this point, most of them should be already linked from previous step.
  4. Create your Follower and Leader prefabs with their new scripts attached.
  5. In Formation Scriptable Objects change Follower reference with your prefab.

Known issues

  • For Historical simulation type, Adaptive Positioning Fallback doesn't always return the best path direction for some formation layouts.

Contribution

Help make this better! Bugs are expected. Feel free to:

  • Open issues for bug reports or suggestions.
  • Submit Pull Requests with improvements or fixes.
  • All contributions are welcome, thank you!