Announcement

Collapse
No announcement yet.

How to add a individual HUD elements to each character using inheritence

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

    How to add a individual HUD elements to each character using inheritence

    I am trying to learn how to code game logic using only Blueprints.

    1. So to start I create a Character blueprint with a bunch of variables and some functions to update those variables.
    2. Then I created a child BP using the first BP.
    3. In this new BP I want to add common HUD elements that all the different characters will share. Like Health or a value from any other variable.

    How do you add a HUD somewhere along the line of child BPs so you can eventually add custom meshes to the last child BP and create several controllable characters that share the same HUD elements.

    I want to show individual health bars on top of (or beside) each character.

    I hope this makes sense.

    #2
    You can think of it as separated things. HUD and Pawn do not necessarily walk together unless you give the HUD calls to display things to your screen. Thus, feel free to create your own logic for this.

    I suggest you get your eyes on the HUD Blueprint (you can change which HUD Class will start in each map, in the selected game mode) and make a child of it. The HUD class will be your HUD manager, which can simply draw textures or materials into the screen or spawn widgets for you.

    You should initialize your HUD spawning the correct Widgets.

    Follow this tutorial to make a widget that shows up the health and whatever you want to show since you get the logic of how to make it. After, go inside your child HUD class and spawn this widget class in the begin play.

    Comment


      #3
      Thanks for your reply. I have seen that tutorial. How would this method work for a game like LoL or Dota? How do you assign mini huds to 8 or 9 players that could be dead or off screen?

      Comment


        #4
        Each player(client) has its own Player Controller. Each player controller possess an instance of pawn/character. Each instance of pawn/character will have its own values to each variable it carries within.

        From this, you may always get the correct reference from what you want to display, usually from the current Pawn your Player Controller is actually possessing.

        About the health bars following each character over head (if you want to make like DotA 2) I suggest you follow this thread .

        To access the other player variable, it must be replicated. So keep in mind to replicate all these variables you want other players to know.

        Comment

        Working...
        X