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:

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

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


I appreciate all the help.

Cheers,
Mike

Where are you casting to get BP 600F?

You said later?

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.

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

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

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

Also: you’ll want the “false” output of that branch, not the “true” output. Slight bug :slight_smile: If this answers your question, please check the “accepted answer” checkbox.

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

Thanks a lot jwatte, your method works great (the is checked multiple times in every frame, solving the issue of 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?

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

Simple Example

In Event graph of widget

Binding here to text box

39559-capture.jpg

Thanks, this is beyond awesome!!

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”)

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

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