UAbilitySystemComponent::ApplyGameplayEffectToSelf
#include "AbilitySystemComponent.h"
Access: public
Description
Applies a Gameplay Effect directly to this component's owner. Used to apply buffs, debuffs, damage, and healing from C++ without going through an ability.
Signature
UE_API FActiveGameplayEffectHandle ApplyGameplayEffectToSelf(const UGameplayEffect* GameplayEffect, float Level, const FGameplayEffectContextHandle& EffectContext, FPredictionKey PredictionKey = FPredictionKey()) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| GameplayEffect | const UGameplayEffect* | The effect CDO or instance to apply. Use GetDefault<UMyEffect>() to get the CDO. | — |
| Level | float | Magnitude level for scalable float curves on the effect. | — |
| EffectContext | const FGameplayEffectContextHandle& | Context providing instigator, source object, and hit results for the effect. | — |
| PredictionKey | FPredictionKey | Prediction key for client-side prediction. Pass default for server-only application. | FPredictionKey() |
Return Type
FActiveGameplayEffectHandle Caveats & Gotchas
- • Returns an invalid handle if the application fails (e.g., immune tags blocked it). Always check IsValid() on the returned handle before storing it.
- • Blueprint equivalent is BP_ApplyGameplayEffectToSelf which takes a class instead of an instance.
- • Duration and Infinite effects require authority to be authoritative; Instant effects can be predicted on clients.
Example
Apply a healing effect to self C++
FGameplayEffectContextHandle Context = AbilitySystemComponent->MakeEffectContext();
Context.AddSourceObject(this);
FActiveGameplayEffectHandle Handle = AbilitySystemComponent->ApplyGameplayEffectToSelf(
GetDefault<UGE_Heal>(), 1.f, Context); See Also
Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?