RealDocs

UAttributeSet::PostAttributeChange

function GameplayAbilities Since unknown
#include "AttributeSet.h"
Access: public Specifiers: virtual

Description

Called just after any modification has changed an attribute's current value. Use this to react to the new value, for example broadcasting a UI update or checking for death when Health hits zero.

Caveats & Gotchas

  • By the time this runs the change is already applied; you can't cancel or clamp it here, only respond (use PreAttributeChange for clamping).
  • Fires for every attribute on the set, so most overrides start by checking Attribute == GetXAttribute() before acting.

Signature

virtual void PostAttributeChange(const FGameplayAttribute& Attribute, float OldValue, float NewValue) { }

Parameters

Name Type Description Default
Attribute const FGameplayAttribute& The attribute that changed.
OldValue float The value before this change.
NewValue float The value after this change.

Return Type

void

Example

Broadcast a death event on Health depletion C++
void UMyHealthSet::PostAttributeChange(const FGameplayAttribute& Attribute, float OldValue, float NewValue)
{
    if (Attribute == GetHealthAttribute() && NewValue <= 0.f && OldValue > 0.f)
    {
        OnHealthDepleted.Broadcast();
    }
}

Version History

Introduced in: unknown

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.