Course contentsShow
← Unreal Engine Game Development
Lesson 652 of 8809. Gameplay Ability System (GAS)Free lesson

Applying Modifiers to Execution Output

Learn how to push calculated results back into the Gameplay Effect context to update attribute values based on your custom math.

In this lesson, you will learn how to finalize your custom math inside an UGameplayEffectExecutionCalculation by pushing calculated results back into the Gameplay Effect context to update your target's attributes.

The Final Step of the Calculation

Up to this point, you have captured source and target attributes and performed your custom math (e.g., calculating damage based on strength vs. armor). However, simply calculating a float isn't enough; the Gameplay Effect system needs to know exactly how that result should be applied to the target's AttributeSet. This is where FGameplayModifierEvaluatedData comes in.

To push your result back into the system, you must construct an output modifier. This object tells the ExecutionCalculation how to modify the attribute—whether to add to it, subtract from it, or overwrite it.

Implementing the Output

Inside your Execute_Implementation function, once you have your CalculatedMagnitude, you add it to the execution output like this:

// 1. Calculate your final magnitude
float DamageAmount = SourceStrength * 2.0f - TargetArmor * 0.5f;

// 2. Define the output modifier
// We specify the attribute we want to modify and the operation (Additive)
FGameplayModifierEvaluatedData EvaluatedData(
    UMyAttributeSet::GetHealthAttribute(), 
    EGameplayModOp::Additive, 
    -DamageAmount
);

// 3. Push it to the execution output
OutExecutionOutput.AddOutputModifier(EvaluatedData);

Why This Matters

By using AddOutputModifier, you remain within the flow of the GAS lifecycle. This ensures that when the attribute value changes, the system automatically triggers necessary callbacks like PostGameplayEffectExecute, allowing your UI, clamping logic, and attribute listeners to respond immediately to the change. If you were to manually modify the attribute variable directly inside the calculation, you would bypass these critical system notifications, potentially causing the UI to desync or your health clamping to fail.

By feeding the result through OutExecutionOutput, you ensure the calculation is handled as a legitimate Gameplay Effect modification, maintaining the integrity of your attribute-based systems.

Key Takeaway: Always use AddOutputModifier to transmit your final calculations, ensuring the Gameplay Ability System correctly processes attribute updates and triggers downstream logic like clamping or UI updates.