Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How do I display the value of a timer variable on a widget?

I'm making a simple racing game, and i'm very new to Unreal.

Firstly, how would I pause a timer (thats counting up in integers) on the event of overlapping a trigger box.

Secondly, how would I then display the current integer being shown in a text box on a widget?

Product Version: UE 4.16
more ▼

asked Apr 16 '18 at 03:13 AM in Blueprint Scripting

avatar image

3 2 7

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I think for your first problem, you want to look into 'cast to' Second in the Widget BP create a text somewhere and bind it to the timer variable. You can learn more about both in various tutorials and projects on the marketplace.

more ▼

answered Apr 19 '18 at 03:10 PM

avatar image

366 3 2 12

avatar image Ed_S Apr 23 '18 at 10:00 PM

I've found an example of a binding someone else has made, linked below,, the problem is I don't know how to get the node where there is a target socket on the left and the variable name next to a socket on the right.

Someone else's example: https://answers.unrealengine.com/questions/231429/how-to-bind-a-variable-with-a-text-box-in-widget-b.html

avatar image Nebula Games Inc Apr 23 '18 at 10:28 PM

@Ed_S this is the same issue you were having on this thread...I was helping you there. If something wasn't clear you should have said so, I made new screen shots for you that walk through the whole process. Yes you can also create a binding it is more straightforward. Just click on your text box and select "create binding", then bind it to whatever variable you wish. You will need to reference that variable somehow within the binding itself though.

Here is the other post


alt text

alt text

avatar image Ed_S Apr 23 '18 at 11:13 PM

Sorry if i'm being unnecessarily difficult, I don't mean to be, but like I said I just need a way to get that node with the 'target' and 'variable' (integer) sockets. You said I need to reference the variable somehow but I don't know how, I know I can't just copy and paste it because the blueprint "doesn't know the references property". The variable for the counter I have is just called Time Counter and I made it in the level blueprint (not as a local variable).

Also I don't recall creating this thread so i'm not sure why there are two questions by me that are only worded slightly differently.

avatar image Nebula Games Inc Apr 23 '18 at 11:20 PM

Haha that's funny/odd! But to answer your question, it is very difficult to get variables from the "level" blueprint as you can't "cast to" it. If you wanted to have the timer in the level blueprint then you would need a method more like what I outlined in the other thread. You would need to "cast to" the blueprint that created the widget. If you create both in the level blueprint then you are good. Just take the reference from the "widget" you create in the level and pull the text variable out of it and update it to equal "Time Counter"

avatar image Nebula Games Inc Apr 24 '18 at 12:14 AM

Here you go man enjoy!


avatar image Ed_S Apr 24 '18 at 10:40 PM

Really helpful tutorial, just one thing, my timer won't stop when overlapping my finish line trigger box. I followed the video closely, can you see anything wrong?alt text

avatar image Nebula Games Inc Apr 25 '18 at 12:56 AM

Print a string from the false and one from the true off the branch and see if that's the problem. Then check and see if the player ref is the same as the character you're playing with. Make sure that cast and variable are the same as the player character crossing the finish line.

avatar image Ed_S Apr 29 '18 at 09:44 PM

Sorry for such a slow reply; doing other assignments. Thanks for the help. One last thing, how could I make it so crossing the start line (after stopping the timer with the finish line) the timer is reset and starts again at 0. I've tried to do it myself but the new timer appears over the current one making it unreadable.

avatar image Nebula Games Inc Apr 29 '18 at 10:28 PM

That sounds like you are “creating” a timer widget each time you start a race or something. I always create widgets once and toggle the visibility for exact issues like this. You should only ever have one timer widget. So you should create it in the player or level blueprint and then it is easy to modify. So on overlap of the start position set timer to 0 and you should be good. Don’t create a new widget.

avatar image Nebula Games Inc Apr 29 '18 at 10:31 PM

Did you ever get the timer to stop? I assume yes since you aren’t asking how to do that anymore haha

avatar image Ed_S May 18 '18 at 10:45 PM

Yeah, I got it to stop. I've tried using the "Set New Time" socket on the stopwatch but that doesn't help. And I have it so when I cross the start line again (when I want the timer to be set back to 0) the timer just carries on from where it stopped (when hitting the finish line). What easier way is there of simply setting it to 0?

P.S. I have the stopwatch in the level blueprint.

avatar image Nebula Games Inc May 18 '18 at 10:53 PM

Nope! That's a completely unrelated pin. You want to set the "time integer" we created back to 0. That will reset the race timer. So whatever you are doing with the "time" after we stop the counter so say the player took 15 seconds to cross the finish line. Obviously you want to use that number for something hence why we displayed it to the screen initially. But once you are done doing whatever and you want the timer to go back to 0, whenever that point is before you start a new race, "Set Time" (the integer variable we created) to 0 and you are good to go. Run the stop watch again it should count up from 0 now.

avatar image Ed_S May 24 '18 at 08:30 AM

I've got it all sorted now, sorry for the hassle thanks a lot for the help.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question