Hi, i have trouble with Enhanced Input System
In BeginPlay i use:
APlayerController* PlayerController = Cast<APlayerController>(GetController());
if (PlayerController)
{
UEnhancedInputLocalPlayerSubsystem *Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer());
if (Subsystem)
{
Subsystem->ClearAllMappings();
Subsystem->AddMappingContext(InputContext, 0);
}
}
then i override SetupPlayerInputComponent Binding the action
void ATank::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) {
Super::SetupPlayerInputComponent(PlayerInputComponent);
FString Name = GetName();
UE_LOG(LogTemp, Warning, TEXT("Setup %s"), *Name);
UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(PlayerInputComponent);
EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &ATank::Move);
}
the Move function is:
void ATank::Move(const FInputActionValue& value) {
UE_LOG(LogTemp, Warning, TEXT("Move: %f"), value.Get<float>());
}
MoveAction and InputContext are setted in BluePrint editor to correct InputAction and InputMappingContext objects if i use the command showdebug enhancedinput
i see that it detects the key pressed, i check in the logs and the BindAction is successful, but seems that the Move function never get called…
Thanks.