Location for code like pausing the game

Hi,

I want to implement pausing my game via c++ code. Just where would I want to do that? I can’t imagine doing that in my player pawn is a good idea, right? Is there a good place in the code for this?

Pausing the game is handled by the “UGameplayStatics” module.

So, you can essentially trigger it from most anywhere you like. Essentially, whatever is handling your input is where you want to place it. For example, you can have a keypress that is handled by either your PlayerController class, or your Pawn/Character class.

Once you’ve handled your input… You can pause/unpause the game via c++ with the following code:

// Pauses Game
UGameplayStatics::SetGamePaused(true);

// Unpauses Game
UgameplayStatics::SetGamePaused(false);

There are some youtube videos you can watch with a quick google search. They show you in blueprints, but the logic is really no different.