Comments (3)
Excellent was looking for something like this, didn't realize it was a feature that was just hidden by default.
The description in those release notes is really helpful, quoting that here just because it was buried a bit:
New: Introduced the concept of "evaluation channels" to non-instant gameplay effects within the ability system! Evaluation channels enable game-specific control over the order in which modifiers are evaluated in attribute calculations.
A game may specify how many channels it would like to use, as well as what they are named, and then modifiers can specify which channel they work on. The channels are evaluated in order, with the numerical output of the first channel serving as the input to the second channel, and so on.
Example: Imagine a sample attribute with a base value of 100. Now apply a multiplicative mod with magnitude 1.1 in channel 0 and a multiplicative mod with magnitude 1.1 in channel 1. The result will evaluate as ((100 * 1.1) * 1.1) instead of (100 * 1.2).
To use channels in a game, two settings within the INI section for AbilitySystemGlobals must be configured. First, bAllowGameplayModEvaluationChannels must be set to true, and second, the channels that should be used (and their names) must be specified in GameplayModEvaluationChannelAliases. Additionally, a game can optionally specify a default channel to use via DefaultGameplayModEvaluationChannel.
In addition, added various new channel-related functionality to the ability classes' API, such as the ability to base the magnitude of a modifier off of an attribute only evaluated up to a certain channel.
And here's some more important snippets from source after reading into them more:
Each channel gets evaluated in order, with the final result from the previous channel used as the base value for the next channel. This happens in FAggregatorModChannelContainer::EvaluateWithBase
:
float FAggregatorModChannelContainer::EvaluateWithBase(float InlineBaseValue, const FAggregatorEvaluateParameters& Parameters) const
{
float ComputedValue = InlineBaseValue;
for (auto& ChannelEntry : ModChannelsMap)
{
const FAggregatorModChannel& CurChannel = ChannelEntry.Value;
ComputedValue = CurChannel.EvaluateWithBase(ComputedValue, Parameters);
}
return ComputedValue;
}
Note that although it's iterating a map, the order of the map is automatically managed in FAggregatorModChannelContainer::FindOrAddModChannel
, to make sure that the channels are always evaluated in order:
FAggregatorModChannel& FAggregatorModChannelContainer::FindOrAddModChannel(EGameplayModEvaluationChannel Channel)
{
FAggregatorModChannel* FoundChannel = ModChannelsMap.Find(Channel);
if (!FoundChannel)
{
// Adding a new channel, need to resort the map to preserve key order for evaluation
ModChannelsMap.Add(Channel);
ModChannelsMap.KeySort(TLess<EGameplayModEvaluationChannel>());
FoundChannel = ModChannelsMap.Find(Channel);
}
check(FoundChannel);
return *FoundChannel;
}
Here's a practical example in which a character's move speed is being overridden by a Run ability, and then multiplied afterwards to apply a Slow debuff:
Since all modifiers in Channel0
are fully evaluated before any modifiers in Channel1
, the Override modifier op can be used here while still allowing Add or Multiply operations afterwards by putting them in a higher channel.
One last visual representation of how a subset of the modifier operations within each channel are used for the above example, with 350 as an arbitrary base value:
- BaseValue = 350
- Channel0Value = Override (650) OR ((BaseValue + Additive) * Multiplicitive) / Division
- Channel1Value = Override OR ((Channel0Value + Additive) * Multiplicitive (0.25)) / Division
- CurrentValue = (650 * 0.25) = 162.5
Thanks again for this great resource 🙏🏼
from gasdocumentation.
Hey, thank you.
I've heard of the evaluation channels before but have never used them. I don't want to include them without a working example.
Then you can do Attribute * MyChannel01Mod * MyChannel02Mod.
Or even Attribute * MyChannel01Mod * (MyChannel02Mod1 + MyChannel02Mod2).
Where does that happen?
from gasdocumentation.
This is really useful and great! I was about to start looking into how to modify EvaluateWithBase and really didn't want to dig into engine code to make a simple change. That fixes what I thought was a GAS shortcoming perfectly!
from gasdocumentation.
Related Issues (20)
- Stamina on client drains atlest and 2x speed.
- Doc section 4.6.2 FGameplayAbilityInputBinds FString enum deprecation HOT 1
- [Question] How can I use GAS with Enhanced Inputs? HOT 4
- Build issue on Unreal Engine 5.1.1
- Possible unnecessary cast in PlayMontageAndWaitForEvent HOT 2
- StaticLoadClass DamageNumberClass doesn't work when packaged HOT 1
- PlayMontageAndWaitForEvent doesn't work on clients HOT 5
- Suggestion to add Gameplay Event/GameplayEvent section, more information about them and example uses
- Clamping value on PreAttributeChanged not working on client
- CDOing AttributeSet in constructor results in garbage collection
- Suggestion for section 4.11.2 (custom target actor confirmation type)
- How to load cues from a Plugin Content folder path? HOT 2
- Output Modifiers in Gameplay Effect Execution Calculations Cannot Modify Source Attributes HOT 1
- AsyncTaskCooldownChanged node's call back too long HOT 1
- UAsyncTaskCooldownChanged HOT 1
- Load gameplay tags from .ini in a Plugin/Config folder HOT 6
- Gameplay Effect Components added in UE5.3
- Suggestion to add explanation on how to setup "InitAttributeSetDefaults()"
- OnAvatarSet called with player state HOT 1
- Modifier tag filter is not available.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gasdocumentation.