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"

Why do these 2 widgets display the same variable on different actors?

alt text

As you can see both of these enemies have a health bar that displays a Health Variable.

But I haven't damaged the one in the distance but they still display the same health variable.

Despite it displaying both of them having the same health variable the value itself is different its just the widget displaying it isn't displaying each actors separate health value.

Any help is appreciated, thanks!

Product Version: UE 4.21
Tags:
error.png (532.3 kB)
more ▼

asked Mar 24 '19 at 07:36 PM in Blueprint Scripting

avatar image

Logz 123
1 1 2

avatar image Everynone Mar 24 '19 at 10:18 PM

Can you show / describe what creates the widgets and how the progress bar value is set?

Also, spooky.

avatar image Logz 123 Mar 24 '19 at 10:46 PM

alt text

The widget is created in blueprints

capture.png (635.9 kB)
capturee.png (111.4 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

Get All Actors Of Class returns same set of actors and you always getting one with index 0, which is the same actor. Insted of using Get All Actors Of Class, send health to the heal bar components directly to set value of the bar from the actor

more ▼

answered Mar 25 '19 at 12:04 AM

avatar image

Shadowriver
35.9k 928 169 1105

avatar image Logz 123 Mar 25 '19 at 12:27 AM

How would i do that 'Directly"?

avatar image Shadowriver Mar 25 '19 at 03:12 AM

Those widgets are on component right? so put code in actor that sets health bar, as you can access it via component

avatar image GarettHunter Mar 25 '19 at 04:57 AM

Assuming you are using the Widget Component https://docs.unrealengine.com/en-us/Engine/Components/Widget

Inside of the blueprint as Shadowriver is suggesting you can use this https://answers.unrealengine.com/questions/358690/cast-to-parent-actor-of-widget.html method to access your specific widget and set the percent bar value on the Event Tick. You could probably do the cast on Event Begin Play and store your user widget object to avoid casting it on each tick.

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

Yea, you are currently only grabbing the actor with the index 0. You'd need to get all actors of class and let a ForEachLoop do the rest. (although I would rather let the actor do the work, instead of the widget) alt text

more ▼

answered Mar 25 '19 at 01:24 AM

avatar image

Aphermion
156 3 5 6

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

Ok thanks everybody for their help

alt text

This made the UI start working the way i want it to alt text

alt text

I made a variable that gets the Blueprint for the character then sets the progress bar to the health /500 (because his default health is 500)

solution1.png (111.2 kB)
solution2.png (37.8 kB)
solution3.png (9.3 kB)
more ▼

answered Mar 25 '19 at 09:08 PM

avatar image

Logz 123
1 1 2

(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