RealDocs

UAbilitySystemComponent::GetAvatarActor_Direct

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

Description

Returns the raw AvatarActor pointer stored in this component. Prefer GetAvatarActor() (which goes through AbilityActorInfo) unless you specifically need the raw cached pointer.

Caveats & Gotchas

  • This can return a stale or null pointer if the avatar was destroyed and OnAvatarActorDestroyed cleared it — always check IsValid() before use.
  • GetAvatarActor() (no _Direct suffix) returns the actor via AbilityActorInfo, which is the preferred path in ability code; _Direct bypasses that indirection.

Signature

AActor* GetAvatarActor_Direct() const { return AvatarActor; }

Return Type

AActor*

Example

Quick null-check before ability logic C++
AActor* Avatar = ASC->GetAvatarActor_Direct();
if (!IsValid(Avatar))
{
    return; // Avatar was destroyed
}
APawn* AvatarPawn = Cast<APawn>(Avatar);

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.