HUD question

Hey all, I have 3 character switching system with a HUD that displays each character’s Fuel and Health whenever they are on screen. What I would like to have is a HUD that shows all 3 character’s health and fuel all the time, but when you switch between the characters the 3 health and fuel bars at the bottom update. Any thoughts on how best to do this. Right now I have a HUD that is hooked up to one a fuel and a health variable that are binded to two progress bars on screen at all times.

If the characters are always spawned somewhere in the map, then just have event tick update a health regen or fuel regen if you have them, otherwise, you’ll want to store the heath and fuel in game mode and just pass that to the widget.

Just make the fuel and health instance editable and exposed on spawn and when you call the widget, just pull from ‘get game mode’ cast to the game mode you have set for the map, then connect those variables from the game mode to the create widget node.

Okay, so the issue you’re going to have is that you’re destroying the actors that I would presume are actually containing the health variables which means that you won’t have them to be updated. So what you would need to do is, in the player controller, where you have the tick of regen on health, you would need to ensure that you’re maintaining an array of value reference for each character and then passing those values to the HUD_MAIN on every tick for each of those character’s health and fuel. So if character A is selected and B and C are out, then B and C would have the regen and be passed to the HUD_Main in that order of index 1 and index 2 to keep everything organized and health matching the correct characters.

Then when you switch characters, you would pull the health value from the Hud or Player controller, whichever you decide to store the health variables and set the new actor’s health from that.

You should basically just do your main hp/fuel, label it primary or current, then get the other 4 bars and name the pairs benched1 and benched2 or something so it’s easy to find and update those variables. You would just need to pull the HUD_MAIN reference and set each of them w/ the updated variables from player controller.

Sorry, I added a bit since you responded. So when you destroy the actor, they no longer exist. What you would need to do is get the health of the current actor just before you switch and set that value into an array in player controller so that it stays relevant while the actor does not. That way it’s not the actor, but the health value that regenerates and then when you switch and re-create the actor, you set the health of it on spawn to what it is now after all the regen.

Hey FatalBreak, Thanks for the answer, I should have posted photos of my setup. It’s fairly complicated. Each character gets destroyed and a new character takes their place in the world. They “switch” in and out. I basically just want to find the two characters that aren’t on screen, then pass their updating (regenerating) health and focus to the Main HUD that’s always on screen (pic 1, but instead of 2 bars in the center of the screen, think 3 sections of bars, each that looks like the 2 bars in HUD in pic 1). So the middle 2 bars are for the character on screen, and the other 4 bars are for the other 2 characters offscreen so you can see how much health and focus they have for when you want to switch to another character.

Pics 3, 4 and 5 are from the player controller that oversees all the variables and switching for the 3 characters. You’re saying to somehow get the actors from the array in playercontroller, pass the character index to them, and then pass their health and focus to the HUD? Also, when in the HUD, how would I make sure that the middle progress bars are for the controlled character and the other set of progress bars are for the destroyed actors?

Hoo-boy, I’ll give that a shot. The regen and respawn bit works, i.e. the destroyed actors regen offscreen and when respawned the HUD updates to their regen amount. And you’re saying I need to store each actirs health and focus separately?

Do you have a blueprint example of how you think this would all go? Mainly the widget blueprint and setup is what is confusing me.

I don’t have access to blueprints right now but I can tell you that you want to pass an index of the current character and set that as the primary then apply the other 2 indices to the benched bars. It’s going to take shifting around of 1 bench and 1 primary every time you swap. You’re doing the whole thing a little different than I’m accustomed to with the maps so I’m not 100% sure the best method when using the variable maps like that.

Orrr… You could have 3 ‘benched’ bar pairs and just collapse 1 set which represents the character who is the primary. That way you just reset the bars for the primary character and then collapse their benched status bars.