๐ ์ ๋ฐ๋ฏธ GAS ๊ฐ์ ์ค ๊ธฐ๋กํด๋๊ณ ์ถ์ ๋ด์ฉ์ ์ ์ด๋ ํฌ์คํธ
Section 7 : GameplayEffect Modifier
AbilitySystemComponent์ AttributeTest ์นดํ
๊ณ ๋ฆฌ์์
DefaultStartingData์ ๋ฐ์ดํฐ ํ
์ด๋ธ ์ฑ์ฐ๊ธฐ

AttributeMetaData Row๋ฅผ ์ฌ์ฉํ๋ ๋ฐ์ดํฐ ํ
์ด๋ธ์ ๋ง๋ค์ด์ ์ฌ์ฉํ๋ฉด ๋๋ค.

๐๏ธ RowName์ ๋ฐ๋์ {AttributeSet ์ด๋ฆ}.{Attribute ์ด๋ฆ}์ ๊ตฌ์กฐ๋ฅผ ์ง์ผ์ผํ๋ค.
ex) AuraAttributeSet.Strength
BaseValue๋ง ํ์คํ ์ฑ์ฐ๋ฉด ๋๊ณ ์ด์ธ์ ๊ฐ์ ์คํ ์ ์ธํ๊ณ ๋ ์ฐธ๊ณ ๋ง.
(ํด๋น ๊ธฐ๋ฅ ์์ฒด๊ฐ ํ๋กํ ํ์
์ด๋ผ ๋ง์ด ์ฐ์ด์ง๋ ์๊ณ ํ์ ํ ์ดํํธ๋ฅผ ํตํด ์ด๊ธฐํํ๋ ๋ฐฉ๋ฒ์ ๋ง์ด ์ด๋ค๊ณ ํจ)

Attribute ์ด๊ธฐํ๋ฅผ ์ํ ์ดํํธ๋ฅผ ๋ง๋ค์ด์ ์บ๋ฆญํฐ ์ด๊ธฐํ ์์ ์ ์ดํํธ ์ ์ฉํ๊ธฐ

Primary Attribute๋ ์ ํด์ง ๊ฐ์ผ๋ก ์ด๊ธฐํํ๊ณ , ๊ทธ ์์ฒด๋ก ๋ค๋ฅธ Attribute์ ์ํฅ์ ๋ฐ์ง ์๋ ๊ฐ๋ค์ด๊ธฐ ๋๋ฌธ์ Duration Policy : Instant๋ก 1ํ ์ด๊ธฐํํด์ค๋ค.
๋ฐ๋ฉด Derived Attribute๋ ๋ค๋ฅธ ๊ฐ์ ์ํด ์ํฅ์ ๋ฐ๊ธฐ ๋๋ฌธ์ ๋ค๋ฅธ ๊ฐ ๋ณํ์ ๋์์ด ๊ฐ๋ฅํ๋๋ก Duration Policy : Infinite๋ก ์ค์ ํด์ค๋ค.
Infinite๋ก ๊ณ์ GameplayEffect๊ฐ ์ด์์๋ ์ํ์ด๊ธฐ๋๋ฌธ
๐๏ธ ์ฐ์ฐ์ ์ฐ์ ์์๊ฐ ์ ์ฉ๋๋ ๊ฒ์ด ์๋๋ผ ์์ฐจ์ ์ผ๋ก ๊ณ์ฐ๋๋ค.
Attribute Based

Backing Attribute์ ๊ฐ์ ๊ธฐ๋ฐ์ผ๋ก ๊ณ์ฐํ๋ค.

๐๏ธ Coefficient , Pre , Post ์ ๊ณ์ฐ ์์์ ์ฃผ์ํ๊ธฐ
Custom Calculation Class (MMC)
๐ Attribute๋ฟ๋ง ์๋๋ผ ์์ค๋ ํ๊ฒ์ด ๋ค๊ณ ์๋ ๋ค์ํ ๋ฐ์ดํฐ๋ฅผ ํ์ฉํด์ ๊ณ์ฐ์ด ๊ฐ๋ฅํ๋๋ก ํด์ค๋ค.
UGameplayModMagnitudeCalculation ํด๋์ค๋ฅผ ํ์ฉํ๋ค.

