I’m implementing the Enhanced Input feature, but the input is not working. When I do Show Enhanced Input in the debug command during runtime, it displays: “No enhanced player input action mappings have been applied to this input”
I also initialized the player controller and local player subsystem in the begin play of my character class:
// Called when the game starts or when spawned
void ACPP_BaseCharacter::BeginPlay()
{
Super::BeginPlay();
if (APlayerController* PlayerController = Cast<APlayerController>(GetController()))
{
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer()))
{
Subsystem->ClearAllMappings();
Subsystem->AddMappingContext(PlayerInputMapping, 0);
}
}
}
I also checked the input project settings and the default player input classes is set enhanced player input. But one thing to note about this is that when I try to open the EnhancedPlayerInput class, it does not show up on the Content Browser. I don’t think that’s supposed to happen.
in your [ProjectName].Build.cs is “EnhancedInput” in either the PublicDependencyModuleNames, or PrivateDependencyModuleNames ? if the project did not start as C++ then it might not be there
did you assign the editor created items (InputMappingContext, and InputActions) in the blueprint for the character?
Controller is by default a public variable in APawn, and I don’t know why you are calling ClearAllMappings() as only the AddMappingContext() should be needed.
//Add Input Mapping Context
if (APlayerController* PlayerController = Cast<APlayerController>(Controller))
{
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer()))
{
Subsystem->AddMappingContext(DefaultMappingContext, 0);
}
}
for the dependencies if the editor builds and launches then it should be included (maybe they finally put it into input…
I mean in the blueprint you made of the character
you need to manually put them into the slots on the blueprint you make from your class. those are just pointers in your class, until you assign them in the blueprint they are just NULL
also remember to add the InputActions to the InputMappingContext as that is a required step for it to all work, and the Input Actions to be mapped to a given button.
in order to not have to assign the items in the blueprint, you would need to assign them in the code manually by getting the path to the item in the ContentBrowser (you can right click the item in the ContentBrowser, and get the path),
WARNING: this introduces the issue of if anyone on your project for any reason decides to move something that is referenced in C++ by path that reference will break, and also names must be exact so the same is true for renaming the file, or the folder.