When the base value of an attribute changes, there is UAttributeSet::PostGameplayEffectExecute()
available to access the (new) value and GameplayEffect with its context. I'm using this to print the changed value to UI (this is also done in ActionRPG).
Is there something similar available for the current value of an attribute? How to notify UI, when FGameplayAttributeData::CurrentValue
is updated?
- Though
UAttributeSet::PreAttributeChange()
is called on every value update, it doesn't provide any context so it is not possible to access the UI from there (events broadcasted byFAggregator
also don't fit). - It is possible to use a GameplayCue instead, to set the value of
FGameplayAttributeData::CurrentValue
within the UI (the cue is triggered by the GameplayEffect who sets the current value). This is possible by deriving from aGameplayCueNotifyActor
and use its eventsOnExecute
andOnRemove
. However, instantiating an actor just to update UI seems to be a waste of resources. - It is also possible to fetch the information using the UI itself (calling a function which accesses the attribute each tick or with a timer), but in comparison to event driven UI update, this is also wasteful.