tranek / GASDocumentation

My understanding of Unreal Engine 5's GameplayAbilitySystem plugin with a simple multiplayer sample project.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Output Modifiers in Gameplay Effect Execution Calculations Cannot Modify Source Attributes

GuyPaddock opened this issue · comments

This is likely to be obvious to others but I just spent a long time debugging an issue in which I was trying to have an ExecCalc modify multiple attributes on a source during an attack, only to find that the attributes weren't being modified. It turned out that the attributes were, in fact, being modified but on the target. Now that I know this, it does make some sense, since there's no option to specify whether an output modifier is going to target the source or the target ASCs. Section 4.5.12 indicates that ExecCalcs, "can change more than one Attribute and essentially do anything else that the programmer wants." So, from this, I was mistakenly assuming I could modify source attributes just like I can target attributes.

Eventually, the workaround I found was to call SourceAsc->ApplyModToAttribute() directly in the exec. For my purposes, this seems safe since the attributes I'm modifying are transient during a single attack, but I am not sure if it's a good general purpose solution.

I found another workaround -- I split the one execution into two separate executions invoked by two different GEs. During the attack, one of the GEs gets applied to the source and then the other GE gets applied to the target; that allows me to still use output modifiers in the execution that makes changes to attributes of the source.

This isn't as useful a workaround if the execution is performing a calculation and the result of that calculation needs to be applied to attributes on both the source and target. What I'm doing to work around that is the calculation is done by the GE exec on the source, the result is being stashed in a transient attribute on the source, and then I am reading that transient attribute in the GE exec on