보키_기록용
Lyra에서 Input Mapping Context 살펴보기 (1) 본문
시작하기에 앞서, 기본 클래스들을 만들어야 한다. Enghanced Input 시작하기를 참조.
Input Mapping Context : 사용자 입력을 입력 작업에 매핑하며 각 사용자에 대해 동적으로 추가, 제거 또는 우선 순위를 지정할 수 있다.
기존에는 그냥 간단하게 PlayerControllerBP에다 AddMappingContext를 했다.
Lyra에서는 어떻게 적용하는지 살펴보려고 한다. Lyra는 기능 간의 종속성을 피하기 위해 GameFeature로 독립형 기능을 만들어서 사용한다. 이 GameFeature의 Actin에서 AddInputConfig를 정의해서 사용한다.
이것을 위해서 GameFeature플러그인을 추가해야한다. 아래 링크는 추가하는 법있는 공식문서
Game Features and Modular Gameplay in Unreal Engine | Unreal Engine 5.0 Documentation
Game Features and Modular Gameplay
Build standalone features that you can quickly activate or deactivate.
docs.unrealengine.com
우선 Lyra에서 InputMappingContext(IMC)를 적용하는 방법은 크게 2가지가 있다.
1) PlayerMappableInputConfig(PMI)
2) LyraExperienceActionSet
1) PlayerMappableInputConfig(PMI)
여기서도 방법이 2가지로 나뉘는데,
- B_SimpleHeroPawn (ULyraCharacter 파생 BP) : 게임 이전에 로비?에서 움직이기만 하는 폰. GameFeature를 안쓰는 간단한 방식.
- ShooterCore (UGameFeatureData)
- TopDownArena (UGameFeatureData)
이런 식으로 나눠놓은 이유는 Lyra는 ShooterCore모드, TopDownArena모드 이런식으로 게임이 여러개인데(롤로 치면 일반모드, 칼바람모드 이런식?), 이 게임들 마다 쓰는 기능이 다를테고, 이걸 독립성을 지키는 방식으로 구조를 짜기위해 이런 방식으로 만든 것 같다. (확실한건 아님)
PMI의 내부를 보면
- PlayerMappableInputConfig(PMI)
- InputMappingContext
이런식으로 키바인딩을 하는 역할을 수행하고 있다.
- B_SimpleHeroPawn
C++ 코드 내에 ULyraHeroComponent::InitializePlayerInput() 부분을 보면 InputMappingContext를 추가한다.
<hide/>
// LyraHeroComponent.h
UPROPERTY(EditAnywhere)
TArray<FMappableConfigPair> DefaultInputConfigs;
// LyraHeroComponent.cpp
void ULyraHeroComponent::InitializePlayerInput(UInputComponent* PlayerInputComponent)
{
// ...
// Register any default input configs with the settings so that they will be applied to the player during AddInputMappings
for (const FMappableConfigPair& Pair : DefaultInputConfigs)
{
FMappableConfigPair::ActivatePair(Pair);
}
// ...
}
BP로 가서 컴포넌트탭에 LyraHero > 디테일을 보면 Default Input Config가 있다.
GameFeatureData 관련은 길어져서 (2)로 후술
Lyra에서 Input Mapping Context 살펴보기 (2)
'언리얼 > Enhanced Input System' 카테고리의 다른 글
UE5 Enhanced Input으로 카메라 터치 조작하기(Pan Camera) (0) | 2023.03.21 |
---|---|
Lyra에서 Input Mapping Context 살펴보기 (3) (0) | 2022.10.27 |
Lyra에서 Input Mapping Context 살펴보기 (2) (0) | 2022.10.26 |
Enhanced Input System을 위한 Game Feature 추가하기 (0) | 2022.10.14 |
C++에서 Enhanced Input System 사용하기 (1) | 2022.09.13 |