Announcement

Collapse
No announcement yet.

UMG Question - Display Boss Health in Progress Bar

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

    UMG Question - Display Boss Health in Progress Bar

    Hi everyone,

    I'm trying to display the health of an actor in my level in the progress bar of the UMG. All of the tutorials that I've read have only mentioned getting info from the player, using the Get Player Character function to cast to.

    I've been trying, with no success, to get the UMG to see the health variable on an actor in the level; all the routes I've taken (Cast to class) have resulted in a failed casting. I'm not too sure what I'm doing wrong.

    Has anyone else managed to get the UMG to display a variable that is not tied to a player character, and if so, how?

    #2
    Only level BP knows about your boss. So when you spawn boss your level BP need to tell player that boss is spawned and its reference ptr.

    So make variable in player that can keep boss reference. Or do for each actor of class, and pick boss class bp.
    Or spawn all enemies from inside gamestate, game mode or player controller (whichever you preffer), and store that reference value given by spawn node.

    When you have that reference cast to boss same way you cast to player, but insted "Getplayercontroller" use remembered value for boss.

    Comment


      #3
      You can have a variable on your character bp. Lets call it BossHealth. When boss bp would take damage,on event any damage it would cast to character bp and set BossHealth variable(on character BP) with the number of hitpoints left after the damage. Now you just need to bind BossHealth with an umg to display it for you. I am sure there are better ways, just a quick thought.

      Comment


        #4
        wouldnt it just be easier to set the variables on the boss it self so it can take damage dont see why you would need it on the player when the boss it self can hold its own health system. you can save your self alot of headaches that way. using collision as a way to tell that its been hit. make a function that checks for collision and and subtract damage by the damage it has received. for your progressbar just set it up like you would the player with the bosses info instead

        Comment


          #5
          I dont mean he should set up entire boss health system on character BP. I said just have one tiny variable in character BP that has its value set by the hitpoints on bossBP. The man said, he is unable to do it directly from boss bp and you say nah just do it from boss bp.

          Comment


            #6
            this is like the 3rd or 4th related topic on display stuff from a different BP on player's HUD. I'm tempted to write a wiki about it if UMG is consider anywhere as finalized.

            The basic idea is leave a named slot or a layout widget with empty contents. Have a (in OP's case) enemy health bar widget blueprint so you can create and insert to player's HUD widget.
            Then, when the event happens, the you insert enemy health bar widget to player, binds the widget update events to boss's take damage event so when boss takes damage, boss can dispatch and update that widget by itself.
            Unreal Engine 4 Game Framework diagram for relation of all major base object types
            Unreal Engine 4 Input Event diagram, scroll down to section Input Processing Procedural
            Resident Evil Classic Camera
            RPCs official document, Must Read
            Everything you should know about replication

            Comment


              #7
              Thanks for the replies, everyone.

              Penguin, is there a sample graph you have of how this works? If I'm reading correctly, I would basically:

              1. Leave an empty spot in the player's HUD
              2. Make a new UMG blueprint that's just for the boss's health.
              3. Put the 2nd UMG into the first UMG.

              After that I'm afraid I'm a little lost, how would I get the second UMG to bind the widget to update when the boss takes damage?

              Comment


                #8
                Yes, but you would need event dispatcher so that when boss takes any damage, it will automatically updates the health bar on player's HUD.

                My example would be reverse, I have a context menu that can adjust a actor's parameter on screen, so the actor added it's own parameter widget BP, and then binds event to those widget's change events.
                But the same concept should apply to boss health, so instead of a input that changes a slider, it's a event that damaged boss that updates the widget you create and then insert to player's HUD.
                (you need to keep a reference of that widget in your boss object, so you can pass health over and directly adjust the health bar when boss takes damage.)
                Unreal Engine 4 Game Framework diagram for relation of all major base object types
                Unreal Engine 4 Input Event diagram, scroll down to section Input Processing Procedural
                Resident Evil Classic Camera
                RPCs official document, Must Read
                Everything you should know about replication

                Comment

                Working...
                X