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.
// 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"
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-188867 in the post.
3 |
Component | UE - Gameplay - Input |
---|---|
Affects Versions | 5.1, 5.2, 5.3 |
Target Fix | 5.5 |
Created | Jun 15, 2023 |
---|---|
Resolved | Apr 19, 2024 |
Updated | Jun 7, 2024 |