Multiple Hp bars in the HUD

This is the status of my Blueprints:

On my GameMode i have:

On my Gamestate i’ve generated the Array i load in the GameMoad and i’ve set it to Replicated.

On my Character Blueprint i have this:


Now the explaination:

I wanted to have one Progress bar to work as a “Healthbar” for my current player, and up to 3 little bars ( it’ll be a 4 player game ) just beneath it. Thoose bars have to show Health and Name.

I’ve made an array of controllers, and i’m looping into them, whenever i get My own controller, i just add to viewport the Default Hud, whereas i get another one, i’ll get that Controller Pawn, pass it to the Widget and get Health and name out of it like this:

At this moment i have an issue and some questions:

If i remove the node “isValid” after the ForEach, i get a red error
PIE: Error: Blueprint Runtime Error: “Accessed None trying to read property CallFunc_Array_Get_Item”. Node: Create Widget Graph: EventGraph Function: Execute Ubergraph BP Top Down Character Blueprint: BP_TopDownCharacter

But even with the errore the widget appear ( without the correct bindings to hp and Name)
If i do add a “isValid” node, the widger appears only on the first player (which is the server-listener).

So far i think the problem lies in how i’m using the Array, and i feel like it’s getting out of replication, for the error makes me suppose the second player is getting an empty array.
still, the bar pops out, so it’s not getting an empty array, just one with wrong values.
I’ve been trying to fix this for a couple hours at the moment and i’ll be back at it tomorrow, but in the meantime, if someone notices something it’d be really great.

Also another question:

I’m using a “delay” function after my “onPosses”, because the first player spawns immediately while the others require a few istants. i think i’ll have to make a custom event that gives an “ok” whenever every player has loaded in ( if something like that doesn’t already exist as a default).

might that be part of the problem? does a solution to the “delay” exist that’s more functional and elegant?
Thank you.

Just curious, have you considered using a HUD class blueprint to create and manage all your widgets? It is way easier to manage all the widgets in one place and you dont have to create a bunch of binds or player references in multiple BP widgets.

It could also control the flow of your heath bars that load in late.

If you havent considered it but are interested in implementing it, youll need to do a bunch of work moving over code from your widgets to the HUD class. But it is so worth it. Its easy to pass info from one widgets to the other and if you use interfaces to update changes then your in good shape.

In your case for the other players on each players begin play then can send a BPI message of their current health info to the hud class and it updates for everyone.

Hopefully i didnt lose you here :laughing::laughing: let me know if you need a more detailed description

you cant replicate PlayerControllers, use the PlayerStates for replicated player information

i had developed wrongly the “onPostLogin” logic that updated my array ( was pickup a way worse logic to obtain that) and yes, i’ve changed it so i was picking a list of playercontrollers from my gamestate now.
It works like a charm

Thank you guys for your suggestions.