RealDocs

UAbilitySystemComponent::CancelAbilityTargetData

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

Description

Cancels pending ability target data and fires any registered cancel callbacks for the given ability/prediction-key pair. Called server-side when the client reports targeting was aborted.

Caveats & Gotchas

  • This fires the AbilityTargetDataCancelledDelegate, not just discards data — any callbacks registered via AbilityTargetDataCancelledDelegate will execute immediately on the server.
  • The prediction key must match the key used when the target data was originally sent. A mismatch means no callbacks fire and the data remains in the replicated cache, potentially causing abilities to wait indefinitely.
  • Internally calls ConsumeAllReplicatedData after firing callbacks, so the data is cleaned up even if no delegates are bound.

Signature

UE_API virtual void CancelAbilityTargetData(FGameplayAbilitySpecHandle AbilityHandle, FPredictionKey AbilityOriginalPredictionKey);

Parameters

Name Type Description Default
AbilityHandle FGameplayAbilitySpecHandle Handle identifying the ability whose pending target data should be cancelled.
AbilityOriginalPredictionKey FPredictionKey The prediction key used when the target data was originally sent, used to locate the correct replicated data entry.

Return Type

void

Example

Manually cancel target data from a targeting actor C++
// Called on server when a targeting actor is destroyed or interrupted
void UMyTargetingAbility::CancelTargeting()
{
    UAbilitySystemComponent* ASC = GetAbilitySystemComponentFromActorInfo();
    if (ASC && IsActive())
    {
        ASC->CancelAbilityTargetData(GetCurrentAbilitySpecHandle(), GetCurrentActivationInfoRef().GetActivationPredictionKey());
    }
}

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.