Skip to content

Author a Custom Formation

Goal. A Skirmish Line: the selected units stand shoulder to shoulder in a single rank. Dragging a line puts the rank on that line, spread to its length. A plain click makes a tight rank across the direction of travel.

A formation decides where each unit stands for one order, and nothing else. It does not pick abilities or move units. Read Orders and Formations first for the shape of the pipeline. The important part: the framework cleans up whatever your formation returns, so it only has to return a rough, deterministic shape.

You need a project with a few selectable units that move, such as the Soldiers from Add Movement.

If you only want to change the spacing of a stock shape, skip the graph. Create the formation asset as in section 1, pick the stock formation as its parent (for example Box Formation), and set Inter Unit Spacing in Class Defaults. Grid Formation does not read it. Then make your asset the default as in section 3.

In the Content Browser, right-click and choose SeinARTS > Formation Pattern. Pick Generic Formation as the parent and name it SF_SkirmishLine.

In Class Defaults, leave Facing Mode on Uniform: every unit faces the way the line faces.

Add one variable, a Fixed Point named MinGap with default 30, and tick Instance Editable. It is the least distance between the centers of neighboring units. Units whose footprints need more room get more. A formation may read its own variables, but it must never write them.

In My Blueprint, hover Functions and choose Override > Build Formation. A formation’s work is a function, not an event. It has three inputs: World, Members and Target, and returns a Sein Formation Layout.

Add two local variables on the function: Facing (Fixed Quaternion) and Length (Fixed Point).

Build the graph:

  1. Break Sein Order Target on Target. You use Anchor, Guide Points, Current Centroid and Current Facing. For a drag, the anchor is the midpoint of the dragged line, and Guide Points holds its two ends. For a click, Guide Points is empty.
  2. Gather Footprint Radii with World and Members. It returns each member’s footprint radius, index-aligned with Members. Keep it as Radii.
  3. Drag Facing Direction with Guide Points. It returns the direction a rank drawn along the drag faces, and the zero vector if there is no usable line. Branch on Is Nearly Zero Vector:
    • False (a drag). Set Facing to Facing From Direction of that direction. Set Length to Vector Distance between the first and last Guide Points (use Get with index 0, and Last Index).
    • True (a click). Set Facing to Compute Formation Facing with Current Centroid, Current Facing and Anchor. It points the formation from where the units are toward where they are going. Set Length to Fixed-point Zero.
  4. Spread 1D with Radii, Min Gap MinGap and Target Length Length. It returns one signed offset per unit along a line, centered on zero. Neighbors are never closer than their footprints, or MinGap. If Length is longer than the tight rank needs, the spare room is shared evenly across the gaps.
  5. Get Quaternion Right Vector of Facing. This is the direction along the rank.
  6. A For Each Loop over the offsets. For each, Add the Anchor and (the right vector Multiplyd by the offset). Add the result to a local array of Fixed Vector named Positions.
  7. Make Sein Formation Layout with Positions Positions, Radii Radii and Facing Facing. Return it.

Every node is from the SeinARTS Math Library, the Formation class or the struct nodes. They use fixed-point types. Do not use float nodes, random nodes or time nodes. Data validation reports them, because the formation runs in the simulation and a different answer on one machine desynchronizes the match.

The result must have one position per member, in the order of Members. Return the Radii too. Without them the framework cannot keep your units from overlapping.

On a drag, the line you draw is the front of the formation, and a deeper formation would extend behind it. A single rank is only a front, so the rank sits on the line. Which side the rank faces comes from the direction you drew: left to right faces one side, right to left the other.

You do not need to project onto walkable ground, separate overlapping slots, or compute per-unit facings. The framework does all three on your result (see Orders and Formations). A slot that lands on a cliff is moved to the nearest free cell, and the preview shows it moved.

Compile and save.

Open Project Settings > Plugins > SeinARTS and, under Orders, set Default Formation to SF_SkirmishLine. A drag now uses it. Turn on Enable Single-Click Formations (also under Orders) if a plain right-click should use it too. Otherwise a click still sends every unit to the point as a blob.

This setting affects the simulation, so every player in a match needs the same value.

Place a few units. Play, select eight Soldiers (radius 40) and:

  1. Right-click and drag a line across the level, about 800 units long. The preview markers form a single rank on the line, centered on it. The Soldiers are about 114 units apart: 800 divided by the 7 gaps between 8 units.
  2. Drag a short line, say 200 units. The rank cannot be shorter than the units need. Your graph spaces 8 Soldiers 80 units apart, and Separate Positions then opens them to about 105 (the two radii plus 25), so the rank is about 735 units wide.
  3. With Single-Click Formations on, click once. A tight rank forms on the cursor facing the direction of travel.
  4. Release a drag near a wall, so part of the rank falls inside it. The preview already shows the stray slots moved to open ground.
  5. Hold Shift, drag again. The second line queues behind the first.

You can leave Default Formation alone and nominate the line only for some drags. This uses three assets.

  1. Add the gameplay tag SeinARTS.Formation.SkirmishLine (use Add New Gameplay Tag in any tag picker).
  2. Create a Blueprint Class whose parent is Default Broker Resolver, named BP_BrokerResolver. In Class Defaults, add an entry to Formations By Tag: the tag above, and class SF_SkirmishLine. Set Default Broker Resolver Class (Orders settings) to BP_BrokerResolver. The stock tags for Box, Wedge, Ring, Square and Blob stay in the map.
  3. Create a Blueprint Class whose parent is Order Gesture, named OG_Skirmish. In Class Defaults, set Drag Formation Tag to the tag above. In your Player Controller Blueprint’s Class Defaults, set Order Gesture Class to OG_Skirmish.

Drags now use the Skirmish Line, and clicks follow the project rules. For finer control, override Build Order in the gesture: it receives the drag’s start, end and sampled path, and whether Shift was held, so it can pick a different tag for a long drag or a Shift drag. See Orders and Formations.

  • The units still gather in a blob. Default Formation is not set, or is None, or a click is used with Single-Click Formations off. A blob also results if Build Formation returned positions on top of each other and no radii.
  • SF_SkirmishLine is not in the Default Formation picker. The Blueprint did not compile, or its parent is not a formation. Open it and compile.
  • The match stops with an error after the first order. The formation wrote one of its own variables. A formation is stateless, and the framework checks that its variables are unchanged after every call. Use local variables, and set class variables only in Class Defaults.
  • The units overlap. The returned Radii were empty or short. Return one radius per member from Gather Footprint Radii.
  • Units end up in the wrong slots. That is expected: the framework swaps which unit takes which slot so paths do not cross. Position index in the result is not the unit that will stand there.
  • The rank faces the wrong way. Drag the other direction. The facing comes from the drag direction, and the rank faces one side of it.
  • Data validation flags a node. A float, random or time node is in the graph. Replace it with its fixed-point equivalent.
  • The preview and the order disagree. They should not: both call the same function. If they do, the formation read something that differs between machines.
  • A tag is mapped but nothing happens. The gesture must nominate the tag, and the resolver Blueprint must be the one named in Default Broker Resolver Class.