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.
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?
@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”
@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
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”.
@anonymous_user_31f0540d1, 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…
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!
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 think we can set that up with some minor alterations. Basically, just use Custom Events
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?
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.
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
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…