2 timers, allow 1 to run while game is paused?

Hey all, need a bit of guidance figuring out how to approach this.

When my game loads I have a Set Game Paused (true) in my GameMode. After that, I load a MainMenu widget.
I also have a Countdown Timer here (that ends the game when it runs out), that I only want to run when the game is unpaused:

In my GameState, I have a Set Timer By Function Name, that I would like to be able to run, After the MainMenu is closed and when the HUD (widget) EventConstruct kicks in.

This is where I would like for it to kick in, before the game is unpaused:

Basically, close the MainMenu, put the HUD up, let the user see the level while paused, have a 3,2,1, Go counter and unpause the game and let the user play, (and have the game mode timer starting). How can this be achieved?

As always, any tips are greatly appreciated

Hey @cnapsys!

I think these might be the nodes you’re looking for! You might need that timer to be set by handle instead of function though.

@Mind-Br thank you for taking the time to answer.
If I do that… I assume I can pause the main timer and unpause it when I want to, but that means the game would have to be unpaused while the widgets are up, correct? This means that my player can use his/her action inputs, which I don’t want them to. Is there a way to not give them access to their controls until the 3,2,1, Go timer is finished?

Absolutely! On begin play, probably on your GameMode or Level BP, use “GetPlayerController” into “DisablePlayerInput”, then as you start the timer, wherever it is you’re starting that use “GetPlayerController” into “EnablePlayerInput” :slight_smile:

Edit: Phrasing for readability

@Mind-Brain oh my… could it be that easy??? :slight_smile: tryin’ it right now

@Mind-Brain Hmmmm, I do not have a DisablePlayerInput only DisableInput (Target Actor), If I use that it disables all input, for widgets too, so the player can’t click on the menu buttons). Sigh… I’m losing my mind

Ah I didn’t realize you’d be working with a widget while it was waiting to start.

Use this then!

@Mind-Brain Ok, but do I use this while the game is still paused??? Or should I not set it to paused in my gamemode?

You should still be able to interact with widgets while paused, as far as I know. Unless you’re doing something I’ve never seen before. Pause just stops ticks typically unless it’s really in-depth. You should just be able to use that once right before the pause, and once right after the unpause to set it back to “Game”.

@Ok, so In my GameMode, I pause the game and set the Input Mode to Game Only, then I load the MainMenu.
On EventConstruct, I change the Set Input Mode to UI only like so…

When MainMenu loads, I have no Player Input and no mouse cursor???

wow, I need some sleep… forgot to connect that Set Input Mode to UI only :rofl:

But now, both timers are paused as soon as I hit Play :frowning:

Try this:

Open your project settings. Do a search for “viewport properties” and change the dropdown from “capture permanently” to “capture on mouse down”! Give that a shot and get back to us! :slight_smile:

Edit: Okay, I thought that was there on purpose when you were fiddling with it lol

I’m confused as to why you’re pausing the game before launch of the gameplay. There’s no reason you should have to do that? If you want a countdown, don’t allow the timer to start or the player to be allowed input until the countdown ends. But if you pause the game, that’s it, the entire time function has stopped. All timers will pause.

@Mind-Brain ok, here’s what I was trying to do… when the game loads, I’m loading a MainMenu, that has a loading screen and then a MainMenu with buttons. When You hit play, the menu closes and it loads the HUD, if I don’t pause the game both timers start right away while the menu is up for the user. My reasoning was to pause the game, and when the user hits play start a 3 second countdown and then start the 1 min timer for each level. if you can’t complete the level in 1 min the game ends.
How else, can I achieve this???

I.e. if I unpause the game before I load the HUD (widget) both timers start ticking simultaneously.

I think we can set that up with some minor alterations. Basically, just use Custom Events :stuck_out_tongue:
Have the widget GetGamemode, CastTo(name of yourGameMode), “StartTimerEvent”. Then once that timer completes, have it run other Custom Events, like “LevelTimer” and such. If you need more assistance, can you show your countdown timer?

@Mind-Brain

Here’s all I got so far:

GameMode:

GM Countdown Timer function:

GameState:

MainMenu, that is Loaded from GameMode after game is paused:

When clicking the PlayBtn inside the MainMenu: (Here, if I unpause the game, the timers both start ticking fine.)

The HUD which is loaded after the MainMenu is removed from Parent:

HUD continued custom event:

HUD tick for setting the timer variables from GM:

Ah. So there’s a few things I see.

I noticed your main menu is not a separate level. Typically it would be, but that’s fine, no biggie and no reason to change that. :slight_smile:

Have you tried moving the “Remove From Parent” to the end of that line? If I remember correctly that needs to be at the end of things done by that widget.

@Mind-Brain Oh, I’m using remove from parent there because I’m hiding the MainMenu on clicking Play… then I put another widget up called HUD, and that’s when I want the timers to kick in one after another.
At that point the game is ready to play… would like to give the player a heads-up countdown… 3,2,1, Go and then let him play :slight_smile:

Yes, I’m still learning… will probably end up putting the MainMenu in its own level… but for now, I’m just taking it all in and figuring things out…