FGameplayAttribute
#include "AttributeSet.h" Description
A lightweight handle that identifies a specific attribute property on an UAttributeSet. Used as a key in GAS callbacks and modifier specs to reference attributes without string comparison.
Caveats & Gotchas
- • FGameplayAttribute wraps an FProperty pointer — it is stable within a session but should not be serialized to disk as a persistent identifier.
- • Use the generated GetHealthAttribute() static from ATTRIBUTE_ACCESSORS to get the correct FGameplayAttribute for a given property rather than constructing one manually.
- • Equality comparison is property-pointer based, which means attributes on different attribute set instances for the same property are considered equal.
Example
Check which attribute changed in PreAttributeChange C++
void UMyAttributeSet::PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue)
{
if (Attribute == GetHealthAttribute())
{
NewValue = FMath::Clamp(NewValue, 0.f, GetMaxHealth());
}
} See Also
Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?