게임플레이 어빌리티 시스템(Gameplay Ability System) 은 RPG나 MOBA 타이틀에서 볼 수 있는 어빌리티 및 어트리뷰트 유형을 구축하기 위한 고도로 유연한 프레임워크입니다. 게임 내 캐릭터가 사용할 액션이나 패시브 어빌리티, 이러한 액션의 결과로 다양한 어트리뷰트를 높이거나 낮추는 상태 이펙트를 만들 수 있고, '재사용 대기 시간' 타이머나 자원 비용을 구현하여 액션의 사용 빈도를 조절하거나, 어빌리티의 레벨과 레벨에 따른 이펙트를 변경하거나, 파티클 및 사운드 이펙트를 활성화하는 등의 작업이 가능합니다. 게임플레이 어빌리티 시스템을 사용하면 점프처럼 단순한 것부터 최신 RPG나 MOBA 타이틀 내 인기 캐릭터의 기술 모음처럼 복잡한 것까지 다양한 인게임 어빌리티를 설계 및 구현하고 효과적으로 연결할 수 있습니다.
게임플레이 어빌리티(Gameplay Abilities) 는 UGameplayAbility
클래스의 C++ 또는 블루프린트 자손입니다. C++ 코드나 블루프린트 스크립팅에서 특정 어빌리티가 어떤 역할을 하는지, 어빌리티의 리플리케이션과 인스턴싱 행동 같은 요소가 어떻게 처리되는지 정의합니다.
게임플레이 어빌리티 내 로직은 일반적으로 어빌리티를 정의하는 로직의 과정 중에 어빌리티 태스크(Ability Task) 라는 일련의 비동기 구성 요소를 호출합니다. 어빌리티 태스크는 추상적인 UAbilityTask
클래스에서 파생됩니다. 어빌리티 태스크는 C++로 작성되며, 작업을 완료할 때 수시로 Cpp의 여러 델리게이트 중 하나를 호출하거나 블루프린트의 출력 실행 핀 중 하나를 호출합니다. 예를 들어 타깃이 필요한 어빌리티에는 '에임' 태스크와 타깃을 확정하는 델리게이트 또는 출력 핀, 어빌리티를 취소하는 델리게이트 또는 출력 핀이 각각 있을 수 있습니다.
게임플레이 어빌리티 시스템은 게임플레이 어빌리티뿐 아니라 게임플레이 어트리뷰트(Gameplay Attributes) 와 게임플레이 이펙트(Gameplay Effects) 도 지원합니다. 게임플레이 어트리뷰트는 게임이나 액터에 특정한 방식으로 영향을 미치는 FGameplayAttribute
구조체에 저장되는 float
값입니다. 생명력, 힘, 점프 높이, 공격 속도와 같은 일반적인 값이 여기 해당됩니다. 게임플레이 이펙트를 사용하면 즉시 또는 일정 시간 동안 게임플레이 어트리뷰트를 변경할 수 있습니다. 후자는 일반적으로 '버프'나 '디버프'라고 합니다. 게임플레이 이펙트의 예시로는 주문을 사용할 때 마법력을 줄이거나, '전력 질주' 어빌리티를 사용하는 동안 이동 속도를 높이거나, 치료약을 사용한 뒤 생명력을 서서히 회복하는 것 등이 있습니다.
게임플레이 어빌리티 시스템과 상호작용하는 액터에는 어빌리티 시스템 컴포넌트(Ability System Component) 가 있어야 합니다. 이 컴포넌트는 어빌리티를 활성화하고, 어트리뷰트를 저장하고, 이펙트를 업데이트하고, 액터 간 상호작용을 처리합니다. 게임플레이 어빌리티 시스템을 활성화하고 어빌리티 시스템 컴포넌트가 있는 액터를 생성하면, 어빌리티를 생성하고 액터가 어빌리티에 어떻게 반응할지 결정할 수 있습니다.
게임플레이 어빌리티 시스템은 플러그인으로 제공되기 때문에 사용 옵션을 선택해야 합니다. 플러그인을 활성화하려면 다음 두 단계를 따릅니다.
편집(Edit) > 플러그인(Plugins) 창에서 Gameplay Abilities 플러그인을 활성화합니다.
이 시스템의 기능을 완전히 활용하려면 프로젝트 내 "(프로젝트 이름).Build.cs" 파일의 PublicDependencyModuleNames
에 'GameplayAbilities', 'GameplayTags', 'GameplayTasks'를 추가합니다. 다음 퍼블릭 모듈 목록을 찾으면 쉽습니다.
PublicDependencyModuleNames.AddRange(newstring[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay" });
게임플레이 어빌리티 시스템을 사용하려면 괄호 처리된 목록에 다음과 같이 3개의 모듈 이름을 추가합니다.
PublicDependencyModuleNames.AddRange(newstring[] { "GameplayAbilities", "GameplayTags", "GameplayTasks", "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay" });
어빌리티 시스템 컴포넌트(Ability System Component)는 게임의 캐릭터가 게임플레이 어빌리티 시스템에 액세스할 때 사용하는 메인 인터페이스입니다. 이 컴포넌트는 게임플레이 어트리뷰트를 관리하고, 게임플레이 이벤트를 실행하고, 게임플레이 어빌리티를 저장하고, 게임플레이 어빌리티 활성화나 확인 및 취소 명령에 바인딩된 플레이어 입력을 처리할 수도 있습니다. 게임플레이 어빌리티 시스템과 상호작용해야 하는 모든 액터에는 어빌리티 시스템 컴포넌트가 필요합니다.
The Ability System Component (UAbilitySystemComponent
) is the bridge between Actors and the Gameplay Ability System. Any Actor that intends to interact with the Gameplay Ability System needs its own Ability System Component, or access to an Ability System Component owned by another Actor. Make sure that your project is set up to use the [Gameplay Ability System Plugin][making-interactive-experiences\GameplayAbilitySystem] before attempting to use the Ability System Component.
To set up your AActor
subclass to use the Gameplay Ability System, implement the IAbilitySystemInterface
interface and override the GetAbilitySystemComponent
function. This function must return the Ability System Component associated with your Actor. In most cases, the Actor class will have a variable, tagged with UPROPERTY
, that stores a pointer to the Ability System Component, similar to any built-in Component on any Actor type. While it is common for an Actor to have its own Ability System Component, there are cases in which you might want an Actor, such as a player's Pawn or Character, to use an Ability System Component owned by another Actor, like a Player State or Player Controller. Reasons for this may include things like a player's score, or long-lasting ability cooldown timers that do not reset when the player's Pawn or Character is destroyed and respawned, or when the player possesses a new Pawn or Character. The Gameplay Ability System supports this behavior; to implement it, write the Actor's GetAbilitySystemComponent
function so that it returns the Ability System Component you want to use.
The following procedure will help you to get started with a simple but common pattern that utilizes the Ability System Component.