RealDocs

UAbilitySystemComponent::GetAvatarActor

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

Description

Returns the avatar actor for this component — the physical actor in the world that abilities act upon. This is often the pawn, but can differ from the owner actor in cases like player-state owned ASCs.

Caveats & Gotchas

  • The avatar actor can differ from GetOwnerActor() when the ASC lives on a PlayerState. Always use GetAvatarActor() to get the pawn mesh/capsule for targeting or animation, not GetOwner().
  • Returns nullptr until InitAbilityActorInfo is called. In a multiplayer game on clients, this may not be valid until after BeginPlay if the actor hasn't fully replicated yet.
  • Distinct from GetAvatarActor_Direct() which bypasses the virtual task avatar override — use GetAvatarActor() in ability code to stay consistent with GetGameplayTaskAvatar.

Signature

UE_API AActor* GetAvatarActor() const;

Return Type

AActor*

Example

Get pawn from ability system component C++
if (AActor* Avatar = AbilitySystemComponent->GetAvatarActor())
{
    if (ACharacter* Character = Cast<ACharacter>(Avatar))
    {
        // Work with the pawn's mesh, capsule, etc.
        Character->GetMesh()->SetHiddenInGame(false);
    }
}

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.