본문으로 건너뛰기
Unreal Engine GAS(Gameplay Ability System) 심화LESSON 05

ASC는 Character와 PlayerState 중 어디에 두어야 할까

난이도심화
예상 시간135분
선수지식4강의 ASC Interface

5강. ASC는 Character와 PlayerState 중 어디에 두어야 할까

1. 이번 강의에서 해결할 문제​

Character가 죽을 때 ASC도 사라지면 Respawn 뒤 Cooldown과 장기 Buff가 초기화됩니다. 반대로 모든 AI까지 PlayerState 패턴을 강제하면 소유 구조가 불필요하게 복잡합니다. ASC의 위치는 “GAS 샘플이 그렇게 했다”가 아니라 상태 수명과 네트워크 소유를 기준으로 결정합니다.

2. 학습 목표​

3. 핵심 개념​

기준Character ASCPlayerState ASC
Pawn 교체새 ASC같은 ASC, Avatar 교체
Respawn 후 Cooldown기본적으로 소멸유지 가능
AI단순하고 자연스러움PlayerState가 없어 부적합
초기화Character만 연결PlayerState Owner + Character Avatar
복잡도낮음Possession·OnRep 양쪽 처리 필요

플레이어 장기 상태가 PlayerState와 같은 수명이어야 하면 ASC도 PlayerState에 둡니다. 죽을 때 모든 효과가 초기화되는 Arena Pawn이라면 Character 소유가 더 명확할 수 있습니다.

4. 구현​

GASPlayerState.h
#pragma once

#include "AbilitySystemInterface.h"
#include "GameFramework/PlayerState.h"
#include "GASPlayerState.generated.h"

class UGASAbilitySystemComponent;
class UGASAttributeSet;

UCLASS()
class GASCOMBAT_API AGASPlayerState
: public APlayerState,
public IAbilitySystemInterface
{
GENERATED_BODY()

public:
AGASPlayerState();
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;

UGASAttributeSet* GetAttributes() const { return Attributes; }

private:
UPROPERTY(VisibleAnywhere)
TObjectPtr<UGASAbilitySystemComponent> AbilitySystemComponent;

UPROPERTY()
TObjectPtr<UGASAttributeSet> Attributes;
};
GASPlayerState.cpp
AGASPlayerState::AGASPlayerState()
{
NetUpdateFrequency = 30.0f;
AbilitySystemComponent = CreateDefaultSubobject<UGASAbilitySystemComponent>(
TEXT("AbilitySystemComponent"));
AbilitySystemComponent->SetIsReplicated(true);
AbilitySystemComponent->SetReplicationMode(
EGameplayEffectReplicationMode::Mixed);

Attributes = CreateDefaultSubobject<UGASAttributeSet>(TEXT("Attributes"));
}

UAbilitySystemComponent* AGASPlayerState::GetAbilitySystemComponent() const
{
return AbilitySystemComponent;
}

Character의 Interface 구현은 PlayerState ASC를 반환합니다. Client에서 PlayerState가 아직 복제되지 않은 시점에는 null일 수 있으므로 다음 강의에서 OnRep_PlayerState를 처리합니다.

5. 코드가 동작하는 이유​

PlayerState는 Pawn보다 오래 살아 Respawn과 Possession 변경 뒤에도 Ability·Effect·Attribute 상태를 유지할 수 있습니다. Mixed Mode는 소유자에게 더 많은 Effect 정보를, 다른 Client에는 최소 정보를 보내는 정책이므로 ASC Owner Actor의 네트워크 Owner 관계가 올바른지 확인해야 합니다.

6. 실패 사례와 해결​

7. 직접 실습​

8. 이해 점검 질문 3개​

9. 핵심 요약​

MINI QUIZ

ASC는 Character와 PlayerState 중 어디에 두어야 할까 미니 퀴즈

선택 즉시 정답과 해설을 확인할 수 있습니다. 결과는 이 브라우저에만 저장됩니다.

0 / 2
  1. 문제 1“ASC는 Character와 PlayerState 중 어디에 두어야 할까” 내용을 실제 작업에 적용한 설명으로 가장 알맞은 것은 무엇인가요?
  2. 문제 2‘AI에도 PlayerState 강제’ 상태에 관한 “ASC는 Character와 PlayerState 중 어디에 두어야 할까” 본문의 설명으로 가장 알맞은 것은 무엇인가요?
LESSON STATUS

학습을 마쳤나요?

직접 실습과 점검 질문까지 확인한 뒤 완료로 표시하세요.

5강. ASC는 Character와 PlayerState 중 어디에 두어야 할까 미완료 상태