Error With UMG ProgressBar Values From Array and Tables

Hi guys i need a help again.

In this case have my Enemies created and working good using a parent BP called BP_Enemy, from that i create the enemies and the settings for each enemies are stored on a database called NPCTable. Here have the values Health, Mana, Damage, Range, Name and ID.

My problem is when try to create a widget to add a health bar over the enemies i cant ganerate the progressbar for this health or mana.

I dont know the way to take the value stored on NPC Table over in array (0 is health, 1 is mana, 3 is damage) and use that to make the progression bar.

This is the way set my health and mana from the table to the array:

Someone have any idea the way to do that?

BR

You could use a widget component set to screen space to display the health/mana above an enemy. Here is an example of a super basic setup.

312451-healthwidget.gif

the widget is setup to just be a single progress bar anchored to the center. there is a custom event to update the percentage it is at.

312453-widgetbp.png

on the enemy, cube in my case, just call the widgets update event whenever you need the bar updated. In my example I’ve attached it to a random timer.

You can expand upon this setup and add more bars for mana, etc.

Hi @Okarii, I make all like the images but have a problem catching the current stat health from my array.
I have this set before when spawn the Enemy:

And later have this taking damage to kill the enemie, but have problems taking the current value…

In the first image set the stat health (0 in array) and mana (1 in array) from the Table.
In the Second image take damage and decrease when take any impact or melee attack.

But i can catch this value to update the percentage Bar…

Thx

@Okarii i put wrong you user jeje about the test, have the bar over the enemys ok but never decrease when recieve the damage, because i can catch the current help update from the array like say before!

From looking at your section on apply damage. I’m trying to understand a little of why you are using a float array, but regardless, here are some things. You’ve got some redundant nodes there I have Circled in Red, you can just remove those. If you looking for where to plug in the UpdateHealthBar Event I would recommend it right after you set the array element, I’ve marked that in blue. And it looks like you are using a clamp node to try and handle some == logic on a branch node later. given its about if the enemy is alive or not, you could remove the stuff on the left indicated by the black box and just change the branchs logic to <=, then if the health ever is 0.0 or less, you can assume the enemy is dead.

If the Print node you have is still not indicating decreasing health then the issue is not in the nodes your currently showing, its either in whats calling this function, or it could be something on the widget, you may want to have a print node (i would change the text color for it) to verify if health value changes are getting there. Keep in mind that a progress bar works from 0-1, 0 being completely empty, 1 being full. anything OVER 1 will still be treated as just full progress bar.

Hi @Okarii, if remove the black part my enemie never die… already put the update on the blue side but nothing happen…

What is the range of float values you are passing to the progress bar? 0.0 to #?

Hi @Okarii, the variable on the array StatCurrent (0 - Health) is set on the beigin play on the BP_Enemy Parent using this nodes:

For that use the variable Health stored on the Data Table for my enemies like that:

The problem with the health bar is cant catch the StatCurrent Value i dont know why…
My flow is simple, all the stat for my enemies are stored on a Data Table from here create and array and make the set to the current stat value like the image before.

So the progress bar operates as 0.0 = 0%, 1.0 = 100%. So any value >1.0 is treated as 100% as well. If you want to use 100 health as their health then you need to divide current health by max health and send that to the widget.

312548-health.png

Thx for your help @Okarii
Now have the bar working…
This is the nodes: