본문 바로가기

Unreal/언리얼 엔진 5로 개발하는 멀티플레이어 게임(Book)

[Unreal] US_CharacterStats.h 스탯 구조체 생성

언리얼에는 구조체를 블루프린터에서 사용할 수 있도록 만드는 방법이 있다. 해당 구조체는 헤더 파일 밖에 사용하지 않아 엔진 에디터가 아닌 IDE에서 생성할 수 있다. 하지만 언리얼에서 사용할 땐 문제가 없지만 IDE에서는 CoreMinimal.h와 같은 기본적인 헤더 파일을 못 찾는 경우가 발생하여 에디터에서 생성하는 것을 추천한다.

US_CharacterStats.h

USTRUCT(BlueprintType)
struct UNREALSHADOWS_LOTL_API FUS_CharacterStats : public FTableRowBase
{
    GENERATED_BODY()

    UPROPERTY(BlueprintReadWrite, EditAnywhere)
    float WalkSpeed = 200.0f;

    UPROPERTY(BlueprintReadWrite, EditAnywhere)
    float SprintSpeed = 400.0f;

    UPROPERTY(BlueprintReadWrite, EditAnywhere)
    float DamageMultiplier = 1.0f;

    UPROPERTY(BlueprintReadWrite, EditAnywhere)
    int32 NextLevelXp = 10.0f;

    UPROPERTY(BlueprintReadWrite, EditAnywhere)
    float StealthMultiplier = 1.0f;
};

 

위와 같이 코드를 작성하면 다음과 같은 방법으로 캐릭터 데이터를 만들 수 있다.

 

 

Blueprints -> 기타 -> 데이터 테이블을 생성한 후 행 구조를 선택한다.

 

추가 버튼을 눌러 원하는 데이터 값을 넣어주면 완성된다.