Simplified Time Based Progress Bar

Hi there.

I am making a little VR minigame. I wish to have a loading bar that lasts 10 Seconds.

My current solution is a custom event that adds 0.1 to a progress variable and then delays for a second (repeated 10 times)

I am fully aware that this is not the best way to do it.

Please can someone much smarter than me explain a better solution?

TIA!




lol yes that is not the best way to do. What you’re looking for is called a for loop. :upside_down_face:

Hey there @ellis_rb! You could just use a Timeline set to 10 seconds! It even lets you stop, reverse, play from start, etc! Happy cooking Walter!

image

Hi Pete,

Thanks for your reply!

I tried using a for loop, however they don’t work with adding a delay!

Hiya!

Thanks for your reply, do you know how I would implement this into the Blueprint? It doesn’t allow me to add a timeline into the Widget Blue print directly :grinning:

Ahhh all of your logic is in the UI. That’s where the hitch is! So generally UI elements are intended to be an “Observer” for gameplay elements. So for example, your Meth screen should be just taking information from the Meth Machine object, not so much handling all of it’s logic. So add the timeline inside the workings of the Meth machine itself, and just have the UI bind to that data. It’ll save you many headaches in the future!

If you need it to work in steps, use a timer:

This will count and update from 0 to 100% every 1.0 second over 10s and then stop; and can be restarted with the same Custom Event. Timers can be (un)paused, too, if needed.


Should you need an animated (a silky-smooth update every frame) progress bar, there are many solutions. While widgets cannot have Timelines themselves, you can:

  • have an underlying actor push the timeline’s track values into a widget
  • use a widget animation with a repeater
  • sample timer’s elapsed time
  • update variable on Tick and bind property to the progress bar
  • make the animation in material instead
  • use some other, more esoteric way…

Do tell if you need an example of any of the above.

Hiya,

Yes, all my Logic is in the UI, It was the only way I could imagine getting it to work lol.

How would I send the variable info from my meth machine object to the UI?

Sorry, I’m new to Blueprints :slight_smile:

Thank you for your reply!

I am confused by the two events, I want the progress bar to start working when a boolean is set to True. Would I have to execute both of those events? Or just start timer?

TIA

I am confused by the two events[…]

Starting the timer is enough. The timer executes the Add Progress custom event every Time seconds. Bar rep-notifies one can’t have something happen when variable states change. I mean you could:

image

But that’s not what you want, surely. Start the timer when you change the variable or start the timer instead, or both:

Above, starting the timer changes the variable. Some other blueprint can call that event when you start making meth :eyes:

How would I send the variable info from my meth machine object to the UI?

That would depend on the architecture of your script / game / project - of which we know nothing. It’s impossible to advise anything tangible - there are simply too many ways of doing it. You generally choose a tool / method for the communication job.

For example: assuming there is a methylamine making machine actor displaying its own progress with a widget progress bar, that actor could:

The same way you could have a timeline here, in the actor, and send its data to the widget.

1 Like

Wow, thank you.

That’s really helpful, thank you for taking the time out of your day to help.

I’m sure I can get something working with the advice from you and others.

Many thanks!

1 Like

Hiya.

Back again.

I understand the logic and I almost have it working, however, I am running into a strange issue.

My widget is going to be placed on an asset (not viewport), so I have it in a BP, here’s a quick example (Imagine it is a screen on a methcooker!) :

The Blueprints update the bar when I change it to “Event construct”, but it doesn’t when I use a custom event. It adds up correctly with the custom event (i tested with print string), however, the bar doesn’t update.


Is there some sort of initialising I need to do?

Thanks again :slight_smile: :grinning:

Now that we know a bit more more and see we’re dealing with a widget component instead, we do not need this:

Remove it, otherwise we’d create yet another widget. A widget component on the actor already creates and maintains a widget so all we need to do is to get to that widget and start its event:

What’s more, you could right click a pin and promote the result of the cast, and then use the created reference to interact with the widget without casting later on.

image

1 Like

Genius, thanks again!

1 Like