> For the complete documentation index, see [llms.txt](https://soulslike-framework.isik.vip/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://soulslike-framework.isik.vip/components-managers/ai-only-components/ai-behavior-manager.md).

# AI Behavior Manager

<div align="left"><figure><img src="/files/Pxb9F1D6r6SRb7Q5t5rd" alt=""><figcaption></figcaption></figure></div>

The **AI Behavior Manager (AC\_AI\_BehaviorManager)** component is responsible for managing AI states (such as Idle, Patrolling, Random Roam, Investigating, Combat, etc.), ensuring smooth transitions between them. Additionally, the component allows for **fine-tuning** AI behavior through various **configurable parameters**.

It is added to the **Soulslike Enemy (B\_Soulslike\_Enemy)** class by default.

### **How It Works**

* **Behavior Tree Initialization**
  * On **Begin Play**, the component checks if the AI has a valid **Behavior Tree** assigned.
  * If a **Patrol Path** is present, the AI starts in a **Patrolling** state immediately.
  * Otherwise, it defaults to the **Idle** state.
* **State Management**
  * The component dynamically adjusts the AI's **state** based on environmental triggers (e.g., detecting the player, being attacked).
  * State changes are handled through the **SetState** method, ensuring smooth transitions between behaviors.
* **Fine-Tuning AI Behavior**
  * The following parameters allow for **custom AI tuning**:
    * **MaxChaseDistanceThreshold:** Maximum distance AI will chase a target before stopping.
    * **AttackDistanceThreshold:** The distance at which AI will initiate an attack.
    * **StrafeDistanceThreshold:** Controls how far the AI must be from its target for strafing.
    * **SpeedAdjustDistanceThreshold:** Adjusts AI movement speed based on distance to the target.
    * **MinimumStrafePointDistance:** The minimum distance for strafing logic.
    * **StrafeMethods:** Defines how AI will strafe (e.g., directional preferences).
* **Event Based Blackboard Updates**
  * The component is responsible for **adjusting Blackboard values** to ensure the AI’s **Behavior Tree** reacts correctly to its state.
* **Target & Patrol Tracking**
  * The **SetTarget()** function updates AI’s **current target** (e.g., player or other AI).
  * The **SetPatrolPath()** function assigns a patrol route.

### Example Usage

<figure><img src="/files/pBgzU24geJiLXpuNgaig" alt=""><figcaption></figcaption></figure>
