UBTTaskNode
#include "BehaviorTree/BTTaskNode.h" Description
The base class for Behavior Tree leaf nodes that perform actions. Subclass this in C++ to create custom AI tasks such as moving, attacking, or waiting.
Caveats & Gotchas
- • Override ExecuteTask() to implement the task logic. Return EBTNodeResult::Succeeded or Failed for instant tasks, or InProgress for latent tasks.
- • For latent tasks, call FinishLatentTask() when done — failing to do so will stall the behavior tree indefinitely.
- • If your task is not instanced (default), treat all virtual functions as const — do not store mutable state on the node object itself. Use NodeMemory instead.
- • Use INIT_TASK_NODE_NOTIFY_FLAGS() in the constructor to automatically enable TickTask and OnTaskFinished notifications.
Example
Minimal custom task C++
EBTNodeResult::Type UBTTask_MyAction::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
AAIController* Controller = OwnerComp.GetAIOwner();
// Do work...
return EBTNodeResult::Succeeded;
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?