This logic requires four sources of information: a gameplay TAG associated with Boosting ability, a node inside your Gameplay Ability ‘Assign set by caller magnitude’, a ‘Data Tag’ (for instance, SetbyCaller.Cooldown), and a gameplay effect (your ability cooldown) with a calculation modifier set to use Caller Magnitude (the Lyra Demo has a blueprint GE_Damage_Basic_SetByCaller already setup for this logic.)
From your GA, check if owning actor (player or even an AI) has a matching tag ‘is Boosting’. If true (player has tag), use a select node and modify the magnitude value of the node Assign set by caller magnitude. Finally set your cooldown GE to calculate magnitude using information from caller.
Take a look at this github page, at chapter 4.5.9.1 SetByCallers:
tranek/GASDocumentation: My understanding of Unreal Engine 4’s GameplayAbilitySystem plugin with a simple multiplayer sample project. (github.com)
Here is the quote:
4.5.9.1 SetByCallers
SetByCallers
allow the GameplayEffectSpec
to carry float values associated with a GameplayTag
or FName
around. They are stored in their respective TMaps
: TMap<FGameplayTag, float>
and TMap<FName, float>
on the GameplayEffectSpec
. These can be used to as Modifiers
on the GameplayEffect
or as generic means of ferrying floats around. It is common to pass numerical data generated inside of an ability to GameplayEffectExecutionCalculations
or ModifierMagnitudeCalculations
via SetByCallers
.
SetByCaller Use |
Notes |
Modifiers |
Must be defined ahead of time in the GameplayEffect class. Can only use the GameplayTag version. If one is defined on the GameplayEffect class but the GameplayEffectSpec does not have the corresponding tag and float value pair, the game will have a runtime error on application of the GameplayEffectSpec and return 0. This is a potential problem for a Divide operation. See Modifiers . |
Elsewhere |
Does not need to be defined ahead of time anywhere. Reading a SetByCaller that does not exist on a GameplayEffectSpec can return a developer defined default value with optional warnings. |
To assign SetByCaller
values in Blueprint, use the Blueprint node for the version that you need (GameplayTag
or FName
):
To read a SetByCaller
value in Blueprint, you will need to make custom nodes in your Blueprint Library.
To assign SetByCaller
values in C++, use the version of the function that you need (GameplayTag
or FName
):
void FGameplayEffectSpec::SetSetByCallerMagnitude(FName DataName, float Magnitude);
void FGameplayEffectSpec::SetSetByCallerMagnitude(FGameplayTag DataTag, float Magnitude);
To read a SetByCaller
value in C++, use the version of the function that you need (GameplayTag
or FName
):
float GetSetByCallerMagnitude(FName DataName, bool WarnIfNotFound = true, float DefaultIfNotFound = 0.f) const;
float GetSetByCallerMagnitude(FGameplayTag DataTag, bool WarnIfNotFound = true, float DefaultIfNotFound = 0.f) const;
I recommend using the GameplayTag
version over the FName
version. This can prevent spelling errors in Blueprint and GameplayTags
are more efficient to send over the network when the GameplayEffectSpec
replicates than FNames
since the TMaps
replicate too.