UBTDecorator
#include "BehaviorTree/BTDecorator.h" Description
The base class for Behavior Tree decorator nodes. Decorators sit on branches or tasks and act as conditional gates — they can allow or block execution and abort active branches when their condition changes.
Caveats & Gotchas
- • Override CalculateRawConditionValue() to implement the condition. Do not override WrappedCanExecute() directly.
- • Abort mode (Self, LowerPriority, Both) determines which branches are aborted when the condition changes at runtime. Wrong abort mode is the most common decorator bug.
- • Like tasks, decorators are shared across all trees using the same asset unless instanced. Do not store mutable state on the object.
Example
Custom decorator checking a gameplay condition C++
bool UBTDecorator_HasAmmo::CalculateRawConditionValue(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) const
{
AMyAIController* Controller = Cast<AMyAIController>(OwnerComp.GetAIOwner());
return Controller && Controller->GetAmmoCount() > 0;
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?