UAbilitySystemComponent::CallOrAddReplicatedDelegate
#include "AbilitySystemComponent.h"
Access: public
Description
Fires the supplied delegate immediately if the Generic Replicated Event has already been received; otherwise registers it to fire when the event arrives. Eliminates the race condition between server setup and client replication.
Caveats & Gotchas
- • If the event already arrived when this is called, the delegate fires synchronously in the same stack frame — ensure your callback is safe to call immediately.
- • The registered delegate is stored per-event-type/ability/prediction-key slot; it will be removed after the event fires once, so do not rely on it for repeated notifications.
Signature
UE_API bool CallOrAddReplicatedDelegate(EAbilityGenericReplicatedEvent::Type EventType, FGameplayAbilitySpecHandle AbilityHandle, FPredictionKey AbilityOriginalPredictionKey, FSimpleMulticastDelegate::FDelegate Delegate) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| EventType | EAbilityGenericReplicatedEvent::Type | The generic replicated event type to watch for. | — |
| AbilityHandle | FGameplayAbilitySpecHandle | Handle identifying the ability. | — |
| AbilityOriginalPredictionKey | FPredictionKey | Prediction key from when the ability was activated. | — |
| Delegate | FSimpleMulticastDelegate::FDelegate | The delegate to fire immediately if the event already arrived, or register for when it does. | — |
Return Type
bool Example
Race-safe server-side wait for InputConfirm C++
ASC->CallOrAddReplicatedDelegate(
EAbilityGenericReplicatedEvent::InputConfirm,
AbilityHandle,
OriginalPredKey,
FSimpleMulticastDelegate::FDelegate::CreateUObject(
this, &UMyAbilityTask::OnInputConfirmed)); See Also
Version History
Introduced in: 4.15
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?