Description

This is happening because the FInputActionInstance has the event as "triggered" when the triggered event and started event occur on the same frame. This is correct, but when the delegate gets fired you will never be able to get the correct trigger event from an event listener. 

Steps to Reproduce
  1. Create an Input Action A
  2. Create a mapping context "IMC_Test"
  3. Add a mapping to Input Action A in IMC_Test with a "Down" trigger to the "O" key
  4. Add the IMC to your player
  5. Add the following bindings in C++ in your character class
  6. // In your Player Controller class...
    
    // .h file ------------
    
    #include "InputAction.h"
    
    void Input_BenTest(const FInputActionInstance& ActionInstance);
    
    UPROPERTY(EditAnywhere)
    TObjectPtr<class UInputAction> BenTestAction;
    
    // .cpp file ------------------
    
    void AFooCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
    {
    UEnhancedInputComponent* LyraIC = Cast<UEnhancedInputComponent>(PlayerInputComponent);
    if (BenTestAction) { LyraIC->BindAction(BenTestAction, ETriggerEvent::Triggered, this, &ThisClass::Input_BenTest); LyraIC->BindAction(BenTestAction, ETriggerEvent::Started, this, &ThisClass::Input_BenTest); LyraIC->BindAction(BenTestAction, ETriggerEvent::Ongoing, this, &ThisClass::Input_BenTest); LyraIC->BindAction(BenTestAction, ETriggerEvent::Canceled, this, &ThisClass::Input_BenTest); LyraIC->BindAction(BenTestAction, ETriggerEvent::Completed, this, &ThisClass::Input_BenTest); //LyraIC->BindAction(BenTestAction, ETriggerEvent::None, this, &ThisClass::Input_BenTest); } 
    }
    
    void ULyraHeroComponent::Input_BenTest(const FInputActionInstance& ActionInstance)
    {
       const ETriggerEvent TriggerEvent = ActionInstance.GetTriggerEvent();
       
       const FString TriggerString = StaticEnum<ETriggerEvent>()->GetNameStringByValue(static_cast<int64>(TriggerEvent));
       
       UE_LOG(LogTemp, Warning, TEXT("Trigger Event: %s"), *TriggerString);   
    }

    Pie and press "O"

Result: The logs only display "triggered", not "started", even though the Started event is firing

Expected Result: The logs display "Started" then "triggered" and then "completed"

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-188867 in the post.

3
Login to Vote

Duplicate
ComponentUE - Gameplay - Input
Affects Versions5.15.25.3
Target Fix5.5
CreatedJun 15, 2023
ResolvedApr 19, 2024
UpdatedApr 19, 2024