Sequences and Random Options

Documentation Unreal Engine Combat Framework AI Actions

Run several actions as one move: an ability, a Behavior Tree and an action graph combo in order, or one of them picked at random, repeatable from a seed.


One action can run other actions of its set: an ability attack, then a combo from the action graph, then a Behavior Tree that backs off, in order. Or one of them, picked at random by weight.

Set it up

3 minutes
  1. 1

    Add an action to the combo enemy's set

    Open ActionSet_UCF_ComboEnemy in Demo/Characters/ComboEnemy. Right-click the empty canvas, choose Add Action and set its Action ID to SlashThenCombo.
  2. 2

    Make it a sequence of two actions

    Open Execution Method and pick Action Sequence. Press + twice on Steps and set the two Action ID fields to SingleAttack and LightCombo, two actions the set already has.
    Details
    SlashThenCombo
    Execution
    Execution Method
    Action Sequence
    Sequence
    Steps
    2 Array elements
    Index [ 0 ]
    Action Id
    SingleAttack
    Weight
    1.0
    Index [ 1 ]
    Action Id
    LightCombo
    Weight
    1.0
    Pick One at Random
    Advanced
    Sequence Timeout
    0.0
    Payload
    Payload
    None
    Steps run top to bottom. Weight counts only once Pick One at Random is ticked.
  3. 3

    Tell it when to fire

    On the card's Scoring > Scorers list, add a Distance Scorer, and raise Selection Weight to 5 while you try it.
  4. 4

    Save, play, and watch both steps

    Save the Action Set, open LVL_UCF_Demo and press Play. Run UCF.Debug.EnemyActions 1 and UCF.Debug.Actions 1, then walk up to a combo enemy. SlashThenCombo turns yellow and stays yellow while the enemy plays its single attack and then the light combo, the action graph's node stepping through the combo above its head.
The demo's set carries both kinds already: AbilityComboTree runs an ability attack, a graph combo and a Behavior Tree move in that order, and EitherCombo picks one of its steps at random.

Run several actions as one

Action Sequence runs other actions of the same Action Set, named by their Action ID. Each step runs through its own action's execution method, with that action's own settings and payload, so any mix works: a Gameplay Ability attack, a Behavior Tree Sequence that walks in first, an Action Graph Combo from the action graph. The demo's AbilityComboTree shows the order: the ability plays first, the combo walks the graph next, and the Behavior Tree runs last.
One run of SlashThenComboTop to bottom
1
The AI picks the sequence
SlashThenCombo
Scored, gated and picked like any other action, and its own cooldown is charged as it starts.
2
Step 1 runs SingleAttack
SingleAttack's own execution method
Whatever SingleAttack runs, an ability or a Behavior Tree, runs here with SingleAttack's own settings and payload. The step ends when that method ends.
3
Step 2 runs LightCombo
Action Graph Combo
The combo walks the enemy's action graph. The step ends once the graph is back at idle.
4
The sequence ends
Completed
Its recovery time starts. SingleAttack and LightCombo keep their own cooldowns untouched, so the AI can still pick either one on its own.
A step that fails or is cut short ends the whole sequence with that step's reason, and the steps after it never run.
SettingDoes
StepsThe actions to run, by Action ID, top to bottom. Each one names another action in the same set.
WeightOn each step. How often it is picked against the others; read only with Pick One at Random ticked. 0 never picks it.
Pick One at RandomRuns one step picked by weight instead of every step in order. Off by default.
Sequence TimeoutBehind Advanced. 0 lets each step keep its own action's timeout. Above 0, this limit replaces theirs and restarts for each step that restarts its own, as a Behavior Tree Sequence does per tree. Reaching it ends the action with the Timed Out reason. The whole sequence also ends as Failed after 30 seconds of running, whatever its timeout says.
On the canvas, a sequence card lists its steps on its summary line.
CustomSlashThenCombo
Sequence: SingleAttack, LightCombo
Weight1
Cooldownnone
CustomAnyCombo
One of: LightCombo, HeavyCombo
Weight1
Cooldownnone
An Action Sequence card lists its steps on its summary line: Sequence for steps run in order, One of for a sequence that picks one step at random. A sequence draws no wire to the actions it names; a wire on this canvas is a chain link.

What counts once, and what each step keeps

