RealDocs

UBehaviorTreeComponent::OnTaskFinished

function AIModule Since 4.0
#include "BehaviorTree/BehaviorTreeComponent.h"
Access: public

Description

Notifies the tree that a task has finished its latent execution (or been aborted), triggering the next execution search. Every custom BT task that returns InProgress from ExecuteTask must eventually call this.

Caveats & Gotchas

  • Must be called exactly once per InProgress task — calling it twice for the same task, or never calling it, leaves the tree stuck or corrupts execution state.
  • If the task is being aborted (TaskResult == Aborted), this is typically called from within your task's AbortTask override rather than ExecuteTask.

Signature

void OnTaskFinished(const UBTTaskNode* TaskNode, EBTNodeResult::Type TaskResult);

Parameters

Name Type Description Default
TaskNode const UBTTaskNode* The task reporting completion.
TaskResult EBTNodeResult::Type Succeeded, Failed, or Aborted — determines how the tree continues.

Return Type

void

Example

Finish a latent task from a message callback C++
void UBTTask_WaitForSignal::OnSignalReceived(UBehaviorTreeComponent& OwnerComp)
{
	OwnerComp.OnTaskFinished(this, EBTNodeResult::Succeeded);
}

Tags

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.