BattleTank - Displaying health on Player UI instead of using the health bar?

Hi everyone,

I am attempting to continue my learning/add functionality to the games like BattleTank now that I’ve finished the Unreal course. On BattleTank, for example, I’ve redone the scenery with a height map, changed to new meshes, and added a firing sound with attenuation.

But at the moment I’m wanting to ditch the health bar on the player controlled tank for a visual indicator on the HUD. I’ve got a tank silhouette .png that I’m going to change the color of depending on damage taken. I’ve run into some problems accomplishing this. In the course we reworked the Player controller, and now a found event for the AimingComponent creates the PlayerUI, with no reference to the tank itself.

As far as I can tell, I need to get a reference to the tank so I can set a variable for the UI BP to get the tank health value or health percent. I’m not sure what the right way to do this would be. My failed attempts so far have returned a warning in the log on play that the variable returns “none” in the PlayerUI_BP. I would appreciate any help :slight_smile:

Through some searching around if fould a solution (Thanks to this post and the reply by @Leonardo_Vici: Health Bar directly in player UI ), I did something similar in the PlayerController C++ to set a tank variable for the UI BP. Don’t know if it’s the best/right way, but it works.

After that, I couldn’t figure out a good way though Blueprint to have 3 or 4 different float or int value ranges to set different colors, so I did something similar to how we set the aimpoint color/conditions and used an ENUM in the Tank C++. Again, don’t know if that’s a good way to do it…

Privacy & Terms