tranek / GASShooter

Advanced FPS/TPS Sample Project for Unreal Engine 4's GameplayAbilitySystem plugin
MIT License
953 stars 265 forks source link

Why We Captured the Damage Attribute From Source? #41

Closed RyuginStudio closed 1 year ago

RyuginStudio commented 1 year ago

On line 21 of GSDamageExecutionCalc.cpp DEFINE_ATTRIBUTE_CAPTUREDEF(UGSAttributeSetBase, Damage, Source, true);

According to your description, 'Damage' is a meta attribute, it can distribute the value to own attributes, Eg. health or armor. Well, my question is why we need to captured the 'Damage' from the 'source'?

I think 'Source' is the GE's instigator. If A was injured by B, Then Why A need to care about B's meta attribute 'Damage'.

tranek commented 1 year ago

A doesn't know about B's meta attribute Damage. All sources of damage in the damage GE are collected into B's Damage attribute. The server then takes this value, does whatever calculations it needs to, then outputs it to A's Damage attribute. A then reads from its own Damage attribute.

This is GAS convention initially copied from Epic's ActionRPG sample project. Epic's Lyra fixes a potential bug by creating a separate outgoing damage meta attribute BaseDamage, but otherwise follows the same pattern of reading the damage meta attribute from the source.