공부/UE

[UE] 입력을 매핑하는 과정

sudo 2025. 10. 3. 01:04
반응형

1. Input Action 만들기

WASD로 움직일거라 Axis2D로 세팅

 

2. Input Mapping Context 만들기

아까 Input Action을 만든 이유는 Input Mapping Context에 Mapping해주기 위함이다

 

3. UEnhancedInputLocalPlayerSubsystem에 내가 만든 InputMappingContext 연결해주기

UEnhancedInputLocalPlayerSubsystem는 언리얼에서 제공하는 Subsystem의 일종이다(https://welikecse.tistory.com/193)

 

4.  InputComponent에 내가 원하는 동작에 대한 함수를 바인딩

InputComponent는 Player Controller 클래스가 멤버로 갖고 있다

InputComponent를 냅다 자식 클래스인 UEnhancedInputComponent 타입으로 캐스팅하는데 이게 가능한 이유는 Project Setting에서 Default Input Component class를 EnhancedInputComponent로 세팅해놨기 때문에 가능하다.

 

5. 움직이는 동작 함수 구현

여기서 좀 헷갈리는건 입력 컨트롤러의 기본 방향은 앞방향(언리얼 좌표계 +x 방향)이다. 그래서 W,S키에 대해서 움직일때는 Swizzle Input Axis Values 세팅을 해서 좌우방향(언리얼 좌표계 +- y 방향)으로 입력이 먹도록 한다

반응형

'공부 > UE' 카테고리의 다른 글

[UE] GAS in Multiplayer Game  (0) 2025.10.03
[UE] Rotation  (0) 2025.10.03
[UE5] Subsystem  (0) 2025.10.02
[UE] FString, TCHAR  (0) 2025.09.24
[UE] Unreal C++ Coding Convention  (0) 2025.09.22