Use EnhancedInput in UE5.1 C++
Bind action
EnhancedInputComponent->BindAction(PauseAction, ETriggerEvent::Triggered, this, &AMazeRunner::PauseMazeGame);
Action Digital (bool) without modifiers with Pressed Triggers
If use first time method PauseMazeGame works fine. If pause/unpause game with code in hud class (binded to delegate)
void AMazeHUD::OnSetPause(bool Paused)
{
if (!GetWorld() || !GetWorld()->GetAuthGameMode()) return;
const auto Controller = GetOwningPlayerController();
Controller->SetPause(Paused);
if (Paused)
{
Controller->SetInputMode(FInputModeUIOnly());
Controller->SetShowMouseCursor(true);
PauseWidget->SetVisibility(ESlateVisibility::Visible);
HudWidget->SetVisibility(ESlateVisibility::Hidden);
}
else
{
Controller->SetInputMode(FInputModeGameOnly());
Controller->SetShowMouseCursor(false);
PauseWidget->SetVisibility(ESlateVisibility::Hidden);
HudWidget->SetVisibility(ESlateVisibility::Visible);
}
}
method PauseMazeGame not work (try log, empty in logs), just not execute
void AMazeRunner::PauseMazeGame()
{
if (const auto GameMode = Cast<AMazeFirstGameModeBase>(UGameplayStatics::GetGameMode(GetWorld())))
{
GameMode->SetPause.Broadcast(true);
}
}
Unpause from Widget class from UMG button clicked
void UMazePauseWidget::ResumeGame()
{
if (const auto GameMode = Cast<AMazeFirstGameModeBase>(GetWorld()->GetAuthGameMode()))
{
GameMode->SetPause.Broadcast(false);
}
}
I think what button for this event simple stuck on Triggered state. First press unfreeze button and second work normal. But other actions work fine.
That is, it turns out that after the game is unpaused, it can be paused again only by double-clicking on the button. What is the problem
How fixed this?