Download

[Gameplay Abilities] Implementing mutating / fading / decaying attribute modifiers

First off, I know the system isn’t really supported for general use, is undocumented, not finished, etc.

I’m looking for a way to implement Gameplay Effects with modifiers that change over the duration of the effect. An example would be Phase’s R from Paragon, Hyperflux:

The decaying movement speed boost is exactly what I’m looking for. The effect is applied, boosting movement speed attribute by x amount, and fades down to 0 over the duration of the effect.

My first idea was to use periodic executions to update the modifier, but turns out if you have a periodic effect the modifiers are essentially treated as instant and permanent, so it keeps updating the base attribute every execution rather than a modifier like I would expect.

I then dug around in source and found out that attribute modifiers can dynamically recalculate themselves based on dependencies updating, where I assumed they were only calculated once on effect application. Simple example of this would be a damage boost based on your health - when your health attribute changes, the damage modifier is notified and recalculates the magnitude of the attribute. This can be done with attribute-based modifiers and also mod magnitude calculation classes that capture attributes.

The other nice thing is that it looks like the recalculation can be triggered by external dependencies, meaning you could have the calculation class for the modifier determine exactly when the magnitude should be recalculated, so in the case of what I want it could just recalculate every 0.1 seconds or so after the application. It also looks like the recalculation happens on predicting clients too - awesome!

The only remaining problem is how to actually determine how long the effect has been active for inside the mod magnitude calculation. It gets access to the effect spec that created it, but as far as I can tell that’s not very useful in this case since the information is only on the Active Effect and there’s no reference to that. We don’t have the target actor / ability system either which means we can’t use the spec to find the active effect.

I could put the target or effect application time in the context, but that doesn’t feel too robust considering the same spec can potentially be applied to multiple targets at different times so they would override each other in that case.

Maybe I’m missing something that would make this easier? How would Paragon be doing it?

Any help appreciated!

You’d be better off asking this question in the UE4 Discord channel. There’s one dedicated completely to GameplayAbilities:

http://unrealslackers.org/

Thanks, but I’ve already posted there. That’s usually my go-to but haven’t figured out a solution yet so thought I might as well hit the forums as well.

Is there a way to set the dependencies using the GE blueprint (I didn’t found anything there to set dependencies for modifiers or executions)? Or did you everything in code?

EDIT: Apparently, an attribute depending on the value of another attribute is achieved by using modifiers which capture attribute(s) (= attribute-based or custom calculation class modifier) like you wrote in the first quoted paragraph. :wink: This is awesome indeed!