Hi, so you try to display the health of the player and the player character inherits from “TestEnemy” / is a “TestEnemy”, right?
I know what are you trying to say hehe 0 and 1 not working. 0-100 not working.
Its just Always “0”
If i connect (for text block) cast failed to return node its shows 0 Like its current health 0
Hello everyone,
From this image this all looks fine but in real… its not like that at all…
WITHOUT BINDING… Text block and progress bar are on screen while playing… (Fill percent works fine )
WITH BINDING … Text block gone progress bar is grey…
Print string on my cast failed works it prints “Hello” hehe
All this binding and scripting works fine on beginning of my game but somehow its just wont work now… I watched so many tutorials about how to set up this simple “code” but its not working Can you try help me
Thanks
Yes, i want to display enemy health bar over enemy grad. But its not showing while i Bind get percent
Just checking, the health is between 0 and 1?
i want to display enemy health bar
over enemy grad.
The logic above will only work if you want to display the health bar of the player, it will not work for anything else. If you want to display the health bar of something else, you will need a reference of that something else (e. g. a reference to that enemy) and then use that instead of “GetPlayerCharacter”, since “GetPlayerCharacter” will return a reference to the character that is currently possessed by the player.
I ll try to do that and will let you know is it working like that
325253-
This is a result of getting reference to my “TestEnemy”
… Still got a error… I followed this tutorial: Show Health (Progress Bar) Above Widget | Floating Widget - Unreal Engine 4 Tutorial - YouTube
1st time before few months with this tutorial this works fine… Now after i create some game it just wont work…
Okey i got it boys: this is great now ill let you know step by step how to do it. CHRUDIMER was right:
- Create your char
- Add Variable (Float) “Health”)
- Create widget and add progress bar ( as you want create it)
- In progress bar on PERCENT create Binding (usually "Get Percent 0)
- In widget of Health_Widget go to Event graph. Expand from Event Construct > Get all actor of class(Set Actor class as your char you want to show Health on )
- Expand Get all actor of class to CAST TO “YourCharachter” (is char you want to show Health )
- Out of Actor expand to Get a copy and connect to Object
- On Cast to “YourCharachter” ( go right click on As “YourCharachter” and promote it to variable
- You ll get your Reference here. Call it as you like
- On “Get percent 0” connect it with return node (By default its already connected)
- Get your reference ( you call it somehow on step 8 )
- expand it to Get (your variable ) Health expand it to float “/” float and / by 100
- Connect it with Return value under Return Node
Do not forget to use Widget on your character
This will only work when there is one enemy. Instead you should have the “Test Enemy” class spawn the widget and assign itself (self) to that widget. On the “Test Enemy REF” check the boxes “Instance editable” and “Expose on spawn” then you can assign this variable while you call “Create Widget”
Great, i did it You can remove Cast to “YourChar” after createing variable from it then i can multiple enemy in game.
I do it the same way on another char and now its not working with same parameters but print string print me Right value… but binded text block is always full hp on Event Any damage Grrr
Hey friend i wanted to let you know you are a genius i was not able to solve this health bar problem for nearly a month . Thanks to you soo much