*구현
1. Data Asset 만들기
#pragma once
#include "CoreMinimal.h"
#include "Engine/DataAsset.h"
#include "AuraInputConfig.generated.h"
/**
*
*/
UCLASS()
class AURA_API UAuraInputConfig : public UDataAsset
{
GENERATED_BODY()
};
2. 설계
구조체 : InputAction, Tag
변수 : 구조체( InputAction, Tag )배열을 가짐
함수 : 태그에 맞는 InputAction 찾는 함수
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameplayTagContainer.h"
#include "Engine/DataAsset.h"
#include "AuraInputConfig.generated.h"
USTRUCT(BlueprintType)
struct FAuraInputAction
{
GENERATED_BODY()
UPROPERTY(EditDefaultsOnly)
const class UInputAction* InputAction = nullptr;
UPROPERTY(EditDefaultsOnly)
FGameplayTag InputTag = FGameplayTag(); //포인터아님 -> 헤더인클루드해야함
};
/**
*
*/
UCLASS()
class AURA_API UAuraInputConfig : public UDataAsset
{
GENERATED_BODY()
public:
const UInputAction* FindAbilityInputActionForTag(const FGameplayTag& InputTag, bool bLogNotFound=false) const;
UPROPERTY(EditDefaultsOnly,BlueprintReadOnly)
TArray<FAuraInputAction> AbilityInputActions;
};
// Fill out your copyright notice in the Description page of Project Settings.
#include "Input/AuraInputConfig.h"
const UInputAction* UAuraInputConfig::FindAbilityInputActionForTag(const FGameplayTag& InputTag,bool bLogNotFound) const
{
for(const FAuraInputAction& Action :AbilityInputActions)
{
if(Action.InputAction && Action.InputTag==InputTag) //nullchk, 일치하는 태그발견시
{
return Action.InputAction; //그때 인풋액션 리턴
}
}
if(bLogNotFound)
{
UE_LOG(LogTemp,Error,TEXT("Can`t find AbilityInputAction for Input Tag [%s], on InputConfig [%s]"),*InputTag.ToString(),*GetNameSafe(this))
//그때 태그, 클래스이름 출력
}
return nullptr;
}
* Tags.cpp에서 태그도 추가해줘야함(변수추가, 에디터에 태그추가 함수에 추가)
struct FAuraGameplayTags
{
public:
...
FGameplayTag InputTag_LMB;
FGameplayTag InputTag_RMB;
FGameplayTag InputTag_1;
FGameplayTag InputTag_2;
FGameplayTag InputTag_3;
FGameplayTag InputTag_4;
void FAuraGameplayTags::InitializeNativeGameplayTags()
{
...
/*
* Input Tags
*/
GameplayTags.InputTag_LMB = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("InputTag.LMB"),
FString("Input Tag for Left Mouse Button")
);
GameplayTags.InputTag_RMB = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("InputTag.RMB"),
FString("Input Tag for Right Mouse Button")
);
GameplayTags.InputTag_1 = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("InputTag.1"),
FString("Input Tag for 1 key")
);
GameplayTags.InputTag_2 = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("InputTag.2"),
FString("Input Tag for 2 key")
);
GameplayTags.InputTag_3 = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("InputTag.3"),
FString("Input Tag for 3 key")
);
GameplayTags.InputTag_4 = UGameplayTagsManager::Get().AddNativeGameplayTag(
FName("InputTag.4"),
FString("Input Tag for 4 key")
);
}
* BP작업
1. BP에서 DataAsset추가
2. IA 추가
3. IMC에 IA들 추가, 설정
4. DA에서 태그와 IA 연결!
런타임에 얼마든지 다른 입력으로 교체가능!!
'UE5 > Gameplay Abilities' 카테고리의 다른 글
[UE5] 태그에 맞는 능력 활성화 구현 (0) | 2024.06.09 |
---|---|
[UE5] Input바인딩용 클래스 생성, 클릭이벤트 발생 테스트 (0) | 2024.06.09 |
[UE5] GA 옵션들 살펴보기 (0) | 2024.06.09 |
[UE5] GameplayAbility class 구현 (0) | 2024.06.09 |
[UE5] Gameplay Ability 개념 (0) | 2024.06.08 |