RealDocs

UAbilitySystemComponent::AbilityTargetDataSetDelegate

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

Description

Returns (and creates if absent) the multicast delegate that fires when replicated target data arrives for a specific ability/prediction-key pair. Abilities bind to this delegate server-side to resume execution once client targeting completes.

Caveats & Gotchas

  • The returned delegate is keyed by both the ability handle AND prediction key — using a stale or incorrect prediction key means your callback will never fire. Always use the activation prediction key captured at ability activation, not a newly created one.
  • If target data has already arrived before you bind, the delegate won't retroactively fire — call CallReplicatedTargetDataDelegatesIfSet() after binding to handle that race condition.
  • This creates a new entry in the replicated data map if one doesn't exist, which carries a small allocation cost. Don't call it speculatively for abilities that may never need targeting.

Signature

UE_API FAbilityTargetDataSetDelegate& AbilityTargetDataSetDelegate(FGameplayAbilitySpecHandle AbilityHandle, FPredictionKey AbilityOriginalPredictionKey);

Parameters

Name Type Description Default
AbilityHandle FGameplayAbilitySpecHandle Handle identifying the ability to retrieve or create a target data delegate for.
AbilityOriginalPredictionKey FPredictionKey The prediction key associated with the ability activation that produced or will produce target data.

Return Type

FAbilityTargetDataSetDelegate&

Example

Bind to target data on server C++
// In an ability's ActivateAbility, called on server:
FGameplayAbilitySpecHandle Handle = GetCurrentAbilitySpecHandle();
FPredictionKey PredKey = GetCurrentActivationInfoRef().GetActivationPredictionKey();

ASC->AbilityTargetDataSetDelegate(Handle, PredKey).AddUObject(
    this, &UMyAbility::OnTargetDataReady);

// Also check if data already arrived
ASC->CallReplicatedTargetDataDelegatesIfSet(Handle, PredKey);

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.