언리얼 엔진/Gameplay Ability System - Udemy

Gameplay Ability System(GAS) - Ability 클래스 생성

mane 2024. 2. 6. 23:57
728x90
반응형

인사말

안녕하세요. 오늘은 GAS 에 있는 UAbilitySystemComponentUAttributeSet 클래스를 생성하겠습니다.


Build.cs Dependency Module 추가

  • GameplayTags
  • GameplayTasks
  • GameplayAbilities
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput", "GameplayAbilities" });

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

 


Aura Character Base

  • UAbilitySystemComponent, UAttributeSetIAbilitySystemInterface 를 추가합니다.
  • IAbilitySystemInterface 는 virtual UAbilitySystemComponent* GetAbilitySystemComponent() 함수를 가지고 있다.
// Copyright mane
#pragma once

#include "AbilitySystemInterface.h"
#include "GameFramework/Character.h"
#include "AuraCharacterBase.generated.h"

class UAuraAbilitySystemComponent;
class UAttributeSet;
class UAbilitySystemComponent;

UCLASS(Abstract)
class AURA_API AAuraCharacterBase : public ACharacter, public IAbilitySystemInterface
{
    GENERATED_BODY()

public:
    AAuraCharacterBase();
    virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
    UAttributeSet* GetAttributeSet() const {return AttributeSet;}
protected:
    virtual void BeginPlay() override;

    UPROPERTY(EditAnywhere, Category = "Combat")
    TObjectPtr<USkeletalMeshComponent> Weapon;

    UPROPERTY()
    TObjectPtr<UAbilitySystemComponent> AbilitySystemComponent;

    UPROPERTY()
    TObjectPtr<UAttributeSet> AttributeSet;
};

Aura Player State

  • Aura Player State 에도 동일하게 UAbilitySystemComponentUAttributeSet 와 IAbilitySystemInterface 를 추가합니다.
// Copyright mane

#pragma once

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

class UAttributeSet;
class UAbilitySystemComponent;
/**
 * 
 */
UCLASS()
class AURA_API AAuraPlayerState : public APlayerState, public IAbilitySystemInterface
{
    GENERATED_BODY()

public:
    AAuraPlayerState();
    virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
    UAttributeSet* GetAttributeSet() const {return AttributeSet;}
protected:
    UPROPERTY()
    TObjectPtr<UAbilitySystemComponent> AbilitySystemComponent;

    UPROPERTY()
    TObjectPtr<UAttributeSet> AttributeSet;
};

 

728x90
반응형