입력 전달 플로우

 

기본 Input Binding Delegate

subsystem인 InputComponent instance의 delegate를 통해 input-action binding하는 구조
InputComponent→BindAxis(" input name ", target instance, & exec function )
InputComponent→BindAction(" input name ", target instance, & exec function )


  • bind axis의 타겟 function은 float 파라미터를 가져야 함
  • input name은 editor - project setting - input 의 keybinding에 할당한 key값


ex)
class hi()
{
  • InputComponent→BindAxis ( "move_forward", this, hi::movef )
  • hi::movef ( float move_f ) { character.move_forward }
}

 

 

 

Enhanced Input System

  • input modifier
  • input action
  • input mapping context

 

구조 개요

회전 입력 전달 경로

  • 이동
    • Pawn :: AddMovementInput
      • Controller Rotation기준으로 forward, right vector 계산

 

Input Action

  • Input Action : 여러 input을 종합해 float1 ~ float3 의 output을 내보낼 수 있는 단위
  • Consume Input : 입력 소모해버리는지 여부?
  • Value Type : bool, float 1 ~ 3 가능하며, modifier에서 각 입력을 어떻게 값으로 변환할지 제어
    • ex. swizzle input axis value - bool이면 ( 1or0 , 0, 0 ) , float 1 이면 ( value, 0, 0 ), float 2면 ( value_x, value_y, 0 ), float 3이면 ( value_x, value_y, value_z ) 이런형태 ( 아래는 인풋타입에 따른 value 생성자. 다음 생성자에서 값 적용

 

Input Modifier

  • 커스텀 타입으로, Input 시, virtual ModifyRaw_Implementation( 인풋, FInputActionValue ( bool ~ float3 ), DeltaTime ) method를 customize하여 → output value를 줄 수 있는 연산모듈
    Input Modifier Class & Modify Raw ( override function )

 

더보기

.h

UCLASS(NotBlueprintable, MinimalAPI, meta = (DisplayName = "Swizzle Input Axis Values"))
class UInputModifierSwizzleAxis : public UInputModifier
{
   GENERATED_BODY()
 
public:
 
   // Default to XY swap, useful for binding 1D inputs to the Y axis.
   UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Settings)
   EInputAxisSwizzle Order = EInputAxisSwizzle::YXZ;
 
protected:
   virtual FInputActionValue ModifyRaw_Implementation(const UEnhancedPlayerInput* PlayerInput, FInputActionValue CurrentValue, float DeltaTime) override;
   virtual FLinearColor GetVisualizationColor_Implementation(FInputActionValue SampleValue, FInputActionValue FinalValue) const override;
};

 

.cpp

FInputActionValue UInputModifierSwizzleAxis::ModifyRaw_Implementation(const UEnhancedPlayerInput* PlayerInput, FInputActionValue CurrentValue, float DeltaTime)
{
    FVector Value = CurrentValue.Get<FVector>();
    switch (Order)
    {
    case EInputAxisSwizzle::YXZ:
        Swap(Value.X, Value.Y);
        break;
    case EInputAxisSwizzle::ZYX:
        Swap(Value.X, Value.Z);
        break;
    case EInputAxisSwizzle::XZY:
        Swap(Value.Y, Value.Z);
        break;
    case EInputAxisSwizzle::YZX:
        Value = FVector(Value.Y, Value.Z, Value.X);
        break;
    case EInputAxisSwizzle::ZXY:
        Value = FVector(Value.Z, Value.X, Value.Y);
        break;
    }
    return FInputActionValue(CurrentValue.GetValueType(), Value);

axis에 사용되는 swizzle axis 예시

  • bool이면 ( 1or0 , 0, 0 ) , float 1 이면 ( value, 0, 0 ), float 2면 ( value_x, value_y, 0 ), float 3이면 ( value_x, value_y, value_z ) 이런형태 ( 아래는 인풋타입에 따른 value 생성자. 다음 생성자에서 값 적용

 

Input Mapping Context

 

 

입력 설정

활성화된 PlayerController의 Enhanced Input Local Player Subsystem 소켓에  특정 Input Mapping Context를 추가

  • PlayerController
    • Enhanced Input Local Player Subsystem
      • Input Mappings[]
        • ← add Mapping Context
  • Input_Mappin_Context에서 할당했던 [Input_Action]의 이름을 통해 event 연결

 

'Unreal > UE Architecture' 카테고리의 다른 글

Cpp -> BP Pipeline 1  (0) 2024.05.17
문자열 처리  (0) 2024.05.16
UE Macro & Reflection System  (0) 2024.05.16
Smart Pointer & Container & Serialize  (0) 2024.05.16
기본 구성  (0) 2024.05.16

+ Recent posts