UBehaviorTreeComponent::StartTree
#include "BehaviorTree/BehaviorTreeComponent.h"
Access: public
Description
Begins executing the given behavior tree asset from its root node. This is what AIController::RunBehaviorTree calls internally to kick off AI logic.
Caveats & Gotchas
- • If a different tree is already running on this component, the new call is queued via internal start-info and only takes effect once the current tree finishes stopping — it doesn't interrupt execution mid-frame.
- • Prefer AIController::RunBehaviorTree in gameplay code; call StartTree directly only when you're managing a UBehaviorTreeComponent outside the standard AIController flow.
Signature
void StartTree(UBehaviorTree& Asset, EBTExecutionMode::Type ExecuteMode = EBTExecutionMode::Looped); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Asset | UBehaviorTree& | The behavior tree asset to run. | — |
| ExecuteMode | EBTExecutionMode::Type | Whether the tree loops back to the root after finishing (Looped) or runs once and stops (SingleRun). | EBTExecutionMode::Looped |
Return Type
void Example
Start a tree on a manually-managed component C++
UBehaviorTreeComponent* BTComp = NewObject<UBehaviorTreeComponent>(GetOwner());
BTComp->RegisterComponent();
BTComp->StartTree(*MyBehaviorTreeAsset, EBTExecutionMode::Looped); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?