x

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"

Problems with UMG countdown

Hi all,

I'm creating a simple umg countdown widget, but it doesn't seem to work. Herem take a look:

alt text

^The blueprint of my Pawn (BP_6DOF_Pawn), later referenced in the graph of the widget:

alt text

The BP_6DOF_Pawn_C is a variable type object reference. And here's the uneventful unlit preview window:

alt text

I appreciate all the help.

Cheers, Mike

Product Version: Not Selected
Tags:
countdown.png (142.0 kB)
countdown2.png (59.4 kB)
more ▼

asked Apr 20 '15 at 03:42 PM in Blueprint Scripting

avatar image

SupMike
8 2 5 6

avatar image Narghile Apr 20 '15 at 04:02 PM

Where are you casting to get BP 600F?

You said later?

Narg

avatar image SupMike Apr 20 '15 at 04:06 PM

I figured I could do without casting (I know very little about it). Guess not. I used the variable BP_6DOF_Pawn_C (a reference to my BP_6DOF_Pawn blueprint class) instead of casting.

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

2 answers: sort voted first

Doing a Delay in an Event Tick doesn't seem right to me.

The "right" way to do countdowns, is to determine a time at which the countdown is done. For example, on Event Begin Play, you might want to get current game time in seconds, and set the "target time" to that value + 3 seconds.

Then, inside Event Tick, you get the current game time in seconds, and subtract that from the target time. If the value is zero or less, you are "past" the time. If the value is greater than zero, you have that much time left. To display it, you probably want to round it using "ceiling" and truncate to an integer.

alt text

more ▼

answered Apr 20 '15 at 04:44 PM

avatar image

jwatte
1.3k 48 42 88

avatar image jwatte Apr 20 '15 at 05:41 PM

Also: you'll want the "false" output of that branch, not the "true" output. Slight bug :-) If this answers your question, please check the "accepted answer" checkbox.

avatar image SupMike Apr 20 '15 at 05:46 PM

Whoa, thanks for the lighting quick reply!! I'll see into the issue in a couple of hours, and hopefully will check the checkbox ;)

avatar image SupMike Apr 21 '15 at 11:31 AM

Thanks a lot jwatte, your method works great (the time is checked multiple times in every frame, solving the issue of time going "too fast" in relation to the game during performance drops), but I still need to relay that information to the umg countdown I created. Can I get some help with that?

avatar image Narghile Apr 21 '15 at 12:45 PM

Casting is really easy

I do it a little old school. Get all all actors of class, get, cast to that actor, promote to variable.

Get that variable and plug it in.

Will do something soon

Narg

avatar image jwatte Apr 22 '15 at 03:54 AM

Isn't that a second question?

Anyway, the way to poke things at the UI is to:

  • open up the UMG asset

  • click on the Graph button in the top-right corner of the UMG editor

  • add a function called "set countdown"

  • give that function an input that is the value

  • in that function, forward the input value to the set text function of the text item in question

  • in your game Event Tick (that calculates the timeout) you can then call the Set Countdown function on the UMG widget

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

Simple Example

In Event graph of widget

alt text

Binding here to text box

alt text

Narg

capture.jpg (24.1 kB)
capture.jpg (34.7 kB)
more ▼

answered Apr 21 '15 at 12:52 PM

avatar image

Narghile
1.7k 74 38 110

avatar image SupMike Apr 21 '15 at 01:12 PM

Thanks, this is beyond awesome!!

avatar image SupMike Apr 21 '15 at 01:14 PM

Buuuuttt... now the variable doesn't update and its' stuck on 240 (the amount of seconds I have choosen for the completion of the "game")

avatar image jwatte Apr 22 '15 at 03:56 AM

I don't like that solution because it ties the blueprint and the widget tight together. Look at my answer above...

(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