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"

Stuck Trying to Display a Variable to the Player's HUD / Widget

Hello Everyone,

I'm having trouble trying to get a variable to display on the Player's HUD. The Variable is an Integer that holds the value of "Time" remaining. Counting down, I am trying to display this variable to the player's HUD. The Timer is a placeable actor into the level, which allows me to change the "time" to complete each level.

What I'm trying to achieve: The timer counts down from 60 seconds, Displaying the time remaining to the player on their HUD. If the time hits "0", then a game over widget pops up.

I'm not primarily a programmer as a developer, So I'm getting stuck every now and again with BPs.

Any help would be greatly appreciated!

For clarification, If you look at the attached images: I'm trying to get the variable called "TestTimer1" to display to the Widget where the "999" is being presented. I am not primarily a programmer, So I'm not sure on how to make this work.

Product Version: UE 4.10
timerblueprint.jpg (142.9 kB)
timerwidget.jpg (260.8 kB)
more ▼

asked Jan 20 '16 at 12:59 PM in Blueprint Scripting

avatar image

41 18 24 28

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

1 answer: sort voted first

Hmm since you are not a programmer im going to try to explain it easier, since the time remaining is something that will be visible to the player, it could be inside the player character blueprint instead of stay on a random actor or on your level blueprint.

1 - So you can create the variable "timeremaining" inside your char blueprint, set its value to what you want.

2- Compile and save your blueprint

3- inside your widget, click on the text you want to show your counter and on details panel you will have the propriety "text" on right side you have a button "bind", click on that and create a bind function (give the name you want for that). This function basically will get a value from some place and put this value on your text.

4- Go to your event graph (still inside the widget), there you have the event construct, plug that to a "cast to (player)" - if you are using the default player on the third person example, it should be: cast to thirdpersoncharacter. It will have an object, this you will plug on a "get player character", then you can get that result and promote to a variable(im gonna call it "playerdata"). so you will have now the reference of your player character and can manipulate variables inside that for example.

5- back to the function you have created. There you will get the variable that you created to reference your player blueprint ("playerdata"), from that you will get the variable "timeremaining" and plug that to return node. You will notice it will automatically convert your integer value to a text value, its ok. Just compile and save.

6- On your level blueprint: event begin play - create widget(choose the one you created) - add to viewport, so now you will notice that the value that is on your timeremaining variable will be on your widget. To manipulate that you can use the tick event and decrement your variable, just remember its a variable inside the player, so you need to cast your player blueprint there too, to have access to that variable.

Here are some screenshots, if the text is too confuse to understand, hope it helps. The update thing could be made on your own widget or even inside player character.

alt text

alt text

alt text

alt text

timeremain.png (51.2 kB)
counter.png (88.5 kB)
gettime.png (94.3 kB)
updatecount.png (121.7 kB)
more ▼

answered Jan 20 '16 at 02:55 PM

avatar image

61 1 3 7

avatar image MikeyBGames Jan 20 '16 at 07:40 PM

@iorek01 Thank you for such a detailed response! This is quite different, I'm just wondering how the "Game Over" state fits into it. When and If the timer hits "0", It's supposed to be game over. :)

Would a "compare int" fit in just the same after the "set timeremaining". Also, just for clarification, does the timer logic actually have to be kept within the Level Blueprint?

Perhaps a timer function could work entirely within the character blueprint?

avatar image iorek01 Jan 20 '16 at 08:58 PM

yes you are right, you can have a "compare int" right after the "set time remaining"and make the game over there. Yes, the timer logic can stay inside the character blueprint, it will work.

avatar image MikeyBGames Jan 20 '16 at 09:18 PM

Thank you so much for your help. It's saved me some serious headaching. :D Is there any way I can contact you if I run into issues? Twitter or something?

avatar image iorek01 Jan 20 '16 at 09:25 PM

you can send me a private msg on unreal forum, so i will be able to answer you as soon as i check it =) i dont have twitter =s

avatar image MikeyBGames Jan 20 '16 at 09:39 PM

Fair enough, I should really be more active on the Forums anyway. :)

(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