Combat Behavior {{ currentPage ? currentPage.title : "" }}

Overview

The UACFCombatBehaviourComponent class is designed to be configured primarily through the Unreal Engine editor, allowing designers to define AI combat behaviors without extensive coding. It manages combat states, evaluates conditions for executing actions, and handles AI character equipment and engagement logic.


Key Features

  • Combat State Management: Handles various AI combat states, such as melee, ranged combat, and target chasing.

  • Condition-Based Actions: Executes actions based on pre-defined conditions and probabilities.

  • Equipment Handling: Manages weapon equipping for melee and ranged combat types.

  • Distance Evaluation: Determines ideal distances for combat states and evaluates target proximity.

  • Initialization and Cleanup: Initializes AI combat behavior and ensures proper cleanup when the behavior is no longer needed.


Configuration Guide

Set Up Combat States in the Editor

  1. Navigate to the component's details panel.

  2. In the CombatStatesConfig section:

    • Add a new state by clicking the + icon.

    • Specify the Combat State, Trigger Chance, and Locomotion State.

    • Optionally, define conditions such as distance thresholds.

Step 2: Configure Conditions

  1. For each combat state, expand its configuration.

  2. Add conditions like Distance-Based Condition or other custom conditions.

  3. Define the condition type (e.g., Below, Above) and value directly in the editor.

Step 3: Define Allowed Behaviors

  1. In the AllowedBehaviors section of the details panel, specify which combat behaviors (e.g., EMelee, ERanged) are available for the AI.

Step 4: Assign Default Behavior

  1. Set the DefaultCombatBehaviorType property to EMelee or ERanged based on the AI's initial combat strategy.

Step 5: Link Actions to AI CombatStates

  1. In the ActionByCombatState map, define actions for each combat state.

  2. For each action:

    • Add the Action Tag (using gameplay tags defined in the project).

    • Assign a Weight to control action selection probability.

    • Optionally, set properties like Wait Time and Priority.


Custom Conditions and Actions

For advanced customization, you can create custom conditions and actions by creating child classes of UACFActionCondition and UACFBaseAction.

Creating a Custom Condition

  1. Create a new class inheriting from UACFActionCondition.

  2. Override the IsConditionMet method to implement your logic.

  3. Add your custom condition in the editor or via script.

Example:

class UCustomCondition : public UACFActionCondition {
    virtual bool IsConditionMet(AACFCharacter* Character) override {
        // Custom logic
        return Character->GetHealth() < 50.0f;
    }
};


Notes

  • Ensure CombatStatesConfig is correctly populated in the editor for expected AI behavior.

  • Regularly test configurations to verify smooth state transitions and combat logic.

{{{ content }}}