단일 어트리뷰트 데이터인 GameplayAttributeData의 묶음
GameplayAttributeData는 하나의 값이 아닌 두 가지 값으로 구성되어 있음
어트리뷰트 세트 접근자 매크로
많이 수행되는 기능에 대해 매크로를 만들어 제공함
ASC는 초기화될 때 같은 액터에 있는 UAttributeSet 타입 객체를 찾아서 등록함
(이번 강의에서는 BaseValue만 사용함)
어트리뷰트 세트의 인자 세팅을 위한 매크로 제공
/**
* This defines a set of helper functions for accessing and initializing attributes, to avoid having to manually write these functions.
* It would creates the following functions, for attribute Health
*
* static FGameplayAttribute UMyHealthSet::GetHealthAttribute();
* FORCEINLINE float UMyHealthSet::GetHealth() const;
* FORCEINLINE void UMyHealthSet::SetHealth(float NewVal);
* FORCEINLINE void UMyHealthSet::InitHealth(float NewVal);
*
* To use this in your game you can define something like this, and then add game-specific functions as necessary:
*
* #define ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \
* GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \
* GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \
* GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \
* GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName)
*
* ATTRIBUTE_ACCESSORS(UMyHealthSet, Health)
*/
ASC에 AttributeSet를 추가하지 않아도 자동으로 관리
// AbilitySystemComponent_Abilities.cpp
void UAbilitySystemComponent::InitializeComponent()
{
...
TArray<UObject*> ChildObjects;
GetObjectsWithOuter(Owner, ChildObjects, false, RF_NoFlags, EInternalObjectFlags::Garbage);
// Owner의 자식 오브젝트들을 순회하며 UAttributeSet 타입인 오브젝트를 가져옴
for (UObject* Obj : ChildObjects)
{
UAttributeSet* Set = Cast<UAttributeSet>(Obj);
if (Set)
{
// 타입이 다른 어트리뷰트 세트를 추가 (중복 방지)
SpawnedAttributes.AddUnique(Set);
}
}
SetSpawnedAttributesListDirty();
}
- GAS 디버깅 시 선택한 캐릭터에 대해서만 태그 출력
GAS 디버깅 화면에는 기본으로 모든 캐릭터에 대해 태그가 출력됩니다.
DefaultGame.ini 파일에 아래를 추가합니다.[/Script/GameplayAbilities.AbilitySystemGlobals] bUseDebugTargetFromHud=True
https://github.com/dnjfs/ArenaBattle_GAS/commit/04c7ea0e194f7258380c086ffb5356fb71b3e38d
Attribute Set 구현
GameplayAttributeData들을 관리하는 어트리뷰트 세트 추가
제공되는 매크로로 어트리뷰트 기본 기능 구현
NPC와 PlayerState에서 각자 소유
공격 범위 지정
TA에서 Source 액터의 AttributeSet을 가져와 AttackRange와 AttackRadius 값을 반환
데미지 처리
공격 성공 시 GA에서 대상의 AttributeSet에서 값을 직접 세팅