The 'Get game time in seconds' node bypasses a branch node in a UMG widget

Hi. I’ve set up a forward counting stop watch by just getting the game time in seconds.
What I want to do is to start the stop watch when the game is started…so there is a started variable that is a boolean.

Initially I had a function bound to the text UI but I couldn’t get control over the widget to start when I wanted.

So I put the nodes in the event graph. But still the game time in seconds node seems to bypass the initial branch node when started is false. I don’t quite get why.



What do you mean, it bypass the first branch?

If it goes through the first branch, it’s because ‘‘Started’’ is true. (Check its default value on the right when you select it)

Or, if you meant that the GetGameTimeInSeconds still increment when your ‘‘Started’’ variable is false, this is normal.
The function returns the game time since the game started.
The only way you can decide when the timer starts is by starting a new game.
You will need to create your own timer

MyTimer += DeltaTime

Thanks @AlexQuevillon. “Started” is definitely false - i’ve printed it to the console and screen - and I understand that GetGameTimeInSeconds still increments - but despite “Started” being false the Text UI is still being set with the current game time.

But thanks for the tip re: MyTime += DeltaTime.

Also - re: starting a new game - in a 2D game I would have a main menu and start game button and then use the open level node.

But in the VR game i’ve created, the game opens on the first level - there’s no separate main menu screen - and the start game button is in front of the player but Event BeginPlay has already begun…so just wasn’t sure how to have a start game button in VR and start the game when the button is pressed given that Event BeginPlay has already executed.


Variables are read by nodes they are connected to. Those green lines are for you just to show which variable is read. For some nodes you can connect multiple variables to single input.
Store that game seconds in your own variable, and use that.

Instead of adding a counter, create a variable named “Time Started” and compute the “Time Since” that time when you need it. There’s no need to have a counter for time if you don’t need one, and as time goes on it’s more accurate.