Orders and Formations
A player gives one order to many units. The framework has to answer three questions for that order: what does each unit do, where does each unit stand, and what happens to the orders the units already have.
Each question has one owner. The unit’s Default Commands say what it does. A formation says where it stands. A broker holds the order, queues it behind the previous one and hands it to its members. Nothing in this chain is a fixed list of verbs: the verbs are your ability Blueprints.
From click to ability
Section titled “From click to ability”A right-click on the battlefield runs these steps:
- Gesture. The Player Controller watches the button. A press and release inside 10 screen pixels is a click. Further than that is a drag. An Order Gesture turns the click or drag into guide points and an optional formation tag.
- Context. The Player Controller builds a set of tags describing what is under the cursor: ground, a friendly, a neutral or an enemy unit, and that unit’s own tags.
- Submit. Issue Smart Command sends one command through lockstep with the selected units, the context, the target, the guide points, the formation tag and whether Shift was held. This is all that crosses the network. The formation’s result never does: every machine computes it again from the same inputs.
- Broker. The simulation moves the units into a broker, an entity that holds the order for them.
- Resolve. The broker’s resolver gives each unit an ability by matching the context against that unit’s Default Commands, and asks a formation for each unit’s slot. A ground order sends each unit to its own slot. An order on a target sends every unit at the target.
- Activate. Each unit activates its ability with that destination or target. If the order is not queued, the new ability cancels the one before it through its Cancel Abilities With Tag setting.
The destination preview you see while dragging runs the same code as step 5, so what you see is what the units get. See Destination preview.
Smart commands and context
Section titled “Smart commands and context”The context is a set of gameplay tags (see Gameplay Tags). A right-click always carries SeinARTS.Command.Context.RightClick and exactly one target tag:
| Tag | When it is added |
|---|---|
SeinARTS.Command.Context.Target.Ground |
Nothing selectable is under the cursor |
SeinARTS.Command.Context.Target.Friendly |
The unit under the cursor belongs to the player |
SeinARTS.Command.Context.Target.Neutral |
It belongs to the neutral player, such as a mineral rock |
SeinARTS.Command.Context.Target.Enemy |
It belongs to any other player |
When a unit is under the cursor, its own tags join the context: its identity tag (SeinARTS.Unit.Truck) and state tags such as SeinARTS.State.UnderConstruction. A mapping can require what the target is, not only whose it is.
An ability started from a button instead of a right-click carries SeinARTS.Command.Context.AbilityTriggered and its own ability tag. The resolver then skips the Default Commands lookup and activates that ability on the units that hold it.
Enemy means “owned by another player”. An allied player’s unit gets Target.Enemy, because the tag compares owners and does not consult diplomacy. If allies should count as friendly, override Build Command Context on your Player Controller Blueprint: call the parent, then remove Target.Enemy and add Target.Friendly when Should Present Player As Friendly says so.
Default commands
Section titled “Default commands”A unit decides for itself which ability a context means. On the unit’s Sein Abilities component, Abilities > Default Commands is a list of mappings:
| Field | Meaning |
|---|---|
| Required Context | Tags that must all be present. A requirement for SeinARTS.Unit.Truck is also met by a child tag, such as SeinARTS.Unit.Truck.Armored |
| Ability Tag | The ability to activate |
| Priority | Higher wins. On equal priority the entry listed first wins |
The unit takes the highest-priority mapping whose Required Context is entirely present. If none matches, it uses Fallback Ability Tag on the same component. If that is empty too, the unit takes no part in the order and stays where it is, unless the resolver names a tag-along ability (see Resolvers).
The Soldier in the demo collects five mappings over its chapters:
| Required Context | Ability | Priority |
|---|---|---|
Right Click, Target Friendly, SeinARTS.Unit.Truck |
Load | 10 |
Right Click, Target Friendly, SeinARTS.State.UnderConstruction |
Build | 10 |
| Right Click, Target Enemy | Attack | 10 |
| Right Click, Target Neutral | Mine | 5 |
| Right Click, Target Ground | Move | 0 |
Each mapping requires a different combination of tags, so no two can match one target. A friendly Truck matches Load. A friendly building under construction matches Build. A plain friendly unit matches nothing, so the unit takes its fallback. See Add the Truck for Load and Add Movement for Move.
Every unit in a mixed selection resolves on its own. Select Soldiers and a Truck, right-click ground, and each runs its own Move. Right-click an enemy, and the Soldiers attack while the Truck, whose table has no mapping for it, stays where it is.
Move Ability on the same component names the ability the framework uses when a unit has to walk on its own: to the edge of an out-of-range target through Auto Move Then, or to a rally point. It needs a granted, non-passive Point ability.
Brokers
Section titled “Brokers”A broker is the entity that holds an order for its member units. Every order runs through one: when a player orders a selection, the simulation puts those units into a broker, and a unit belongs to one broker at a time, so ordering it again moves it to the new one.
The broker is where the group’s shared state lives, because none of it belongs to a single unit:
- The order queue, with one entry per order and the context each was given.
- The members’ centroid and the anchor facing of the last order.
- The settled slots: the slot positions and facings of the last ground order, so units can re-form where the formation stands.
Read a broker from Blueprint with Get Current Broker (a unit’s broker), Get Broker Members, Get Broker Centroid, Get Broker Queue Length and Get Broker Order Context. See the orders library for each. The broker data itself is Sein Broker Data.
A broker normally disappears once its members and queue are empty. A game that keeps standing groups sets its broker to survive an empty member list and gives it its own resolver.
Queues
Section titled “Queues”A plain order replaces what the units are doing. An order with Shift held appends: it joins the back of the broker’s queue and starts when the members finish the order before it. A drag with Shift held queues a formation order the same way.
Orders that share members run one after another. Orders for different members, such as a repair order for one unit while the rest keep walking, run at the same time. When a queued order covers only some of a broker’s members, those members get the order for themselves.
From a graph, Issue Broker Order takes the same inputs the Player Controller does. Turn on Queue Command to append. An AI controller or a scenario uses Issue Broker Order For Player.
Resolvers
Section titled “Resolvers”The resolver is the policy object behind a broker. For each order it decides which members run which abilities against which targets, and where each member stands. The default is Default Broker Resolver. The project picks it in Project Settings > Plugins > SeinARTS > Orders > Default Broker Resolver Class.
The default resolver works in this order:
- Takes the members the order covers.
- Asks the formation for one slot per member.
- For each member, finds the ability its Default Commands give for the context and dispatches it. A ground order targets the member’s own slot. An entity-targeted order targets the entity, and each ability handles getting into range.
- A member with no matching ability is skipped, unless Tag Along Ability is set. That ability is then dispatched to the member’s slot, so units that cannot act on the order still travel with the group. It is empty by default.
To change the policy, create a Blueprint Class whose parent is Default Broker Resolver (or Broker Resolver for a policy of your own), and point the project setting at it. Its Class Defaults hold:
| Setting | Meaning |
|---|---|
| Default Formation Class | The formation this resolver uses when the order names none. Empty falls back to the project’s Default Formation |
| Formations By Tag | Maps a formation tag, as an Order Gesture nominates, to a formation. Ships with Box, Wedge, Ring, Square and Blob |
| Reassign Slots Lateral / Depth | Re-match units to slots so a moving formation does not make them cross paths. Both on is a full two-axis match; both off keeps the formation’s slot order |
| Tag Along Ability | The ability for members that cannot act on the order |
You can also override these events on the resolver Blueprint:
- Resolve Member Ability picks the ability for one member and context. Return an empty tag to skip the member. Use it for rules the Default Commands table cannot express, such as “workers prefer Repair on a damaged friendly”.
- Resolve Dispatch produces the whole plan. Call Apply Ability Dispatch Policy from it to keep each ability’s own Dispatch Mode (see Abilities).
- Post Process Positions adjusts the positions after the layout, for example to snap units onto authored standing points.
Resolver overrides run inside the simulation. Use fixed-point nodes and no random or time nodes, or peers desynchronize.
Setting Default Broker Resolver Class to None turns group dispatch off: a right-click on a multi-unit selection no longer fans out. Single units still receive their order.
Gestures
Section titled “Gestures”An Order Gesture interprets the click or drag. The default one does this:
- Click. With Enable Single-Click Formations off (the default), it nominates the Blob formation: every unit goes to the clicked point, and the framework spaces them so none overlap. With it on, a click spreads the units in the project’s Default Formation, centered on the cursor.
- Drag. It sends the line from press to release as the guide, with the formation named by its Drag Formation Tag. That tag is empty by default, which means the project’s Default Formation. The order’s anchor is the midpoint of the drag.
The Player Controller samples the cursor every Command Drag Sample Distance (100 units by default) while you drag, and a gesture with Forward Full Path on sends all of those points instead of just the two ends.
To change how drags behave, create a Blueprint Class whose parent is Order Gesture, override Build Order, and set Order Gesture Class in the Player Controller Blueprint’s Class Defaults. Build Order receives whether it was a drag, the start, end and sampled path in world space, and whether Shift was held, and returns guide points and a formation tag. A gesture runs on the issuing machine only, so it may use ordinary floating-point math. Its result is baked into the command.
The preview and the order call the same gesture, so a change shows in the preview at once.
Formations
Section titled “Formations”A formation turns “these units, this target” into one position per unit. It does not choose abilities. It is pure computation: the same inputs always give the same positions, and it may not change simulation state. The framework runs a formation on a scratch copy and stops the match if a call changes the formation’s own variables.
The stock formations:
| Formation | Shape | Settings |
|---|---|---|
| Blob | Every unit goes to the anchor. The framework then spreads them so none overlap | None |
| Grid | A tight square-ish block, rotated to face the move | None that has an effect. Its Inter Unit Spacing is not read |
| Box | Rank and file. On a drag, the drawn line is the front rank and the block fills in behind it | Inter Unit Spacing, 150 |
| Wedge | Hollow nested chevrons with a tip out front | Inter Unit Spacing, 0. Half Angle Degrees, 45 |
| Ring | Concentric rings around the point, with an empty center | Inter Unit Spacing, 0 |
| Square | A hollow square outline, with nested squares for large selections | Inter Unit Spacing, 0 |
Inter Unit Spacing is in world units. On Box it is the smallest cell of the block, and a smaller unit takes a whole cell. On Wedge, Ring and Square it is extra room added to the gap between footprints, so 0 means footprints touch. All shapes space slots by each unit’s real footprint (see Collision and Extents), so a Truck gets a bigger slot than a Soldier, and the largest units sit front and center.
Ring and Square default Facing Mode to Radial Outward, so each unit faces away from the center. Other shapes use Uniform, where everyone faces the formation’s direction. Radial Inward turns units toward the center.
On a drag, the line you draw is the front of the formation, and the body extends behind it. A plain click centers the formation on the cursor, facing the direction of travel.
Two project settings choose the shape. Under Project Settings > Plugins > SeinARTS > Orders:
| Setting | Default | Meaning |
|---|---|---|
| Default Formation | Box | What a drag uses, and what a single click uses when Enable Single-Click Formations is on. None gives no shape: units arrive as a blob |
| Settle To Formation Facing | On | After arriving on a slot, a unit turns at its Turn Rate to the slot’s facing. Off, units keep the heading they travelled |
Whatever shape a formation returns, the resolver then runs the same four steps on it, which is why even a rough custom formation ends up clean:
- Separate Positions pushes apart any two slots closer than the sum of their footprint radii plus 25 units.
- Reassign slots swaps which unit takes which slot so paths do not cross. It swaps only between units of the same footprint radius.
- Project Positions To Navigable moves any slot that is off the walkable area, or on top of a parked unit, to the nearest free cell.
- Post Process Positions runs your resolver override, and per-unit facings are computed last.
To write your own, see Author a custom formation.
Destination preview
Section titled “Destination preview”While the player drags, markers show where each unit will stand. They come from the same layout the command uses, so a slot pushed off a cliff edge shows already moved.
A unit draws a marker only if its Blueprint has a SeinARTS Navigation Renderer component. On a group’s actor it opts in every member. The component’s Preview Actor Class, or the project’s Formation Preview Actor Class (under Orders), picks the renderer. The default draws flat meshes. Two alternatives, decal and instanced mesh, ship alongside it. The Truck in the demo adds a Navigation Renderer with a Marker Material.
To issue exactly what you showed, such as a custom UI that previews and then confirms, use Plan Formation Order. It returns the planned positions and a one-use token. Pass the token to Issue Formation Order, and the units go to the planned points even if other units moved since.
Example: a river crossing
Section titled “Example: a river crossing”Eight Soldiers and a Truck stand in a clearing. The Soldiers carry the mappings above. The Truck has one: Right Click with Target Ground maps to Move.
The player selects all nine and drags a 1,200-unit line across the far bank.
- The gesture sends two guide points and no tag. The anchor is the midpoint of the line.
- Every unit’s context is Right Click and Target Ground. The Soldiers resolve to Move through their priority 0 mapping, and so does the Truck.
- The default resolver asks the project’s Default Formation, Box. Its front rank spans the drag. The Truck, the biggest footprint, takes the center of the front rank, and Soldiers fill the two ranks on each flank beside it. No two slots overlap.
- A slot that lands in the river is moved to the nearest free bank cell.
- The preview showed all of that while the player dragged. Releasing sends one command. Each unit’s Move runs against its own slot.
- The player holds Shift and drags a second line. It queues behind the first. The units start walking it only after they arrive.
Now the player selects the Soldiers only and right-clicks the Truck. The context is Right Click, Target Friendly and SeinARTS.Unit.Truck. Load matches at priority 10 and beats the generic fallback, so they walk to it and board.
Common mistakes
Section titled “Common mistakes”- Equal priorities. Two mappings that can both match at the same priority resolve to whichever is listed first. Give the more specific one a higher number.
- A mapping that cannot occur. A mapping that requires
Target.GroundandSeinARTS.Unit.Trucknever matches: a ground click has no target tags. - Expecting allies to be friendly.
Target.Friendlyis the player’s own units. See Smart commands and context. - Editing the resolver Blueprint without selecting it. Your resolver does nothing until Default Broker Resolver Class names it.
- Writing variables in a formation. A formation Blueprint that sets one of its own variables stops the match. Use local variables.
- No formation at all. A Default Formation of None, or a resolver with none, sends units to one point as a blob. That is valid, but not what most players expect from a drag.
- A tiny drag. A drag under 10 screen pixels is a click.
- Choosing abilities in a formation. A formation only places units. Choose abilities in Default Commands or the resolver.
Related
Section titled “Related”- Add Movement and Add the Truck for Default Commands in practice
- Abilities for what an order activates, and Gameplay Tags for the context tags
- Movement for what a unit does with the destination it is given
- Collision and Extents for the footprints formations space by
- Author a custom formation
- Orders reference, Formation, Broker Resolver and Orders settings