Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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:
    Click image for larger version

Name:	SS_1.jpg
Views:	1
Size:	54.5 KB
ID:	1168605
    The variable that does work: (inside the game mode BP)
    Click image for larger version

Name:	SS_2.jpg
Views:	1
Size:	19.3 KB
ID:	1168606

    #2
    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.
    My current question - Getting variables from unspawned actorcomponent

    Our game - Robots Minerals Profit! - a side-on builder game with cooperative multiplayer, made in UE4.

    Comment


      #3
      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.

      Comment

      Working...
      X