🏹
Unit Formation
  • WELCOME
    • πŸ‘‹Hello
    • πŸ—ΊοΈRoadmap
    • ⛑️Support & Community
    • πŸŽ“Changelog
  • GETTING STARTED
    • πŸ”ŒImport package
    • βš’οΈAdd unit placement to scene
    • 🚢Add unit movement
    • πŸ“½οΈPosition units in Editor
  • HOW IT WORKS
    • πŸ‘‡Formation Placement
    • πŸ¦₯Unit Formation
    • πŸ“ΊPlacement Visuals
    • πŸ–±οΈInput
    • 🎽Formations
  • Integrations
    • 〽️A* Pathfinding Project
      • πŸ”ŒImport package
      • βš’οΈAdd unit placement to scene
      • 🚢Add unit movement
      • πŸ“½οΈPosition units in Editor
Powered by GitBook
On this page
  • List of formations
  • Customisation
  1. HOW IT WORKS

Formations

PreviousInputNextA* Pathfinding Project

Last updated 1 year ago

List of formations

Here you can find names and behaviours for each provided formation.

Ring

Positions units in a ring formation with specified configurations:

  • Angle

  • Unit spacing

Cone

Positions units in a cone formation. Configurations:

  • Unit spacing

  • Pivot in center (flag)

Line

Positions units in a line formation. Only configuration here is unit spacing.

Rectangle

Positions units in a filled rectangle. Configurations:

  • Column count

  • Unit spacing

  • Center units (when last line is not full)

  • Pivot in center (flag)

Rectangle Border

Positions units along the rectangle edges. If there are too few units, then a line is formed.

Configurations:

  • Unit spacing

  • Aspect Ratio

  • Pivot in center (flag)

When there is a left over unit, it will be added to back side of the formation (front and back might be uneven in unit numbers)

Triangle

Positions units in a filled triangle formation. Configuration:

  • Unit spacing

  • Center units (when last line is not full)

  • Pivot in center

Triangle Border

Positions units in a triangle formation. Configuration:

  • Unit spacing

  • Pivot in center (flag)

When units cannot be divided by 3, there are some leftovers. When there are 2, they are added on left and right side, when there is one, it is added to the back side of the triangle formation.

Circle

Positions units within a circle with fill. While this implementation is fairly simplistic, filling a circle can be quite a computational heavy and complex task. For this the formation must be adjusted manually with parameters to fit different unit counts:

  • Outer radius

  • Unit spacing

When max radius is not large enough for unit count and their required spacing, remaining units will be placed in its center.

Computed Circle

Uses the same calculation as the base Circle, but uses iterations to fit best fit. Search is controlled by:

  • Minimal radius (starting radius)

  • Maximal iterations (number of maximal attempts)

  • Radius increment (radius increment for each attempt)

Use this formation to find the best fit, but using it in game/project to calculate filled circle could be performance intensive for higher number of units or iterations.

Customisation

And you can always add a new one by implementing IFormation.

The interface is very simple, you get a number of units to position and then formation must return positions relative to Vector3.zero. Translating positions to world space is done by FormationPositioner utility class, which is used by other components.

public interface IFormation
{
    List<Vector3> GetPositions(int unitCount);
}

If unit count and returned list size do not match, errors are expected.

🎽