Widget component for actor sharing state
I have X amount of backpacks in my level and have a system in place where each backpack is a blueprint actor with a widget component in it, linked to a widget class that's responsible for a radial progress bar.
The idea is that a player, client or server, approaches a random backpack and starts to pick it up, but the problem is that all the other backpacks in the level also display the same widget component and begin filling up their progress bars for the acting player. They all share this widget blueprint and so all have the same state.
How do I make this progress bar unique for every backpack?
Backpack WB that the widget component in the backpack actor uses: ![alt text] : /storage/temp/246568-capture.png
I got it somewhat working, enough for you to adapt it to your project I think. I created the backpack blueprint with just a mesh, a widget component and a box collision to detect any overlap. The widget class I use just contains a progress bar with "is variable" checked.
On overlap, I check if the overlapping actor is a character, if it is, I start a timer firing an event to update the progress bar every 0.1sec (you did that using tick function but I prefer this way so that I'm not calling it when nothing is happening).
Every 0.1sec, I update the progress variable and set the bar percent accordingly, if CurrentProgress/TimeToPickup = 1, we got the backpack, I destroy the actor.
If an actor is leaving the overlap, I check if that's the actor that was picking it up and if that's the case, reset any useful variable.
That's probably not the best system but I guess it's a start :)
answered Jul 08 '18 at 10:19 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here