UI Widget BP

Hi,

I’ve created a UI Widget health bar for my NPC Bots. This basically would just float on the top of the bots, pretty usually i’d assume.

Anyway, I’m not trying to bind the value of Health on my bot to the progress bar in the widget and I just cant seem to find how to get the owner.
GetOwningPlayer and all similar methods seem to return the Player Character / Pawn / Controller and not the bot that has the component added on to their Blueprint.

How do I get the NPC object ref in the UI Widget Graph or Bind function!!

Thanks,

In your UI widget event graph create a custom function. With a reference to your character class as an input.

In your character class, add the widget component and set its class in the details panel. Pass a reference of self (The current character) to the widget reference

In the widget blueprint, select the progress bar, then in the details panel next to the percent, select bind, new binding (If you havent already.)
Then finally get a reference of the stored character, get the health and ideally max health from the character reference. (In my image its a local variable called DefaultHealth, but this was just for testing.)
Current health divided by maximum health is what you need to set the final percentage of the health bar.

Hey Mordynak,

Yea, don’t know where my brain got all knotted up…This works very well.

It’s actually quite easy and straight forward (i’m realizing now). Thanks for the explanation with the screenshots, so cool…
You’r awesome…

Thanks…

No problem. Glad you got it resolved!