RealDocs

UAbilitySystemComponent::OnOwnerActorDestroyed

function GameplayAbilities Since 4.15
#include "AbilitySystemComponent.h"
Access: public Specifiers: UFUNCTION

Description

Internal callback bound to the owner actor's OnDestroyed delegate. Clears the OwnerActor pointer when the logical owner (e.g. a PlayerState) is destroyed.

Caveats & Gotchas

  • Like OnAvatarActorDestroyed, do not call this manually — it is wired up by InitAbilityActorInfo and fires automatically through the engine's actor lifecycle.
  • In most gameplay scenarios OwnerActor (PlayerState) outlives the Pawn, so this fires less often than OnAvatarActorDestroyed — but in session teardown it fires during world cleanup and ability tasks should tolerate null owners.

Signature

UE_API void OnOwnerActorDestroyed(AActor* InActor)

Parameters

Name Type Description Default
InActor AActor* The actor being destroyed (expected to be the current owner actor).

Return Type

void

Example

Awareness of owner-destroyed timing in ability code C++
// In an ability task's OnDestroy, always guard against null owner:
void UMyAbilityTask::OnDestroy(bool bInOwnerFinished)
{
    if (UAbilitySystemComponent* ASC = AbilitySystemComponent.Get())
    {
        // Safe: ASC may still exist even if owner actor is gone
        ASC->ConsumeAllReplicatedData(AbilityHandle, PredictionKey);
    }
    Super::OnDestroy(bInOwnerFinished);
}

Version History

Introduced in: 4.15

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.