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"

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][1] [1]: /storage/temp/246568-capture.png

Product Version: UE 4.18
Tags:
capture.png (134.1 kB)
more ▼

asked Jul 07 '18 at 09:47 PM in Blueprint Scripting

avatar image

Micke879
10 5 5 7

avatar image ZazarLaLiche Jul 08 '18 at 09:43 AM

How are you handling the fact that a player is approaching the backpack ? Are you using an overlap event ?

avatar image Micke879 Jul 08 '18 at 09:57 AM

Yep, a begin overlap event inside the backpack actor blueprint. I've tried doing a bool variable to say "IsNear?", and when this is true, it fired off an event to the Char BP to start the timeline that increases the progress bar value.

avatar image ZazarLaLiche Jul 08 '18 at 10:00 AM

Ok so, what is exactly your problem here ? Are all your backpack's progressbar filling up or do you want the bar to only be seen by the player picking it up ?

I got something working on my end but everybody can see the bag's bar filling up, is that what you want to avoid ?

avatar image Micke879 Jul 08 '18 at 10:07 AM

Problem is that when I have two or more backpacks sharing the same Widget BP, all the backpacks in the level will be updating their progress bar when I approach any one backpack. I have no idea how to keep them on separate timers while having a widget component in the backpack BP.

avatar image ZazarLaLiche Jul 08 '18 at 10:09 AM

Ok, in my project, only the backpack that is being picked up is showing the bar updating, I'll post an answer with screenshots so you can see if that's what you want =)

avatar image GarnerP57 Jul 08 '18 at 10:16 AM

I always makes Widgets as ignorant as possible. I would place the timer on the backpack and have it update the widget as needed. This would also prevent you from having the widget send an event back to the backpack when the timer is done.

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

1 answer: sort voted first

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

alt text

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.

alt text

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.

alt text

That's probably not the best system but I guess it's a start :)

alt text

overlap.png (133.9 kB)
updatebar.png (164.2 kB)
leaveoverlap.png (110.1 kB)
more ▼

answered Jul 08 '18 at 10:19 AM

avatar image

ZazarLaLiche
213 2 3 5

avatar image Micke879 Jul 08 '18 at 10:29 AM

Pretty clever solution, got it to work!!

avatar image ZazarLaLiche Jul 08 '18 at 10:30 AM

Nice to hear =) I never did something like that before so it was also useful for me, good question ;)

Good luck for your projects!

avatar image Micke879 Jul 08 '18 at 11:11 AM

Question though: the set progress percent function, how does that look for you?

avatar image ZazarLaLiche Jul 08 '18 at 11:20 AM

I just query the widget of my widget component, cast it to my desired widget class and then set the percent of the bar to what was calculated before CurrentProgress/TimeToPickup. Be sure to check the "Is Variable" checkbox on your progress bar in the widget blueprint or you will not be able to call it from your blueprint.

alt text

(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