AI Combat Coordinator System

System Summary

Implemented a centralized AI combat coordination system that manages multiple enemies engaging the player simultaneously. Instead of all enemies attacking at once, the system evaluates nearby AI, grants attack permission to one attacker at a time, and organizes other enemies into surrounding positions while they wait for their turn.

This creates controlled combat encounters that maintain pressure on the player while avoiding chaotic crowd attacks.


Design Goals

  • Prevent enemies from overwhelming the player

  • Maintain constant combat pressure

  • Ensure combat encounters remain readable

  • Create the illusion of coordinated enemy tactics

What I Built

Responsibilities

  • Designed and implemented a centralized AI Combat Coordinator

  • Created an attack permission system that selects which AI can attack

  • Implemented an AI queue system for managing waiting enemies

  • Built a suspicion meter that determines when enemies join combat

  • Integrated the coordinator with Unreal Behavior Trees and Blackboards

  • Developed circling behavior for waiting enemies

  • Implemented logic for attack completion and next attacker selection

Enemy Detects Player

Suspicion Meter Fills

AI Registers With Combat Coordinator

Coordinator Adds AI To Attack Queue

Coordinator Selects Current Attacker

Selected AI Executes Attack Behavior

Attack Finishes

Coordinator Selects Next AI


Technical Breakdown

The AI Combat Coordinator acts as a central decision manager for enemies in combat.

When an enemy detects the player and reaches a suspicion threshold, it registers itself with the coordinator. The coordinator evaluates the list of active enemies and grants attack permission to one AI at a time.

Other enemies remain active but are placed in a waiting state, where they circle the player and maintain pressure until the coordinator grants them permission to attack.

This approach prevents enemy overlap while maintaining the illusion of coordinated group combat.


Blueprint Logic

Enemy Registration

When an AI's suspicion meter exceeds a threshold:

  1. AI sends a RequestAttackPermission call to the Combat Coordinator.

  2. The coordinator stores the AI reference in an Active Enemy Array.

  3. If no attacker is currently active, the coordinator selects one.

Attack Selection

The coordinator:

  • Checks if CurrentAttacker is empty

  • Selects an AI from the registered enemies

  • Sets that AI as CurrentAttacker

  • Updates its CanAttack flag

This flag is read by the AI’s Behavior Tree to enter the attack state.

Behavior Tree Integration

AI behavior trees reference the coordinator through blackboard variables.

Typical flow:

Selector
├── Attack Player (if HasAttackPermission)
├── Circle Player (if WaitingForTurn)
└── Investigate / Chase Player

The HasAttackPermission value is controlled by the coordinator.

Circling System

Enemies waiting for their attack turn move around the player instead of standing still.

The circling position is calculated by:

  • Getting the player location

  • Generating an offset position around the player

  • Using vector rotation to distribute enemies around the player

This ensures enemies maintain spacing while remaining threatening.


Challenges & Solutions

Multiple AI Attacking at Once

Initially, enemies would attack simultaneously when they detected the player.

Solution

Implemented a centralized attack permission system that ensures only one AI can enter the attack state at a time.

Idle AI Standing Still

Enemies waiting for their turn felt unnatural when standing still.

Solution

Added a circling behavior that generates dynamic positions around the player, allowing enemies to reposition while waiting.

Combat Flow

Without coordination, combat encounters felt chaotic and overwhelming.

Solution

The coordinator system regulates attack timing and enemy positioning, creating combat that feels intentional and readable for the player.

Directional Attack System

System Summary

Implemented a directional melee attack system that selects different attack animations based on the player's movement input at the moment the attack is triggered. This allows the player to perform forward, backward, and side attacks, creating a more responsive and varied combat system similar to directional melee combat found in modern action games.

The system reads the player's movement input relative to the character's facing direction and determines the correct attack animation to play.


What I Built

Responsibilities

  • Designed and implemented a directional attack detection system in Unreal Engine Blueprints

  • Created logic to determine attack direction based on player input and character orientation

  • Implemented animation selection logic for directional attacks

  • Integrated directional attacks with the existing combat and animation systems

  • Built a combo-compatible system that supports branching attacks based on input direction

  • Ensured smooth transitions between directional attack animations

Attack Input Pressed

Get Player Movement Input

Convert Input To Direction

Determine Attack Direction

Select Corresponding Attack Animation

Play Attack Montage


Technical Breakdown

The directional attack system determines which attack animation should play by evaluating the player's movement input relative to the character's forward direction.

When the player presses the attack input, the system analyzes the current movement input and determines the direction the player intends to attack. This direction is then used to select the corresponding animation.

Directional inputs are interpreted relative to the character's orientation rather than world direction, ensuring the attacks always match the player's movement relative to their character.


Blueprint Logic

Detecting Player Input Direction

When the player presses the attack button, the system reads the current movement input values.

  1. Retrieve the player's movement input vector

  2. Normalize the vector to determine direction

  3. Compare the direction relative to the character's forward vector

This allows the system to determine whether the player is attacking:

  • Forward

  • Backward

  • Left

  • Right

Determining Attack Direction

The system compares the movement direction against the character’s orientation.

Example logic:

  • Forward input → Forward attack

  • Backward input → Back attack

  • Left input → Left attack

  • Right input → Right attack

This allows the attack system to dynamically select different animations based on player intent.

Animation Selection

Once the direction is determined, the system selects the correct attack animation.

Each attack direction corresponds to a specific animation montage section. The system plays the appropriate animation based on the detected direction.

This allows attacks to feel more responsive and varied during combat.

Behavior During Combat

The directional system integrates with the overall combat logic.

  • If the player attacks while moving forward → forward strike

  • If the player attacks while strafing → side strike

  • If the player attacks while retreating → backward strike

This allows the player to control the type of attack they perform through movement input.


Challenges & Solutions

Determining Direction Relative to Character Orientation

Early versions of the system used world direction, which caused attacks to trigger incorrectly when the player rotated.

Solution

The system evaluates movement input relative to the character’s forward direction, ensuring attacks always align with the character’s orientation.

Maintaining Smooth Combat Flow

Directional attacks initially caused abrupt animation transitions.

Solution

Directional attack animations were integrated into the combat animation system to ensure transitions remained smooth and responsive.