Unreal Engine: How to track of Play Time (Get Game Time)

Are you interested in learning how to keep track of the game playtime in Unreal Engine 5?

Luckily, Unreal Engine provides a simple way to achieve this by using the “Get Game Time in Seconds” Blueprint node.

In this blog article, we’ll look as how you can use this node to track the amount of time spent playing your game and show it in the format 00:00:00.

So let’s get started!

How to Get Game Time in Unreal Engine?

To start monitoring your game’s playtime, open the Blueprint where you wish to enter the code.

This code can be used for testing during game development, but also in Widget Blueprints if you want to display total playtime in the game user interface.

It is especially useful for games that encourage speed runs because it allows players to keep track of how long it takes to finish the game.

1. Get Game Time in Seconds

In the Blueprint, search for ‘Get Game Time in Seconds‘ in the search bar and add it to your Event Graph.

The ‘Get Game Time in Seconds‘ node returns the playtime in seconds, which is useful but not the format we want.

To clearly display the playtime in hours, minutes, and seconds, we must format it.

2. From Seconds (Blueprint Math Node)

In order to achieve this, connect the ‘Get Game Time in Seconds‘ node’s output to a ‘From Seconds‘ blueprint node.

This allows you to display the playtime in the desired format of hours, minutes, and seconds.

To do it, just right click in the ‘From Seconds’ output pin and select ‘Split Struct Pin‘.

Get Game Time in Seconds Unreal Engine

3. Convert Integer value to Text

Next, use a “To Text (Integer)” node to convert the Integer value to Text.

If you’re unsure about the difference between an integer and a text value, please read our lesson about Variables and Data Types first.

The “Minimum Integral Digits” value should be set to “2” if you want to display two digits.

Finally, you can use the “Format Text” node to show the formatted playtime in hours, minutes, and seconds. Just use this Format:

{h}:{m}:{s}

Finally connect the return value nodes like in the screenshot below.

Get Game Time in Unreal Engine

Result: Play Time in Unreal Engine

If you want to display the playtime on the screen, you have a couple of options.

First, you can use a “Print Text” node to display the playtime directly on the screen.

Alternatively, you can bind the formatted text to a text variable in a Widget Blueprint.

The Widget Blueprint allows you to display the playtime in a more dynamic and customizable way, making it easier for players to keep track of their progress in the game.

In conclusion, by following the steps outlined in this post, you can track and display the playtime of your game in the format of hours, minutes, and seconds.

With this method, you will achieve the same play time format used in the Resident Evil 3 UI.

Source: Game UI Database

Hope This Helps! Keep On Creating!