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
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!
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.
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?
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:
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
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 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.
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.