Referencing a variable from different Class BP's to the same HUD

I’m trying to get my HUD to display the status of my target, through a reference saved in my Game Mode BP.

The way I go about it is, I first create a Character Reference variable in my game mode BP.
Then inside one of my enemy BP’s: When the enemy is clicked on i cast to the game mode BP and set the Character Reference to self.
When I then try and bind the health bar of the HUD to the health of the target i can’t get anything other than inherited values. If I instead of a Character Reference variable create a Enemy Reference variable (specific blueprint) I’m able to get all the different variables inside my enemy, but the problem comes when I have many different types of enemys since I can’t have a specific variable for each type of enemy BP.

Inside one of my Enemy classes:
The variable that does work: (inside the game mode BP)

How many enemy classes do you have? If you don’t mind swapping out the nodes in a function once for each class, you could:

  • set up a ‘HUD health’ variable in your game mode BP
  • use ‘Event ActorOnClicked’ to modify this variable

If you want the HUD element to display something different each time, you could set the UI BP up with multiple types of health bar on top of each other, and use the same event to hide the inactive UI element.

You’re just trying to display your enemy health?

You could handle all that right on your character. Trace your mouse hit, get reference to enemy, cast to it, get values and set them in HUD.