Announcement

Collapse
No announcement yet.

Problem with my progress bar

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

    Problem with my progress bar

    Hello, I am using a UMG widget to track my health aka shield.

    Here I have a User Interface Widget Blueprint. As you can see I bind the percent to my Health variable.
    Click image for larger version

Name:	1.jpg
Views:	1
Size:	504.8 KB
ID:	1160119

    In this Graph of the widget casting to where my variable is.
    Click image for larger version

Name:	2.jpg
Views:	1
Size:	548.3 KB
ID:	1160120

    My variable Health getting the percent of my max health from 1 to 0.
    Click image for larger version

Name:	3.jpg
Views:	1
Size:	521.1 KB
ID:	1160121

    I created the widget in the level blueprint.
    Click image for larger version

Name:	4.jpg
Views:	1
Size:	534.4 KB
ID:	1160122

    In this video you can see that the bar is empty all the time, I'm printing my health variable on tick as you can see on the left.


    Can someone tell me what I missed.

    #2
    Where is the "print string"? In character BP or UMG?

    If we do it in UMG we can check the real value that is receiving.

    Anyway, Could be your problem that you have unchecked "is variable" in your "Shield Bar"?
    Last edited by vegetamaker; 08-26-2015, 06:08 AM.

    Comment


      #3
      put it in the char bp then just print the value out.

      Comment


        #4
        I had it on my character BP, I moved it to the HUD and it prints out 0, when I exit I get an Error Accessed None 'K2Node_DynamicCast_AsFlying_Pawn' from node Cast To FlyingPawn in blueprint my_HUD. I checked is variable and it is till not working.

        Comment


          #5
          The Accessed None Error could come from a few ticks that the Bind tries to use the variable before the OnConstruct actually fills it.
          I normally bind a function instead of a variable and then you can use a "IsValid" node for the Pointer/Reference Variable to make
          sure that you don't use it when it is NULL/empty.

          Is the Health Variable also 0 in your CharacterBlueprint? Because if yes, then you have some false calculation going on there.
          If not, then you might want to bind a function instead of the variable.
          Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

          My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
          (Including 100+ Pages Multiplayer Network Compendium to get you started.)

          Comment


            #6
            Well that explain where is the problem.

            If in Character BP value is correct, but in HUD isn't, then the problem is that it isn't getting the value correctly.

            I guess I found the problem exactly. It is in your second image (and other things, but step by step). I guess your "My Character" isn't a "pawn" type and your "get player character" I replaced it with a "get player pawn" (well, atleast should be a pawn right? if not, you can't move it)

            Click image for larger version

Name:	6cfc652dd5afa6e8c182beb83364fa34.png
Views:	1
Size:	37.6 KB
ID:	1084492
            With this code I am making a reference to the pawn controlled by Player index 0 when widget is created.

            Click image for larger version

Name:	9ae47379c9e8acd995abc3db7f943fe7.png
Views:	1
Size:	74.7 KB
ID:	1084493
            This other code is where I checked the value of the "binding" of a text in the widget. It update the text correctly with the "pepe" variable value in my characterBP.

            I hope this help you

            Edit: eXI posted while I was writing :P. Thanks for explain that error! Btw, look like the OP have the correct values in CharacterBPs, atleast it is was look in the video.

            Edit2: I guess I learned somethings with this thread ^^. Ill practice the references again. If I said something that make you move your hand to your forehead and move your head side to side, please forgive me. Ill work harder to learn more.

            Is the Health Variable also 0 in your CharacterBlueprint? Because if yes, then you have some false calculation going on there.
            If not, then you might want to bind a function instead of the variable.
            So the problem could be only that he is trying use a variable that still doesn't exist? That could explain why my code worked, because I did a fuction instead a variable reference for the bind (I must admit that I don't know how to bind a variable directly there :P).

            Thanks again.
            Last edited by vegetamaker; 08-26-2015, 07:37 AM.

            Comment


              #7
              @vegetamaker: You also need to fix something. The "NOTE" displays it. In a function, each possible exec needs to end in the Return Node.
              In C++ this will give compile errors if not! That's why Epic made multiple return nodes in 4.9.

              To get this working i do the following:

              Create a LocalVariable for the Function. Make it the same Type as the ReturnValue (text here). Now, use 2 Set Nodes for this variable.
              One Set node is for the working part, where you just plug in your "pepe" value. The other one is kept empty and all failing execs will
              go into it. Like the CastFailed.



              This fill fix the Warning and should always be used!
              Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

              My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
              (Including 100+ Pages Multiplayer Network Compendium to get you started.)

              Comment


                #8
                That NOTE mean! I thought all this time that I pressed a key when I not should and added a note (promise, I spend some time looking what was that :3).

                Thanks so much eXI!

                Let me ask you something, what is the node that is linked to your "Character Ref"? I guess I will need it soon :3

                Comment


                  #9



                  A self made Struct. Structs are good to save a bunch of variables and keep them together.
                  You can create your own.



                  But let's not further spam his thread here with other topics. If you need help with structs etc,
                  feel free to open your own thread.

                  @OP: The Screenshot i posted in my other post above is how you want to make your Bind Function.
                  But you will take the Health variable and not a Struct like i did. Then you select this function for the
                  percentage bind.
                  Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

                  My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
                  (Including 100+ Pages Multiplayer Network Compendium to get you started.)

                  Comment


                    #10
                    Very nice explanations. I love it when I learn new things.

                    Comment


                      #11
                      Thank you so much, I fixed it. vegetamaker was right all I needed to do was change it to get player pawn. It's working perfect.

                      Comment

                      Working...
                      X