Something I that disliked about the enhanced input system was having to individually bind each action, and add UInputActions for each action, and then initialize the actions in your blueprint. Seemed like a lot of redundant busy work when the mapping context contained all this information. I came across an easier solution in ALS that I thought I'd share. You set up your mapping context and match the button press functions names to the IA_* mapping and that's it. Far less bookkeeping. Here's the code:
void AProPlayerController::SetupInputComponent()
{
Super::SetupInputComponent();
UEnhancedInputComponent* EnhancedInputComponent = Cast<UEnhancedInputComponent>(InputComponent);
if (EnhancedInputComponent)
{
EnhancedInputComponent->ClearActionEventBindings();
EnhancedInputComponent->ClearActionValueBindings();
EnhancedInputComponent->ClearDebugKeyBindings();
BindActions(DefaultInputMappingContext);
BindActions(DebugInputMappingContext);
}
else
{
UE_LOG(LogTemp, Fatal, TEXT("We require Enhanced Input System to be activated in project settings to function properly"));
}
}