Help: Why is my Enhanced Input Started event being called twice?

I set the binding to Started mode in C++, but when I press a key once in the game, the function is called twice. Does anyone know why this is happening?

“.h file”
UEnhancedInputLocalPlayerSubsystem* Subsystem;
UEnhancedInputComponent* Input;

“.cpp file”

void APeopPlayController::SetupInputComponent()
{
Super::SetupInputComponent();

Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(GetLocalPlayer());

check(InputMapping);

Subsystem->ClearAllMappings();
Subsystem->AddMappingContext(InputMapping,0);

Input = Cast<UEnhancedInputComponent>(InputComponent);
Input->BindAction(IA_Move, ETriggerEvent::Triggered, this, &APeopPlayController::Move);
Input->BindAction(IA_Jump, ETriggerEvent::Triggered, this, &APeopPlayController::isJump);
Input->BindAction(IA_Jump, ETriggerEvent::Completed, this, &APeopPlayController::isJump);
Input->BindAction(IA_Look, ETriggerEvent::Triggered, this, &APeopPlayController::Look);
Input->BindAction(IA_E, ETriggerEvent::Started, this, &APeopPlayController::EKey);

}

void APeopPlayController::EKey(const FInputActionValue& Value)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT(“EKey”));
}

1 Like

The same action IA_Jump is bound twice, once for Triggered and once for Completed.

  • Triggered: The action was triggered. This means that it has completed the evaluation of all trigger requirements. For example, a “Press and Release” trigger is sent when the user releases the key.
  • Completed: The trigger evaluation process is completed.

I haven’t seen how you set up your input action, but I’ll assume you set the Trigger to “Pressed”, and if so, it means that Triggered and Completed are the same thing, so your function is called twice.

Read about trigger states here:

As for IA_E, I can’t tell what’s wrong unless I see how the input action is set up. There also might be something strange with your input context.

Hello, I uploaded my project on GitHub. Can you take a look and see why?

No.

I don’t have that version of Unreal installed anyways. Just post screenshots of your input action and context with the details expanded.

ok,The following situation doesn’t involve only the ‘e’ key; when I set the ‘w’ key to ‘started,’ it also triggered twice. Let me know if you need any additional information










Thanks,The issue has been resolved. SetupInputComponent is automatically called by the system and does not need to be called manually.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.