🚀 How to Deal Damage in Unreal's GAS: Meta Attribute and Execution Calculation Pattern
What are meta attributes and how to use them Most commonly, and in this example, a meta attribute will be used for damage. Meta attributes are placeholder attributes that act as intermediaries on which we perform all the necessary calculations before damage is actually applied. For projects that have more complex damage handling in which certain calculations should be performed before damage is applied (armor, buffs, resistances etc.), a meta attribute is a good choice. Meta attributes are also useful because they separate concerns between the damage dealer and the target, as the damage dealer doesn't need to know how the target handles its damage. Meta attributes are typically not replicated. Making a meta attribute To make a damage meta attribute, you can make a regular attribute in your attribute set, which won't be replicated as damage should only be handled on the server, so there's no need for a GetLifetimeReplicatedProps entry or an OnRep. UPROPERTY(BlueprintReadOnly, Category = "Meta Attributes") FGameplayAttributeData IncomingDamage; ATTRIBUTE_ACCESSORS(ThisClass, IncomingDamage) Using a meta attribute To use the meta attribute, in PostGameplayEffectExecute, we can store the value of this meta attribute in a local variable to use it later, and immediately zero out the attribute so that any new damage starts at 0 instead of adding to previous values. Now, we can have a check for if the damage is above 0, in which case we can subtract from our health attribute with it,...
👉 Read more: https://dev.to/marko-ue/how-to-deal-damage-in-unreals-gas-meta-attribute-and-execution-calculation-pattern-3da7