์ฒ์ C++ ํด๋์ค๋ฅผ ์์ฑํ๋ฉด ์๋ฌด๊ฒ๋ ์๋ ์ํ์ด๋ฏ๋ก ๋ค์ ๊ณผ์ ์ด ํ์ํ๋ค.
CalculateBaseMagnitude_Implementation ์ค๋ฒ๋ผ์ด๋Attribute ์บก์ฒ(FGameplayEffectAttributeCaptureDefinition)MyAttributeSet์ ๋ง๋ค์ด์ง ํจ์๋ก ํ ๋น AttributeToCapture - ์ด๋ค Attribute ์บก์ฒํ ์งAttribute๋ฅผ ์ดํํธ์ Source์์ ๋ฐ์์ฌ์ง, Target์์ ๋ฐ์์ฌ์ง ์ง์ RelevantAttributesToCapture์ ์บก์ฒํ Attribute ์ถ๊ฐํ๊ธฐGetCapturedAttributeMagnitude๋ก ์ํ๋ Attribute์ ๊ฐ์ ๋ฐ์์ค๊ณ CalculateBaseMagnitude_Implementation์ ๊ฒฐ๊ณผ๋ก ๋ฆฌํด๐ MMC_MaxHealth.h
UCLASS()
class AURA_API UMMC_MaxHealth : public UGameplayModMagnitudeCalculation
{
GENERATED_BODY()
public:
// 1. ์์ฑ์ ๋ง๋ค๊ธฐ
UMMC_MaxHealth();
// 2. ๊ณ์ฐ ํจ์ ์ค๋ฒ๋ผ์ด๋
virtual float CalculateBaseMagnitude_Implementation(const FGameplayEffectSpec& Spec) const override;
private:
// 3. ์บก์ฒ๋ฅผ ์ํ ๋ฉค๋ฒ ์ถ๊ฐ
FGameplayEffectAttributeCaptureDefinition VigorDef;
};
๐ MMC_MaxHealth.cpp
UMMC_MaxHealth::UMMC_MaxHealth()
{
// 3-1. ํน์ Attribute ์บก์ฒ
VigorDef.AttributeToCapture = UAuraAttributeSet::GetVigorAttribute();
// 3-2. Attribute Source ์ง์
// MaxHealth์ ๊ฒฝ์ฐ ํ๋ ์ด์ด ์บ๋ฆญํฐ๊ฐ ์คํฏ ์ด๊ธฐํํ ๋ ์ฌ์ฉํ๊ณ ์์ผ๋ฏ๋ก Source == Target
VigorDef.AttributeSource = EGameplayEffectAttributeCaptureSource::Target;
// 3-3. ์ค๋
์ท ์ฌ๋ถ ์ค์
// Attribute์ ๊ธฐ์ค์ ์ ์ด๋ ์๊ธฐ๋ก ํ ๊ฒ์ธ๊ฐ.
// True : EffectSpec์ด ์์ฑ๋์๋ง์ , False : Effect์ ์ ์ฉ ์์ ์
VigorDef.bSnapshot = false;
// 4. ๋ฆฌ์คํธ์ Attribute ์ถ๊ฐํ๊ธฐ
RelevantAttributesToCapture.Add(VigorDef);
}
float UMMC_MaxHealth::CalculateBaseMagnitude_Implementation(const FGameplayEffectSpec& Spec) const
{
// Source์ Target์ ํ๊ทธ ์ ๋ณด ์ ๊ทผ ๊ฐ๋ฅ
const FGameplayTagContainer* SourceTags = Spec.CapturedSourceTags.GetAggregatedTags();
const FGameplayTagContainer* TargetTags = Spec.CapturedTargetTags.GetAggregatedTags();
FAggregatorEvaluateParameters EvaluationParameters;
EvaluationParameters.SourceTags = SourceTags;
EvaluationParameters.TargetTags = TargetTags;
// 5. ํ์ํ Attribute์ ํ์ฌ๊ฐ ๋ฐ์์ค๊ธฐ
// Vigor๋ OutParam
float Vigor = 0.f;
GetCapturedAttributeMagnitude(VigorDef,Spec,EvaluationParameters,Vigor);
// ํด๋จํ (0๋ณด๋ค ๋ฎ์์ง์ง ์๋๋ก)
Vigor = FMath::Max<float>(Vigor,0.f);
// Source ์ค๋ธ์ ํธ ๋ฐ์์ค๊ธฐ (์ด ๊ฒฝ์ฐ AuraCharacter์ ๋ ๋ฒจ์ ์์๋ด๊ธฐ ์ํจ)
ICombatInterface* CombatInterface = Cast<ICombatInterface>(Spec.GetContext().GetSourceObject());
const int32 PlayerLevel = CombatInterface->GetCombatLevel();
// 6. ์ํ๋ ๊ฐ์ผ๋ก ์กฐ์ ํ ๋ค ๋ฆฌํด
return 80.f + 2.5f * Vigor + 10.f * PlayerLevel;
}
https://github.com/jongmin7759/Unreal_GAS/commit/41a52805e8ed6f9b0e4d2cd34efe4a68461bf805