RealDocs

UBlackboardComponent::UnregisterObserversFrom

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

Description

Removes every observer delegate that was registered with the given owner object, regardless of which key each one watched.

Caveats & Gotchas

  • The most reliable way to clean up observers in EndPlay or a component's destructor, since it doesn't require tracking individual FDelegateHandle values.
  • Only removes observers registered via RegisterObserver with this exact NotifyOwner pointer — observers registered with a different owner for the same object instance are unaffected.

Signature

void UnregisterObserversFrom(const UObject* NotifyOwner)

Parameters

Name Type Description Default
NotifyOwner const UObject* The owner object passed to RegisterObserver when the observers were created.

Return Type

void

Example

Clean up all observers owned by this object C++
void AMyAIController::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
    if (UBlackboardComponent* BB = GetBlackboardComponent())
    {
        BB->UnregisterObserversFrom(this);
    }
    Super::EndPlay(EndPlayReason);
}

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.