# 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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://soulslike-framework.isik.vip/components-managers/ai-only-components/ai-behavior-manager.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