The sequence is one action to the AI. Its own scorers and gates decide when it is picked, its own cooldown is charged as it starts, and its own recovery time follows it. The actions it names are only borrowed:
  • A step runs on the sequence's say-so. Its own scorers, gates and cooldown are not checked, and running it as a step charges none of its cooldown. The AI can still pick that action on its own between sequences.
  • A step brings its own payload and ability. An ability reading its action's payload reads the step's payload, and a Behavior Tree step's Activate Action Ability node starts the step's own Ability to Grant.
  • Keep each step's action Enabled. An unticked Enabled also stops that action's ability being granted, which leaves the step nothing to start. To keep the AI from picking a step on its own, set that action's Selection to Manual Only: a sequence still runs it.
A step that fails or is cut short ends the whole sequence with that step's reason, and the steps after it never run. An action ended early, by a reaction, a stun or a death, ends its running step with it.
A step cannot name another Action Sequence, so a sequence never runs itself: list that sequence's steps instead. Saving the Action Set refuses it in the Asset Check message log, along with an empty Action ID and a name the set does not have. An Action Sequence also cannot run as a reaction, since its steps come from the Action Set.

Pick one at random

Tick Pick One at Random and each run plays one step, drawn by Weight. The demo's EitherCombo works this way. In this one of your own, AnyCombo, LightCombo plays two times in three and HeavyCombo one time in three:
Details
AnyCombo
Sequence
Steps
2 Array elements
Index [ 0 ]
Action Id
LightCombo
Weight
2.0
Index [ 1 ]
Action Id
HeavyCombo
Weight
1.0
Pick One at Random
Each run plays one of the two combos: LightCombo two times in three, HeavyCombo one time in three.
The two kinds of randomness answer different questions:
UseWhen the choice is between
An Action Graph Combo with several VariantsInput lists played on one action graph: three light attacks, or a light into a heavy. See Action Graphs in Action Sets.
An Action Sequence with Pick One at RandomWhole actions of any kind: a combo, an ability, a Behavior Tree.

Three ways to combine actions

WayWhat the AI doesSet it on
A chain linkFavors the follow-up for a moment after an action ends. The AI may still pick something else, and the follow-up runs as its own action, with its own cooldown.The first action's Chain Links, or a wire between two cards. See Action Set Editor.
An Action Sequence in orderCommits to every step, one after another, as one action.A new action naming the steps.
An Action Sequence that picks oneCommits to one step, drawn by weight.The same, with Pick One at Random.
A chain link works across every execution method, so an ability attack can lead into a graph combo and on into a Behavior Tree move with nothing but wires on the canvas. Reach for a sequence when the moves must always come together.

Repeat it exactly

Variant picks and random steps come from the enemy's own random stream. Tick Deterministic on the enemy's AI Config and the enemy picks the same variants and the same steps in the same order every run, built from Default Seed like the rest of its choices. Two enemies sharing one config still pick differently from each other, since each mixes the seed with its own name.
Give a combo enemy seed 7 and every fight draws its combo variants in the same order as the fight before. See Determinism for the seed, the start barrier and how to prove a fight repeats.

Debug it

RunShows
UCF.Debug.EnemyActions 1The sequence in yellow for its whole run, above the enemy's head.
UCF.Debug.Actions 1The node the enemy's action graph stands in while a combo step plays.
UCF.Debug.Scoring 1What the sequence scored at the last decision.
SymptomCause
The card's summary line is red and ends in (incomplete)No steps, a step with no Action ID, or Pick One at Random with every weight at 0.
The sequence starts and fails at onceA step names an action the enemy's current Action Set does not have, or another Action Sequence. The log warns under LogUCFBridge with the step's name.
A step's ability never startsThat action is unticked Enabled, so its ability was never granted.
The sequence ends earlyA step failed or was cut short; the sequence ends with that step's reason.
MultiplayerWhere it runs
A sequence runs on the server, like every execution method, and each step with it. Other machines see each step the way they see that action on its own: an ability's montage, a combo's moves through the enemy's animations.
C++C++
The method is UUCFActionSequenceExecutionMethod in the UCFBridge module; a step is FUCFActionSequenceStep (ActionId, Weight). PickSteps(Owner) returns the step indices a run plays, empty when nothing can run.
Each step duplicates the named action's execution method, found through UActionEvaluationComponent::FindActionSpec, and drives the copy through its own begin, tick and abort. The next step starts on the sequence's next tick, never inside the callback that ended the last one. GetPayload, GetAbilityToGrant and GetAbilityActivationPlan answer with the running step's, and CanRunAsReaction returns false.