RealDocs

UBehaviorTreeComponent::RegisterMessageObserver

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

Description

Sets up an observer that resumes a task's latent execution when a matching FAIMessage is broadcast to this component. Used by tasks waiting on an external system (pathfinding, animation, etc.) to signal completion.

Caveats & Gotchas

  • Only takes effect while the task is actually running as a latent operation; calling it for a task that isn't currently executing has no effect.
  • A second overload accepts an explicit FAIRequestID so you can match one specific request instead of any message of MessageType — needed when the same task can have multiple outstanding requests.
  • Observers registered this way are cleaned up automatically by UnregisterMessageObserversFrom when the task finishes, aborts, or the tree stops.

Signature

void RegisterMessageObserver(const UBTTaskNode* TaskNode, FName MessageType);

Parameters

Name Type Description Default
TaskNode const UBTTaskNode* The task whose latent execution should resume when a matching message arrives.
MessageType FName Identifier of the message to wait for, matched against the Message parameter passed to FAIMessage::Send.

Return Type

void

Example

Register observer in a latent task C++
EBTNodeResult::Type UBTTask_WaitForSignal::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
	OwnerComp.RegisterMessageObserver(this, TEXT("SignalReceived"));
	RequestAsyncSystemToFireSignal();
	return EBTNodeResult::InProgress;
}

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.