Skip to content

Combat Template ProOnly¶

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, and Combat.Hero.Transition.Combo let 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

  1. The player presses Attack. An ActionInput_Transition fires, and the state machine enters the Attack 1 state.
  2. Attack 1 plays a montage via StateClass_PlayMontage.
  3. During the montage, notify windows trigger gameplay events at specific animation frames:
    • ActivateHitBox_NotifyState activates hit detection during the damage window, using the AttackProperties configured on the notify.
    • Combo_NotifyState opens a combo window by adding a gameplay tag. If the player presses Attack again during this window, ActionInput_Transition (with its Required Tag set to the combo tag) transitions to Attack 2.
    • Breakout_NotifyState adds a tag that allows canceling into a dodge.
  4. On the receiving end, a Damaged_Transition fires on the hit character, routing through FilterAttackPower_Transition and FilterAttackDirection_Transition to 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.Dead tag.
  • 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:

  1. CheckActive waits for the player to come within range.
  2. 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.
  3. Attack Selection is a conduit that picks between light and heavy attacks based on RandomChance_Transition.
  4. ATK - Light / ATK - Heavy are attack states using StateClass_PlayMontage. Animation notifies handle hit detection and damage.
  5. Attack Cooldown Movement is a nested state machine with brief recovery movement after attacking.
  6. DEF - Dodge is triggered if the enemy is damaged during an attack.
  7. Reset Cycle resets the state machine to restart the loop.
  8. 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:

  1. Locomotion is the idle/movement state. Input transitions lead to attacks, hold attacks, or healing.
  2. Attack combo chain. Attack 1 chains to Attack 2 chains to Attack 3 via ActionInput_Transition with a Combo required tag. The Combo_NotifyState on each attack montage opens the combo window during specific animation frames: no window, no combo.
  3. 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.
  4. Dodge is reachable from any state when the breakout window is open. A conduit checks LeftStickEngaged_Transition to choose between forward and backward dodge. After dodging, the player can chain into Attack 1.
  5. Hit Reaction is entered via Damaged_Transition from any state, routed through a filter for impact vs. stagger reactions.
  6. Heal Potion plays a potion montage via StateClass_PlayMontage. The montage includes a HeroHeal_AnimNotify that restores health.
  7. 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.

  1. Set up the character hierarchy. Have your characters inherit from Character_Base, Player_Base, or Enemy_Base. This gives you gameplay tag management and damage handling out of the box.

  2. Add components. Attach DamageHandler_Component to characters that can deal and receive damage. Add AI_Controller_Component to AI enemies.

  3. Create animation montages. Add the template's animation notify states to your attack montages. At minimum, add ActivateHitBox_NotifyState during the damage window and Combo_NotifyState during the combo window.

  4. Build state machines. Use the template's state and transition classes to build your combat flow. StateClass_PlayMontage and StateClass_AIMoveTo cover the most common needs. Compose transitions from the provided types.

  5. 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¶

  • AttackProperties is a struct containing attack damage, direction tag, and power tag. Passed from ActivateHitBox_NotifyState to the DamageHandler_Component.
  • PlayerActions is an enum for player action types used by ActionInput_Transition.
  • EnemyMoveTo is an enum for enemy movement patterns used by StateClass_AIMoveTo.
  • CombatFunctionLibrary is a Blueprint function library with shared utility functions.
  • BI_EnemyAnim_Notify is an interface for enemy animation callbacks.
  • BI_PlayerManagement is an interface for player management systems.