RealDocs

UAbilitySystemComponent::ServerSetReplicatedTargetData

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

Description

Reliable server RPC that sends confirmed targeting data from the client to the server. The server stores it and fires the ability's target data delegate.

Caveats & Gotchas

  • Target data is not validated by default — the server trusts what the client sends. Override the target data validation logic to sanity-check positions and line-of-sight if exploits are a concern.
  • Custom target data types must implement GetScriptStruct() and correctly support net serialization; failing to do so causes silent data corruption or crashes when serializing the handle over the network.

Signature

void ServerSetReplicatedTargetData(FGameplayAbilitySpecHandle AbilityHandle, FPredictionKey AbilityOriginalPredictionKey, const FGameplayAbilityTargetDataHandle& ReplicatedTargetDataHandle, FGameplayTag ApplicationTag, FPredictionKey CurrentPredictionKey)

Parameters

Name Type Description Default
AbilityHandle FGameplayAbilitySpecHandle Handle to the ability spec that produced this target data.
AbilityOriginalPredictionKey FPredictionKey The prediction key that was active when the ability was activated.
ReplicatedTargetDataHandle const FGameplayAbilityTargetDataHandle& The target data collected by the targeting actor or task.
ApplicationTag FGameplayTag Optional tag describing how the target data should be applied.
CurrentPredictionKey FPredictionKey The prediction key active when the target data is confirmed.

Return Type

void

Example

Sending target data from a custom targeting task C++
// Typically called by UAbilityTask_WaitTargetData on player confirm.
// Direct use inside a custom task:
ASC->ServerSetReplicatedTargetData(
    AbilityHandle,
    OriginalPredictionKey,
    TargetDataHandle,
    FGameplayTag(),
    CurrentPredictionKey);

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.