Combat Template
¶
The Combat template is a content sample that demonstrates a complete third-person melee combat system driven by Logic Driver state machines. Players can chain light attacks into combos, charge heavy attacks, dodge out of recovery frames, and heal, all controlled through state machines and animation timing. Enemies use AI state machines to move to and around the player, engage, and dodge.
This template is not meant to be production ready out of the box. It is designed as a starting point that you can adapt to fit your game's combat needs.
Prerequisites
Familiarity with Custom Node Classes, State Stacks, and Transitions will help you get the most out of this template. Knowledge of Unreal's Animation Montages, Animation Notifies, and Gameplay Tags is also recommended.
Installation¶
Install the template from the Logic Driver utility launcher under Content Samples. See Content Samples for details.
Once installed, the template creates two directories:
- Template/ contains reusable core files: state classes, transition classes, state stacks, animation notifies, base characters, components, enums, structs, interfaces, and a function library. These do not depend on any shared plugin content.
- Samples/ contains a complete working combat example with player and enemy characters, animation assets, state machines, UI, and a playable map.
Architecture Overview¶
The combat system is built around four pillars.
-
State Machines
Drive all combat behavior for both the player and AI enemies. Each character has a state machine that manages locomotion, attacks, hit reactions, and death.
-
Animation Notifies
Bridge the gap between animations and gameplay. Notifies placed on montage timelines define when hit detection activates, combo windows open, and movement adjustments happen.
-
Gameplay Tags
Control state transitions and manage character status. Tags like
Combat.Dead,Combat.Invulnerable, andCombat.Hero.Transition.Combolet transitions query character state without tight coupling. -
Components
Handle damage detection, AI control, and input tracking. Attach them to characters to give them combat capabilities without modifying the character class itself.
How It Works: The Combat Loop¶
The combat system follows a loop: input (or AI decision) -> state machine transition -> animation montage -> animation notifies -> gameplay effects -> next transition. Understanding this loop is the key to working with the template.
A typical player attack
- The player presses Attack. An
ActionInput_Transitionfires, and the state machine enters the Attack 1 state. - Attack 1 plays a montage via
StateClass_PlayMontage. - During the montage, notify windows trigger gameplay events at specific animation frames:
ActivateHitBox_NotifyStateactivates hit detection during the damage window, using theAttackPropertiesconfigured on the notify.Combo_NotifyStateopens a combo window by adding a gameplay tag. If the player presses Attack again during this window,ActionInput_Transition(with itsRequired Tagset to the combo tag) transitions to Attack 2.Breakout_NotifyStateadds a tag that allows canceling into a dodge.
- On the receiving end, a
Damaged_Transitionfires on the hit character, routing throughFilterAttackPower_TransitionandFilterAttackDirection_Transitionto the appropriate hit reaction.
The pattern is: state machines define what happens, animation notifies define when it happens, and gameplay tags connect the two.
Tip
When creating new attack montages, the placement of notify windows is everything. Moving the combo window earlier makes attacks feel snappier and more forgiving. Moving the breakout window later gives attacks more commitment. Experiment with timing to find the feel you want.
Characters¶
Three base character Blueprints form the character hierarchy:
Character_Base is the root class. It provides gameplay tag management, attribute stats (health, damage scalar), and health tracking. All characters in the system inherit from this.
Player_Base extends Character_Base with player-specific input tracking and a configurable hold duration for charging heavy attacks (default: 0.2 seconds).
Enemy_Base extends Character_Base with AI-specific defaults. Its AI controller class is set to AI_Controller_Component.
Components¶
AI_Controller_Component is a DetourCrowdAIController that handles AI navigation and sensing for enemies. Attached to enemy characters via the AIControllerClass default on Enemy_Base.
DamageHandler_Component manages hit box activation, hit detection via component overlap, and damage calculation. It checks gameplay tags (Combat.Dead, Combat.Invulnerable) on targets before applying damage, tracks which targets have already been hit to prevent duplicate damage within a single attack, and checks instigator type to prevent enemies from damaging other enemies.
Template Building Blocks¶
These are the reusable classes you configure when building combat state machines. Each section covers only the properties you actively set on nodes in the state machine graph.
State Classes¶
StateClass_PlayMontage¶
The workhorse state class. Plays an animation montage when the state begins. Most combat states use this.
| Property | Description |
|---|---|
| Montage To Play | The animation montage to play when this state is entered |
| Starting Position | The starting position within the montage (0.0 to 1.0) |
| Reset State Machine On Anim End | Whether to reset the owning state machine when the animation finishes |
| Tag To Add | An optional gameplay tag to add while this state is active and remove when it ends |
StateClass_AIMoveTo¶
Moves an AI character toward a target. Used in enemy movement states.
| Property | Description |
|---|---|
| Selection | The movement pattern to use: move to player, strafe, or retreat (from EnemyMoveTo enum) |
| Acceptance Radius | How close the AI must get to the target to consider movement complete |
Transition Classes¶
The template includes 12 reusable transition classes, each checking a specific condition. These are the ones with properties you configure on graph nodes:
| Transition | Properties | Description |
|---|---|---|
| ActionInput_Transition | Selection (attack, dodge, heal), Required Tag |
Fires on player input. Supports combo windows and hold attacks via event-driven evaluation |
| DelayTime_Transition | Delay Time, Random Time Variance |
Fires after a time delay with optional random variance |
| FacingPlayerArc_Transition | Forward Arc (degrees), Inverse |
Fires when the enemy is (or is not) facing the player within an arc |
| FilterAttackDirection_Transition | Attack Direction Required |
Filters by attack direction tag (Left or Right) |
| FilterAttackPower_Transition | Attack Power Required |
Filters by attack power tag (Impact or Stagger) |
| PlayerWithinRange_Transition | Range, Inverse |
Fires when the player is within (or outside) a distance |
| RandomChance_Transition | Chance (0--100) |
Fires based on a random probability check |
| TagCheck_Transition | Tag To Check, Inverse |
Fires when a gameplay tag is (or is not) present on the character |
The remaining transitions have no per-node properties. They fire based on events or character state:
- Damaged_Transition fires when the character receives damage.
- Killed_Transition fires when the character has the
Combat.Deadtag. - LeftStickEngaged_Transition fires when the player has directional input.
- PreviousStateEnd_Transition fires when the previous state's animation completes.
Animation Notifies¶
Animation notifies are placed on montage timelines to trigger gameplay events at specific animation frames. The template includes 10 notify states (window-based) and 1 single-frame notify.
ActivateHitBox_NotifyState is the most important notify. During its window, hit detection is active and any overlapping character takes damage.
| Property | Description |
|---|---|
| Attack Properties | The attack properties struct: damage amount, direction tag, and power tag applied to targets hit during this window |
| Hit Box | Which hit box component to activate (default: HitBox_Weapon) |
Combo_NotifyState opens a combo window by adding a gameplay tag. The ActionInput_Transition checks for this tag, so the player can only chain attacks during this window.
| Property | Description |
|---|---|
| Tag | The gameplay tag to add during the combo window (typically Combat.Hero.Transition.Combo) |
Breakout_NotifyState adds a tag that allows the player to cancel the current action, such as dodging out of attack recovery.
| Property | Description |
|---|---|
| Tag | The gameplay tag to add during the breakout window (typically Combat.Hero.Transition.Breakout) |
AddTag_NotifyState is a general-purpose notify that adds any gameplay tag for its duration and removes it when the notify ends.
| Property | Description |
|---|---|
| Tag | The gameplay tag to add and remove |
Movement and rotation notifies
These notifies handle the movement adjustments that make melee combat feel responsive. They are configured on the montage timeline and rarely need their defaults changed.
PlayerHoming_NotifyState moves the player toward the nearest enemy during attacks. Properties: RInterp Speed (rotation, default: 20), VInterp Speed (translation, default: 3), Distance (max homing range, default: 200).
EnemyTargetRotation_NotifyState rotates enemies toward the player during attacks. Respects Combat.Dead, Combat.Invulnerable, and Combat.Status.InDodge tags. Property: RInterp Speed (default: 0.4).
EnemyTargetTranslation_NotifyState translates enemies toward their target during attacks. Properties: VInterp Speed (default: 0.08), Distance (default: 100).
AllowPlayerAnimRotation_NotifyState allows the player to rotate toward their input direction during attack animations.
AnimPlayRate_NotifyState controls animation playback speed during specific windows. Property: Global Play Rate (default: 1).
EnemyStopLookPoses_NotifyState disables enemy look-at poses during its window.
HeroHeal_AnimNotify is a single-frame notify (not a window) that restores player health.
| Property | Description |
|---|---|
| Heal Amount | Amount of health to restore (default: 100) |
State Stacks¶
State Stacks run alongside the active state, providing layered behavior without duplicating logic. The template includes three:
| State Stack | Property | Description |
|---|---|---|
| FaceDamageInstigator_StateStack | Set Face Damage Instigator |
Rotates the character to face whoever damaged them |
| FaceInputDirection_StateStack | Face Input Direction |
Rotates the character to face the direction of player input |
| ResetStateMachine_StateStack | Reset State Machine |
Resets the owning state machine, useful for returning to idle after a sequence |
State Machines¶
StateMachine_Base is the base state machine class (SMInstance) for all combat state machines. It caches references to the character, AI controller, and damage handler component on startup. Both the player and enemy state machines inherit from this.
Enemy_StateMachine drives the full combat AI loop. The enemy cycles through phases: check if the player is nearby, move toward them, pick an attack, execute it, then cool down before repeating.
Phase breakdown:
- CheckActive waits for the player to come within range.
- Move To Target is a nested state machine where the enemy navigates toward the player using
StateClass_AIMoveTo, randomly choosing between direct approach and strafing. - Attack Selection is a conduit that picks between light and heavy attacks based on
RandomChance_Transition. - ATK - Light / ATK - Heavy are attack states using
StateClass_PlayMontage. Animation notifies handle hit detection and damage. - Attack Cooldown Movement is a nested state machine with brief recovery movement after attacking.
- DEF - Dodge is triggered if the enemy is damaged during an attack.
- Reset Cycle resets the state machine to restart the loop.
- Death is the end state, reachable from any state via
Killed_Transition.
Any State transitions handle death and hit reactions from any state. The hit reaction filter conduit routes to either HitReactions_Fodder or HitReactions_Elite.
Hit Reaction State Machines
Hit reactions are handled by separate nested state machines based on enemy type.
HitReactions_Fodder handles basic enemies with directional impact reactions. Impact hits produce a left or right flinch, then the enemy may dodge away based on a random chance check. Stagger hits play a stronger animation.
HitReactions_Elite routes through an attack power filter to a stagger state, followed by a retaliation check conduit that can lead to a counterattack.
HitReactionsFlinches_Elite is a flinch sub-system that plays direction-based flinch animations on elite enemies via an Any State damaged transition.
Player_StateMachine drives the player's combat actions. It uses ActionInput_Transition for input-driven state changes and combo windows for attack chaining.
How the player flows through combat:
- Locomotion is the idle/movement state. Input transitions lead to attacks, hold attacks, or healing.
- Attack combo chain. Attack 1 chains to Attack 2 chains to Attack 3 via
ActionInput_Transitionwith aComborequired tag. TheCombo_NotifyStateon each attack montage opens the combo window during specific animation frames: no window, no combo. - Hold Attack is triggered when the player holds the attack button longer than the hold activation duration. Can be entered from locomotion or after a combo finishes.
- Dodge is reachable from any state when the breakout window is open. A conduit checks
LeftStickEngaged_Transitionto choose between forward and backward dodge. After dodging, the player can chain into Attack 1. - Hit Reaction is entered via
Damaged_Transitionfrom any state, routed through a filter for impact vs. stagger reactions. - Heal Potion plays a potion montage via
StateClass_PlayMontage. The montage includes aHeroHeal_AnimNotifythat restores health. - Death is the end state via
Killed_Transition.
Gameplay Tags Reference¶
The combat system uses gameplay tags for status management and transition conditions.
| Tag | Purpose |
|---|---|
Combat.Dead |
Character is dead |
Combat.Invulnerable |
Character cannot take damage |
Combat.Status.InDodge |
Character is in a dodge |
Combat.Status.Dummy |
Marks a character as a dummy (non-combat) |
Combat.Hero.Transition.Combo |
Combo window is open (player can chain attacks) |
Combat.Hero.Transition.Breakout |
Breakout window is open (player can cancel into dodge) |
Combat.Hero.Transition.HoldAttack |
Heavy attack has been charged |
Combat.Hero.Transition.HoldAttackEarly |
Heavy attack charge started early in the combo |
Combat.Hero.Transition.NoDefensive |
Defensive actions (dodge, heal) are blocked |
Combat.Hero.Controls.HoldingAttackAction |
Attack button is currently held down |
Combat.AttackProperties.Direction.Left |
Attack came from the left |
Combat.AttackProperties.Direction.Right |
Attack came from the right |
Combat.AttackProperties.AttackPower.Impact |
Impact power (lighter hit reaction) |
Combat.AttackProperties.AttackPower.Stagger |
Stagger power (heavier hit reaction) |
Health.Current, Health.Max, and Damage.Scalar are used as attribute keys in the character's AttributeStats map, not as gameplay tags for status checks.
Integrating Into Your Project¶
Tip
Start by getting a single attack working end-to-end before building out the full combat system. One state with a montage, one ActivateHitBox_NotifyState, and one Damaged_Transition on the target is enough to see the whole loop in action.
-
Set up the character hierarchy. Have your characters inherit from
Character_Base,Player_Base, orEnemy_Base. This gives you gameplay tag management and damage handling out of the box. -
Add components. Attach
DamageHandler_Componentto characters that can deal and receive damage. AddAI_Controller_Componentto AI enemies. -
Create animation montages. Add the template's animation notify states to your attack montages. At minimum, add
ActivateHitBox_NotifyStateduring the damage window andCombo_NotifyStateduring the combo window. -
Build state machines. Use the template's state and transition classes to build your combat flow.
StateClass_PlayMontageandStateClass_AIMoveTocover the most common needs. Compose transitions from the provided types. -
Configure gameplay tags. The template's tag hierarchy (
Combat.*) is designed to be extended. Add your own tags for new status effects, attack types, or transition conditions.
State Stacks
Use state stacks for behaviors that should run alongside any state, like facing the damage source or input direction. See State Stacks for details.
Other Template Files¶
AttackPropertiesis a struct containing attack damage, direction tag, and power tag. Passed fromActivateHitBox_NotifyStateto theDamageHandler_Component.PlayerActionsis an enum for player action types used byActionInput_Transition.EnemyMoveTois an enum for enemy movement patterns used byStateClass_AIMoveTo.CombatFunctionLibraryis a Blueprint function library with shared utility functions.BI_EnemyAnim_Notifyis an interface for enemy animation callbacks.BI_PlayerManagementis an interface for player management systems.
Related Guides¶
- Custom Node Classes -- Creating custom state and transition classes
- State Stacks -- Running parallel state behaviors
- Transitions -- Transition evaluation and configuration
- Content Samples -- Installing and managing content samples