UBehaviorTreeComponent::GetCurrentTree
#include "BehaviorTree/BehaviorTreeComponent.h"
Access: public
Specifiers: const
Description
Returns the behavior tree asset for the currently active instance on the stack. When a dynamic subtree is running, this returns the subtree asset rather than the top-level tree.
Caveats & Gotchas
- • Returns null if the instance stack is empty (tree hasn't been started, or has already stopped) — check IsRunning first if that matters.
- • Differs from GetRootTree when a subtree has been pushed via StartTree/RunBehavior — this returns the innermost active tree, not the one at the bottom of the stack.
Signature
UBehaviorTree* GetCurrentTree() const Return Type
UBehaviorTree* Example
Reading the active tree asset C++
if (UBehaviorTree* ActiveTree = BTComponent->GetCurrentTree())
{
UE_LOG(LogBehaviorTree, Log, TEXT("Running: %s"), *ActiveTree->GetName());
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?