Create Formation

Now that the Unit prefab is ready, you can create formations that will organize and command these units.

  1. Create formation GameObejct

    Create an empty GameObject in your scene and add the Formation.cs script to it. This object will serve as the center and anchor point for the entire formation. It can be found under Assets\TopsonGames\Large Scale Formation System/Scripts/Formation.cs

  2. Add Units

    1. Drag your previously created Unit prefab from the Project window and drop it as a child of the Formation GameObject.

    2. Duplicate this Unit GameObejct as many times as you need units in this formation (e.g., by using Ctrl+D or Cmd+D).

  3. Generate Formation

    1. Select the main Formation GameObject. In the Formation.cs component, you will find a Create Formation button.

    2. Click this button. The script will automatically find all child Unit objects, add them to its list, and arrange them according to the Formation Settings.

  4. Adjust Formation Settings

    1. Under Formation Settings, you can define the group's layout:

      1. Formation Width: Determines the number of units per row.

      2. Spacing: Sets the distance between individual units.

  5. Set the TeamID

    1. The Team ID field allows you to assign a faction to a formation.

    2. The default value is "0", which signifies a player-controllable formation. You can use other IDs for allied AI or enemy formations that should not respond to direct player input.

  6. Line Renderer

    1. After creating the formation, a Line Renderer component is automatically added. Please note that the Line Renderer component gets automatically disabled, please do keept it disabled.

    2. This component draws a line showing the formation's movement path to its new destination. You can assign any material you like to customize the line's appearance.

  7. Create Formation Prefab

    1. Next create a Prefab of your Formation by dragging an dropping it into your Project folder.

The setup of your formation is now complete.

Last updated