1. 레벨업 정보 데이터 에셋(LevelUpInfo Data Asset)
(1) C++ 레벨업 정보 클래스
#pragma once
#include "CoreMinimal.h"
#include "Engine/DataAsset.h"
#include "LevelUpInfo.generated.h"
USTRUCT(BlueprintType)
struct FAuraLevelUpInfo
{
GENERATED_BODY()
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
int32 LevelUpRequirement = 0;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
int32 AttributePointAward = 1;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
int32 SpellPointAward = 1;
};
UCLASS()
class AURA_API ULevelUpInfo : public UDataAsset
{
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly)
TArray<FAuraLevelUpInfo> LevelUpInformation;
int32 FindLevelForXP(int32 XP);
};
경험치 필요량, 속성 포인트, 스펠 포인트의 정보를 담은 AuraLevelUpInfo 구조체를 사용한다.
데이터 에셋은 이런 구조체를 각 레벨별로 가지게 된다.
#include "AbilitySystem/Data/LevelUpInfo.h"
int32 ULevelUpInfo::FindLevelForXP(int32 XP)
{
// 경험치 필요량 찾기
for (int i = 0; i < LevelUpInformation.Num(); i++)
{
if (LevelUpInformation[i].LevelUpRequirement >= XP)
{
return i;
}
}
return 1;
}
각 레벨은 이전 레벨까지의 경험치 요구량의 합이 될 것이며, 캐릭터가 보유한 경험치도 지금까지 획득한 경험치의 총합이 될 것이다.
(2) 데이터 에셋 블루프린트 생성
'UE 5 스터디 > Gameplay Ability System(GAS)' 카테고리의 다른 글
20-4. 경험치 - (3) 경험치 변화 델리게이트 바인딩 (0) | 2025.01.15 |
---|---|
20-3. 경험치 - (2) 경험치, 레벨 도입 (0) | 2025.01.15 |
20-1. 경험치와 레벨업 (0) | 2025.01.15 |
19-10. 모델링 모드 (0) | 2025.01.14 |
19-9. 오버레이 UI - (7) 스펠 글로브에 쿨다운 시간 표기 (0) | 2025.01.14 |