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

Like this?

Still getting:

Infinite loop detected. Blueprint: BP_MyGameMode Function: Countdown Timer Call Stack: Show"

Oh wait this one is from GM

Log:
“LogScript: Warning: Infinite script recursion (120 calls) detected - see log for stack trace
BP_MyGameMode_C /Game/Maps/UEDPIE_0_MainLvl.MainLvl:PersistentLevel.BP_MyGameMode_C_0
Function /Game/Blueprints/BP_MyGameMode.BP_MyGameMode_C:CountdownTimer:0000
PIE: Error: Infinite loop detected. Blueprint: BP_MyGameMode Function: Countdown Timer Call Stack: Show”

Yeah, like I said earlier it has to be pulled off of tick. Just do this, honestly:

This bad boy:

I guess we are no longer changing that bool in GameState???

You’re losing me :slight_smile:

where should this be???

BPGameMode, ignore the mygamestate thing. We have ours switched.

You need to do this instead of the “On Tick” you had.

The “Your Time Left Variable” should be whatever time you have on your countdown timer, so it knows to stop the loop.

sigh, I had 2 variables… minutes and seconds. Cause I needed them separate to update the text boxes in the hud

No worries! Just use an “OR” node and another Greater-than check :slight_smile:

image
But I have to hit the hay, I’ll check back on this thread tomorrow. Next is player lock/unlock! You might be able to figure it out yourself, though. You need to “set input to UI and Game” then “Disable Player Input” on PlayerController when the main Menu is created. On the “GoGoGo FALSE LINE”, “Enable Player Input” on the player controller. Hopefully I come back tomorrow and everything’s peachy!

Much appreciated man. I’ll see what I can do and will report back tomorrow. Thanks a lot. Have a good nite

1 Like

Just tried it…still getting infinte loop :frowning:

  • Server logged in
  • Play in editor total start time 0.249 seconds.
  • Infinite loop detected. Blueprint: BP_MyGameMode Function: Countdown Timer Call Stack: Show

Log:
“LogScript: Warning: Infinite script recursion (120 calls) detected - see log for stack trace
BP_MyGameMode_C /Game/Maps/UEDPIE_0_MainLvl.MainLvl:PersistentLevel.BP_MyGameMode_C_0
Function /Game/Blueprints/BP_MyGameMode.BP_MyGameMode_C:CountdownTimer:0000
PIE: Error: Infinite loop detected. Blueprint: BP_MyGameMode Function: Countdown Timer Call Stack: Show”

@Mind-Brain

In my MainMenu EventConstruct, I already have it set to UI only. Should I change it to Game and UI??? Sadly, I can’t test anything anymore because of the infinite loop

Here, a few changes you need to make :slight_smile:

And yes, change it to game and UI, not UI only. And IMMEDIATELY after, “Disable Player input”. Enable Player Input on the GoGoGo False line :slight_smile:

Ok, so I have it like this in the HUD now:

This in GameMode:

And this in GameState:

Error:
“Infinite loop detected. Blueprint: BP_MyGameMode Function: MyLevelTimer Call Stack: Show” :frowning:

You don’t need this node anymore, just the enable input and Set Focus is fine.

Try adding a “Do Once” node. Here:

If that doesn’t work, add one here:

Adding a DoOnce should for sure block the loop. If that doesn’t work I have one more trick.

Adding a DoOnce oin the GameState BP fixed the infinite loop.

However, here are the rest of the issues now…
Because I added the Set Input Game and UI In the EventConstruct of MainMenu it seems to completely ignore Set Show Mouse Cursor (true). A bit of an issue for pc, but I guess ok for consoles, mobile, etc…???
Another issue, Enable Input seems to enable muse clicking for the user in game but the rotation of the pawn is still locked :frowning:
The biggest issues is… When I hit Play in the MainMenu, the 3,2,1 counter is already finished, set at 0 and never hides (stays there forever) and the MyLevelTimer is already ticking at 00:54 seconds

Any suggestions?

@Mind-Brain

Ok, I know you’re not gonna like it, but I found a hacky solution to all this :slight_smile:

I reverted back to Pausing the game.
Instead of having 2 timers, I only kept the LevelTimer.
For the 3,2,1,Go… I created an animation in the widget, that lasts exactly 4sec. → after the animation is complete, I call an event "Animation Finished(Widget Animation) and Unpause the game.
I know it’s hacky af… but it works. This way if the user pauses the game at any time (for a pauseMenu, Settings, etc etc…) the LevelTimer gets instantly paused as well.
I know it’s probably not the best approach, but it works great for what I had in mind initially. Not to mention… no more custom timers, dispatches, delegates and all the complicated stuff.

Let me know what you think, or if you see any issues with this or a better/simpler way

Listen @cnapsys. You learn the way you can!

Half of programming is getting it to work AT ALL. Worry about fixing things and making it neater once you get a good understanding of things. I’m proud of you for your “Hacky Solution”! One day you might look back and say “I can’t believe I did that” (I still say that and will say that next year about this year). But the thing is you won’t reach that point if you don’t power through! :slight_smile: Good job, and keep going!

@Mind-Brain

Your help is greatly appreciated good sir. I know it’s hacky, and I’m sure eventually I’ll figure out a better solution for my future developments. For now… in all honesty, I feel bad for wasting your time with my silly project already. Nonetheless, I learned a lot from your points and I commend your patience in guiding me step by step.
You sir, are a rock star :metal:

1 Like