Search code examples
unreal-engine5gamepadenhanced-input-system

Enhanced Input Ongoing Gamepad Stick Binding


My desired behavior is that the gamepad left stick 2d vector will send input every tick about its latest position.

  • When I EnhancedInputComponent->BindAction(AimAction, ETriggerEvent::Started ... then I receive 1 event every time the stick is moved past the actuation threshold - not cool because I don't receive further events when the position of the stick changes, or when it returns to 0
  • When I EnhancedInputComponent->BindAction(AimAction, ETriggerEvent::Ongoing ... then I receive no events at all.

Input Mapping Context

Input Action


Solution

  • I figured out the answer by creating a new First-Person Game with C++ (the default Unreal 5 template) and studying how they did Enhanced Input.

    The Input Mapping Context has no triggers or modifiers:

    Input Mapping Context

    The Input Action also has no triggers or modifiers:

    Input Action

    Here's how I bound the action in ShipCharacter.cpp

    void AShipCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
    {
        Super::SetupPlayerInputComponent(PlayerInputComponent);
    
        if (UEnhancedInputComponent* Input = CastChecked<UEnhancedInputComponent>(PlayerInputComponent))
        {
            Input->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AShipCharacter::InputMove);
        }
    }
    
    void AShipCharacter::InputMove(const FInputActionValue& Value)
    {
        const FVector2D V = Value.Get<FVector2D>();
        // todo stuff with the input
    }