Navigation
API > API/Runtime > API/Runtime/AIModule > API/Runtime/AIModule/BehaviorTree
Inheritance Hierarchy
- UObjectBase
- UObjectBaseUtility
- UObject
- UActorComponent
- UBrainComponent
- UBehaviorTreeComponent
References
| Module | AIModule |
| Header | /Engine/Source/Runtime/AIModule/Classes/BehaviorTree/BehaviorTreeComponent.h |
| Include | #include "BehaviorTree/BehaviorTreeComponent.h" |
Syntax
class UBehaviorTreeComponent : public UBrainComponent
Variables
| Type | Name | Description | |
|---|---|---|---|
| float | AccumulatedTickDeltaTime | Accumulated DeltaTime if ticked more than predicted next delta time | |
| uint16 | ActiveInstanceIdx | Index of last active instance on stack | |
| uint8: 1 | bIsPaused | If set, execution requests will be postponed | |
| uint8: 1 | bIsRunning | If set, tree execution is allowed | |
| uint8: 1 | bLoopExecution | Loops tree execution | |
| uint8: 1 | bRequestedFlowUpdate | Set when execution update is scheduled for next tick | |
| uint8: 1 | bRequestedStop | Set when tree stop was called | |
| bool | bTickedOnce | Used to tell tickmanager that we want interval ticking | |
| uint8: 1 | bWaitingForLatentAborts | Set when execution is waiting for tasks to finish their latent abort (current or parallel's main) | |
| TMap< FGameplayTag, double > | CooldownTagsMap | Behavior cooldowns mapped by tag to last time it was set | |
| TArray< TArray< FBehaviorTreeDebuggerInstance::FNodeFlowData > > | CurrentRestarts | ||
| TArray< TArray< FBehaviorTreeDebuggerInstance::FNodeFlowData > > | CurrentSearchFlow | Search flow for debugger | |
| TArray< FBehaviorTreeExecutionStep > | DebuggerSteps | Debugger's recorded data | |
| TObjectPtr< UBehaviorTree > | DefaultBehaviorTreeAsset | Data asset defining the tree | |
| FBTNodeExecutionInfo | ExecutionRequest | Execution request, search will be performed when current task finish execution/aborting | |
| friend | FBehaviorTreeDebugger | ||
| friend | FBehaviorTreeInstance | ||
| TArray< FBehaviorTreeInstance > | InstanceStack | Stack of behavior tree instances | |
| TArray< FBehaviorTreeInstanceId > | KnownInstances | List of known subtree instances | |
| double | LastRequestedDeltaTimeGameTime | GameTime of the last DeltaTime request, used for debugging to output warnings about ticking | |
| float | NextTickDeltaTime | Predicted next DeltaTime | |
| TArray< TObjectPtr< UBTNode > > | NodeInstances | Instanced nodes | |
| TArray< FBranchActionInfo > | PendingBranchActionRequests | List of all pending branch action requests | |
| FBTPendingExecutionInfo | PendingExecution | Result of ExecutionRequest, will be applied when current task finish aborting | |
| TArray< FBehaviorTreeDebuggerInstance > | RemovedInstances | ||
| FBehaviorTreeSearchData | SearchData | Search data being currently used | |
| TMap< FName, FString > | SearchStartBlackboard | ||
| EBTBranchAction | SuspendedBranchActions | Type of suspended branch action | |
| TMultiMap< FBTNodeIndex, FAIMessageObserverHandle > | TaskMessageObservers | Message observers mapped by instance & execution index | |
| FBTTreeStartInfo | TreeStartInfo | Stored data for starting new tree, waits until previously running finishes aborting | |
| friend | UBTCompositeNode | ||
| friend | UBTNode | ||
| friend | UBTTask_RunBehavior | ||
| friend | UBTTask_RunBehaviorDynamic | ||
| friend | UBTTaskNode |
Constructors
| Type | Name | Description | |
|---|---|---|---|
UBehaviorTreeComponent
(
const FObjectInitializer& ObjectInitializer |
|||
UBehaviorTreeComponent
(
FVTableHelper& Helper |
DO NOT USE. This constructor is for internal usage only for hot-reload purposes. |
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | Abort currently executed task | ||
| void | ActivateBranch
(
const UBTDecorator& RequestedBy, |
Activate a branch as the decorator conditions are now passing | |
| void | AddCooldownTagDuration
(
FGameplayTag CooldownTag, |
Add to the cooldown tag's duration | |
| void | Apply pending node updates required for discarded search | ||
| void | ApplySearchData
(
UBTNode* NewActiveNode |
Apply pending node updates from SearchData | |
| void | ApplySearchUpdates
(
const TArray< FBehaviorTreeSearchUpdate >& UpdateList, |
Apply updates from specific list | |
| EBTNodeRelativePriority | CalculateRelativePriority
(
const UBTNode* NodeA, |
Return NodeA's relative priority in regards to NodeB | |
| void | Copy memory block from persistent memory to running instances (rollback) | ||
| void | Copy memory block from running instances to persistent memory | ||
| void | DeactivateBranch
(
const UBTDecorator& RequestedBy |
Deactivate a branch as the decorator conditions are not passing anymore | |
| bool | DeactivateUpTo
(
const UBTCompositeNode* Node, |
Deactivate all nodes up to requested one | |
| FString | |||
| FString | |||
| void | EndFrame () |
Code for timing BT Search for FramePro. | |
| void | EvaluateBranch
(
const UBTDecorator& RequestedBy |
Evaluate a branch as the decorator conditions have changed | |
| void | EvaluateBranch
(
EBTNodeResult::Type LastResult |
Evaluate a branch as current active node is finished | |
| void | ExecuteTask
(
UBTTaskNode* TaskNode |
Execute new task | |
| int32 | FindInstanceContainingNode
(
const UBTNode* Node |
Tries to find behavior tree instance in context | |
| UBTNode * | FindTemplateNode
(
const UBTNode* Node |
Tries to find template node for given instanced node | |
| uint16 | Get index of active instance on stack | ||
| const UBTNode * | |||
| UBehaviorTree * | |||
| uint8 * | GetNodeMemory
(
UBTNode* Node, |
||
| UBehaviorTree * | GetRootTree () |
||
| double | GetTagCooldownEndTime
(
FGameplayTag CooldownTag |
||
| EBTTaskStatus::Type | GetTaskStatus
(
const UBTTaskNode* TaskNode |
||
| bool | Return true if the current or any parallel task has a latent abort in progress | ||
| bool | |||
| bool | IsAuxNodeActive
(
const UBTAuxiliaryNode* AuxNode |
||
| bool | IsAuxNodeActive
(
const UBTAuxiliaryNode* AuxNodeTemplate, |
||
| bool | Check if debugger is currently running and can gather data | ||
| bool | IsExecutingBranch
(
const UBTNode* Node, |
||
| bool | Returns true if InstanceStack contains any BT runtime instances | ||
| bool | |||
| void | OnTaskFinished
(
const UBTTaskNode* TaskNode, |
Finish latent execution or abort | |
| void | Called when tree runs out of nodes to execute | ||
| void | Process execution flow | ||
| void | Apply pending execution from last task search | ||
| void | Apply pending tree initialization | ||
| bool | PushInstance
(
UBehaviorTree& TreeAsset |
Push behavior tree instance on execution stack : should never be called out-side of BT execution, meaning only BT tasks can push another BT instance! | |
| void | RegisterMessageObserver
(
const UBTTaskNode* TaskNode, |
Setup message observer for given task | |
| void | RegisterMessageObserver
(
const UBTTaskNode* TaskNode, |
Setup message observer for given task | |
| void | RegisterParallelTask
(
const UBTTaskNode* TaskNode |
Add active parallel task | |
| void | Remove instanced nodes, known subtree instances and safely clears their persistent memory | ||
| void | RequestBranchActivation
(
const UBTDecorator& RequestedBy, |
Request branch activation: helper for decorator | |
| void | RequestBranchDeactivation
(
const UBTDecorator& RequestedBy |
Request branch deactivation: helper for decorator | |
| void | RequestBranchEvaluation
(
const UBTDecorator& RequestedBy |
Request branch evaluation: helper for decorator | |
| void | RequestBranchEvaluation
(
EBTNodeResult::Type ContinueWithResult |
Request branch evaluation: helper for active node (ex: tasks) | |
| void | RequestExecution
(
const UBTCompositeNode* RequestedOn, |
Request execution change | |
| void | RequestExecution
(
EBTNodeResult::Type ContinueWithResult |
Replaced by RequestBranchEvaluation with EBTNodeResult | |
| void | RequestExecution
(
const UBTDecorator* RequestedBy |
Replaced by the RequestBranchEvaluation from decorator | |
| void | RestartTree
(
EBTRestartMode RestartMode |
Restarts execution from root | |
| void | Resume branch actions and execute all the queued up ones | ||
| void | Restore state of tree to state before search | ||
| void | Schedule execution flow update in next tick | ||
| void | ScheduleNextTick
(
float NextDeltaTime |
END UActorComponent overrides Schedule when will be the next tick, 0.0f means next frame, FLT_MAX means never | |
| void | SetDynamicSubtree
(
FGameplayTag InjectTag, |
Assign subtree to RunBehaviorDynamic task specified by tag | |
| void | StartTree
(
UBehaviorTree& Asset, |
Starts execution from root | |
| void | StopTree
(
EBTStopMode::Type StopMode |
Stops execution | |
| void | StoreDebuggerBlackboard
(
TMap< FName, FString >& BlackboardValueDesc |
Describe blackboard's key values | |
| void | StoreDebuggerExecutionStep
(
EBTExecutionSnap::Type SnapType |
Make a snapshot for debugger | |
| void | StoreDebuggerInstance
(
FBehaviorTreeDebuggerInstance& InstanceInfo, |
Make a snapshot for debugger from given subtree instance | |
| void | StoreDebuggerRemovedInstance
(
uint16 InstanceIdx |
||
| void | StoreDebuggerRestart
(
const UBTNode* Node, |
Store restarting node for debugger | |
| void | StoreDebuggerRuntimeValues
(
TArray< FString >& RuntimeDescriptions, |
Gather nodes runtime descriptions | |
| void | StoreDebuggerSearchStep
(
const UBTNode* Node, |
Store search step for debugger | |
| void | StoreDebuggerSearchStep
(
const UBTNode* Node, |
Store search step for debugger | |
| void | SuspendBranchActions
(
EBTBranchAction BranchActions |
Suspend any branch actions and queue them to be processed later by ResumeBranchActions() | |
| void | Tracks if there are new tasks using latent abort in progress | ||
| bool | Returns true if execution was waiting on latent aborts and they are all finished; | ||
| bool | Indicates instance has been initialized to work with specific BT asset | ||
| void | UnregisterAuxNodesInBranch
(
const UBTCompositeNode* Node, |
Unregister all aux nodes in branch of tree | |
| void | UnregisterAuxNodesInRange
(
const FBTNodeIndex& FromIndex, |
Unregister all aux nodes between given execution index range: FromIndex < AuxIndex < ToIndex | |
| void | UnregisterAuxNodesUpTo
(
const FBTNodeIndex& Index |
Unregister all aux nodes less important than given index | |
| void | UnregisterMessageObserversFrom
(
const FBTNodeIndex& TaskIdx |
Remove message observers registered with task | |
| void | UnregisterMessageObserversFrom
(
const UBTTaskNode* TaskNode |
Remove message observers registered with task | |
| void | UnregisterParallelTask
(
const UBTTaskNode* TaskNode, |
Remove parallel task | |
| void | UpdateDebuggerAfterExecution
(
const UBTTaskNode* TaskNode, |
Update runtime description of given task node in latest debugger's snapshot | |
| uint8 | UpdateInstanceId
(
UBehaviorTree* TreeAsset, |
Add unique Id of newly created subtree to KnownInstances list and return its index |
Overridden from UBrainComponent
| Type | Name | Description | |
|---|---|---|---|
| void | Cleanup () |
AI logic won't be needed anymore, stop all activity and run cleanup | |
| void | DescribeSelfToVisLog
(
FVisualLogEntry* Snapshot |
||
| FString | |||
| void | HandleMessage
(
const FAIMessage& Message |
||
| bool | IsPaused () |
||
| bool | IsRunning () |
||
| void | PauseLogic
(
const FString& Reason |
Pause logic and blackboard updates. | |
| void | RestartLogic () |
Restarts currently running or previously ran brain logic. | |
| EAILogicResuming::Type | ResumeLogic
(
const FString& Reason |
Resumes paused brain logic. MUST be called by child implementations! | |
| void | StartLogic () |
Starts brain logic. If brain is already running, will not do anything. | |
| void | Stops currently running brain logic. |
Overridden from UActorComponent
| Type | Name | Description | |
|---|---|---|---|
| void | RegisterComponentTickFunctions
(
bool bRegister |
Virtual call chain to register all tick functions | |
| void | SetComponentTickEnabled
(
bool bEnabled |
Set this component's tick functions to be enabled or disabled. | |
| void | TickComponent
(
float DeltaTime, |
BEGIN UActorComponent overrides | |
| void | Handle this component being Uninitialized. |
Classes
| Type | Name | Description | |
|---|---|---|---|
| FBranchActionInfo | |||
| FBTSuspendBranchActionsScoped |
Typedefs
| Name | Description |
|---|---|
| FBTSuspendBranchDeactivationScoped |
Constants
| Name | Description |
|---|---|
| ActiveDebuggerCounter | Set when at least one debugger window is opened |
| bAddedEndFrameCallback | Code for timing BT Search for FramePro. |
| FrameSearchTime | |
| NumSearchTimeCalls |
Deprecated Functions
| Type | Name | Description | |
|---|---|---|---|
| void | RequestUnregisterAuxNodesInBranch
(
const UBTCompositeNode* Node |
This function is deprecated. Please use RequestBranchDeactivation instead. | |
| void | This function is deprecated. Please use ResumeBranchActions instead. | ||
| void | This function is deprecated. Please use SuspendBranchActions instead. |