I am trying to implement a multiplayer health bar on top of each character.
First I want to make it simple and make it work locally on two players (Say 1 AI and the player )
I have a c++ class that looks like this :
I’ve made an event that I want to be used in blueprints and do stuff with the information provided from the event.
Next, I have is a BP base for the player logic, and two other child BP for two different characters(difference in models, animations, etc )
In the base BP, I add the health component and a health bar widget and it looks like this:
Test print string inside the base class of player ( proper names get printed of damaged player and damage causer )
And finally, in the widget blueprint, I have the following scheme that updates the health bar on start and binds the OnHealthChanged event to a delegate that should update when the player / AI took some damage.
The problem is that the function “Get Owning Player Pawn” ALWAYS returns the same player, not the owner of the widget. My guess is it is because is name PLAYER PAWN (it means the local player ? so it always returns the same widget??? ). If it is like this, how can I get the Widget owner PER instance of the player BP?
What happens is if I attack the AI player, the UI never gets updated ( because its widget got the player owning pawn and a player can never hurt himself !!! ). But when I make a pain-causing volume, WELL, both widgets get updated( like it is the same widget, but with two instances).
Any help is appreciated. Thanks !!