UAbilitySystemComponent::BeginPlay
#include "AbilitySystemComponent.h"
Access: public
Specifiers: virtualoverride
Description
Called when the owning actor's BeginPlay fires. The ASC uses this to finalize actor-info setup and grant any abilities or effects configured on the actor.
Caveats & Gotchas
- • Call Super::BeginPlay() — skipping it means InitAbilityActorInfo may not have been called for server-only actors, leaving the ASC unable to apply gameplay effects.
- • On clients, BeginPlay fires before attribute replication arrives; do not read replicated attribute values in BeginPlay expecting them to be final.
Signature
virtual void BeginPlay() override Return Type
void Example
Granting startup abilities in BeginPlay C++
void UMyAbilitySystemComponent::BeginPlay()
{
Super::BeginPlay();
if (GetOwnerRole() == ROLE_Authority)
{
for (TSubclassOf<UGameplayAbility> AbilityClass : StartupAbilities)
{
GiveAbility(FGameplayAbilitySpec(AbilityClass, 1));
}
}
} Version History
Introduced in: 4.15
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?