C++ Unpause

Question about unpause in C++

I have an action bind for pause/unpause in my character class that calls

UGameplayStatics::SetGamePaused(GetWorld(), !UGameplayStatics::IsGamePaused(GetWorld()));

in my player controller SetTickableWhenPaused(true);

in my player controller tick

if (IsPaused()) TickPlayerInput(DeltaTime, IsPaused());

it ticks once, and that’s it

it pauses the game fine, but cannot unpause

thanks!

Can you provide more context for those lines? Is there more to your PC tick function?

Can you show the function that processes Pause and UnPause input?

What does TickPlayerInput do?

Are you sure it’s not ticking? Could it be ticking, but not unpausing?

Is your action binding actually getting called when the game is paused? (add a breakpoint or stick in a UE_LOG to check).

If it’s not then try binding using something like this instead (replace method names and InputComponent as needed)

FInputActionBinding menuBack = FInputActionBinding(FName("MenuBack"), IE_Released);
menuBack.bExecuteWhenPaused = true;
menuBack.ActionDelegate.BindDelegate(this, FName("MenuBackPressed"));

InputComponent->AddActionBinding(menuBack);

You could also write this as something like:

 InputComponent->BindAction("MenuBack", IE_Pressed, this, &ThisClass::MenuBackPressed).bExecuteWhenPaused = true;

(Code written from memory, may not be completely correct).

Note the bExecuteWhenPaused flag being set to true.

1 Like