Change the UI counter when one second passes.

Good afternoon.

I’m a newbie in Unreal programming.

My doubt is, how can I change the text of my UI, with a looped counter that passes a second, can I change this change in the graphic of the UI itself?

My idea is to make an interaction with the interface that every second goes adding in some counters, Clash of Clans style, whether food, wood, etc… Depending on the level you have the mines, it will be multiplied by a higher number.

This project idea, I don’t know if you see it better in a GameManager, which is how I used to do it in Unity, the more advice I get from you on how to make it more fluid without consuming resources, the better.

Tabmien if you can give me some advice on how to control more Unreal, I am also welcome to receive it, I’m doing a course and I’m practicing, but when it comes to practice, I find it hard to realize the different ideas I have in mind. Before I programmed in Unity, if it helps you.

Best regards.

You can set a timer node to loop every 1 second.
Where you do this depends more specifically on what you want to do.

You could also use a delay.

1 Like

Hey @BaBuuuuuu! Welcome to the Forums!

To expand a bit more on what @Astaraa explained, you can find more information on timers here:

As for delays, you can create a timer using a delay with your set time (duration is in seconds) and update your blueprint/widget with your current time value. Here is an example using a simple killstreak combo countdown that subtracts 1 second from the countdown timer every second:

I hope the above is the answer you need!

Good afternoon.

Thank you very much for your replies. Sorry for not replying sooner, I have been working.

I have checked the forum, I understand the concepts of each module, what it is used for, etc. But my main problem is that I don’t know how to relate it or how to structure it. Here are my doubts.

1 - If you want to make a game that its gameplay is based on a graphical interface, that also goes with resources. Would you do that generic programming the game in a BP of the UI? or, Is it better to make a BP of an actor where you make reference to the BP of the UI and work everything in the BP of the actor as a GameManager. I know that Unreal has a BP that is GameManager, maybe the best way is like that or directly all the code in the same UI, but I’ve noticed that it has more limitations of operations on the nodes than a normal BP.

2- How can I make that a text in the UI is changed by a counter? I understand the Delay nodes, but I don’t understand how to link it to the UI Text so that it changes every second and the references. Also instead of a Delay I would use a Timer, maybe you have told me about the Delay because it doesn’t consume a lot of resources.

Thank you very much for your answer and I wait patiently for your answer.

Best regards.

Hey @BaBuuuuuu,

I think what you are needing at the moment is more information and foundation in blueprint / widget communication and Game instances rather than the timer itself, as that is the easier part. After that you can implement whichever of the above methods works best for your use case.

Check out these non-Epic affiliated tutorials that will teach you the main concepts of blueprint communication through making a health bar and going over a mini health system using a game instance.

Good luck on creating your counter!

Depends on the complexity of the task. You choose the right tool for the job. If you have a vague job description, you’ll get what may seem like a vague answer:

If you need a complex object full of components that do all kinds of stuff, responsible for driving logic, referencing assets and need timelines, you will want a dedicated actor that displays the results of those tasks in a UI element it creates. You could feed the UI some data and have it format it appropriately for display - make the data pretty. But in most cases I would not give the UI widget the job of obtaining such data. Although it can work, too. In short: it depends.

That’s a lot of ifs because we do know what you actually need. Impossible to give you a straight answer.

A manager actors tends to get very busy, and the UI does not need to know about the internal shenanigans. The role of the UI it to show stuff that’s pertinent and take input from the player.

I know that Unreal has a BP that is GameManager

Do you mean the Game Mode?

How can I make that a text in the UI is changed by a counter? I understand the Delay nodes, but I don’t understand how to link it to the UI Text so that it changes every second and the references.

For something that simple, I would not create an underlying actor, and there’d be no need to reference anything:

  • in the widget:

This would update a text block once per seconds and show an ever increasing counter. 1, 2, 3…

Also instead of a Delay I would use a Timer, maybe you have told me about the Delay because it doesn’t consume a lot of resources.

I believe you worry about the wrong thing. I’d focus on getting the functionality going first. Then you can run that functionality by creating 1 million widgets and see whether using a Timer or Delay is faster.

You’ll find out that you cannot have 1 million widgets so the test makes no sense whatsoever anyway. I am simplifying a bit but it’s a thing.

The Delay node is quite Dumb, as in - it cannot do much, fire & forget. A Timer, on the other hand, can do a lot of useful stuff:

If you need this functionality, use a Timer. It’s not a matter of handling resources. What’s the point of running a cheap Delay if it does not do what you want.

Choose the right tool for the job.

1 Like

Greetings again.

Thanks for the input!

I may have to focus on getting the game up and running and then refine it.

I have tried to put your code but the reference to my TextBlock, tells me that it is null. I have marked in red what I think it is.

I’m sending you a screenshot in case you know what’s going on.

Thank you very much.

You’ve decided to do it in the actor instead. See how the screenshot I posted reads Widget Blueprint?

If you want to script it in the actor, you’ll need to communicate, make the actor and the widget talk to each other. Create a reference to said widget first - right click the Return Value pin and Promote to Variable

Use that reference to fetch the text block that lives inside the widget. Or, better, fire a Custom Event in the widget and let it format the text.


If you ever manually add variables, you must assign them data.

  • add a string, type in a message
  • add an integer, punch in some numbers
  • add a text block reference, tell the editor which one you mean
  • reference an entire other blueprint actor, explicitely point to a specific instance as there can be thousands…

Good afternoon.

I have tried to do what you tell me but it doesn’t work, could you give me the two examples to see the difference if you don’t mind.

Thank you very much for the constant help.