관리 메뉴

Mini

[UE5] GAS 개요이해 // PlayerState, ASComponent, AttributeSet 본문

UE5/GAS

[UE5] GAS 개요이해 // PlayerState, ASComponent, AttributeSet

Mini_96 2024. 5. 26. 17:11

1. 개요

2. 구성방법

2.1 : 폰에직접 달기

(-) 폰이 죽으면, 능력치 데이터가 없어져버림 -> 별도로 데이터를 저장해줘야함

2.2 : PlayerState라는 별도 클래스에 달기 && 폰과 PS 연결

(+)폰이 죽으면, 폰만죽음

부활시, 새 폰과 연결만 해주면됨

 

3. 실전적용

적 : GAS를 직접 가짐 // 간단함, ai controller에서 조정하므로

플레이어 : PS로 관리함 // 폰을 바꿀일이 많으므로

 

1. PlayerState 만들기

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerState.h"
#include "AuraPlayerState.generated.h"

/**
 * 
 */
UCLASS()
class AURA_API AAuraPlayerState : public APlayerState
{
	GENERATED_BODY()
public:
	AAuraPlayerState();

};
#include "Player/AuraPlayerState.h"

AAuraPlayerState::AAuraPlayerState()
{
	// 네트워크 업데이트 주기를 설정합니다. (단위: 헤르츠, 초당 업데이트 횟수)
	// 이 경우, NetUpdateFrequency를 100으로 설정하여 1초에 100번의 네트워크 업데이트를 수행합니다.
	NetUpdateFrequency = 100.f;
}

2. 플러그인 활성화

3. AS 컴포넌트생성

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "AbilitySystemComponent.h"
#include "AuraAbilitySystemComponent.generated.h"

/**
 * 
 */
UCLASS()
class AURA_API UAuraAbilitySystemComponent : public UAbilitySystemComponent
{
	GENERATED_BODY()
	
};

4. Attritube Set 생성

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "AttributeSet.h"
#include "AuraAttributeSet.generated.h"

/**
 * 
 */
UCLASS()
class AURA_API UAuraAttributeSet : public UAttributeSet
{
	GENERATED_BODY()

};

5. Build.cs > 모듈추가

PrivateDependencyModuleNames.AddRange(new string[] { "GameplayAbilities","GameplayTags","GameplayTasks" });