How to assign game time to a variable and use that variable in another widget?

Hi this is my first post so please go easy on me!

I’m basically developing my first game on Unreal Engine 4 which is a 2D side scroller.

I want to assign the game time to a variable and use that variable in a widget which will appear when the game ends. I will then use that variable to show the user if they have achieved a gold silver or bronze medal depending on the time they finish the level in.

The best i managed to do, was print the game time to the screen as a string but i would like to assign this to a variable and use it in other blueprints for my game.

Can anyone give me advice on how i could approach this or link me to a guide that could help me attempt this?

Many thanks,


There is blueprint node “game time seconds”, use this one, as it counts for pause and slow motion changes.

At “event begin play” of player pawn store value of game seconds in variable. Lets name that variable “game start seconds”

Now create your widget: place border widget, and inside it place text. Border has some extra functionality for widget layouts, so get into habit of using it as parent.

Next is binding (creating function that changes text) for your text widget. Select text, and there (in details list) should be small box that you can type what is displayed, next to it is bind button. After you bind it creates new function called something like: “get_text_somewidget”.

in umg widget function of get_text_something get reference to player pawn, then cast to it (and its class), read that “game start seconds” and substract from current game time in seconds, display difference (feed that value to return node). Now extra tip: TEXT type has very nice “Format text” node use it, then float (your seconds value) has very nice conversion node to TEXT (expand it there is easy way to make constant length for return text, and constant decimal place).

Also watch umg tutorials
And blueprint communication ones.

Thank you for the fast reply, i will try this when i am back at my computer and i’ll try this out :slight_smile: