Announcement

Collapse
No announcement yet.

How can i get variable from UMG Widget blueprint, in other blueprints ?

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

    How can i get variable from UMG Widget blueprint, in other blueprints ?

    Guys i need your help, i create "Editable text box" and "button" on widget blueprint, after this i made an event "on button click", to store text from editable text box. Now the question: how can i get this variable on other blueprints ? for example on "MyCharacter"

    #2
    You need to assign the MyCharacter to a variable in the GUI so it has access to it just like normal blueprints. When you construct the widgets you can also assign them a player controller. Then you can access the player controller on the GUI cast it to your particular type, and then get information like the character pawn, or player health...etc.

    Cheers,
    Nick

    Comment


      #3
      If I understand you correctly, I made a couple of screenshots to show the result.
      This is example of my event.
      Click image for larger version

Name:	Example.jpg
Views:	1
Size:	408.5 KB
ID:	1056840
      This is some errors in log after i try it in game.
      Click image for larger version

Name:	Result.jpg
Views:	1
Size:	405.3 KB
ID:	1056841

      Help me with this, what did I do wrong? It looks very simple, but I'm trying to figure it out for several days, and there are no results.

      Comment


        #4
        Casting

        I posted a complete tutorial that shows interaction between UMG widget blueprints and the My Character blueprint, it has lots of pics!

        https://forums.unrealengine.com/show...l=1#post146513

        As you will see in my tutorial you need to cast your UMG widgets and then access the variables of each of your widget elements.

        So there are a series of casts involved!

        If you walk through my whole tutorial you will have the answer to your question when you are done!

        Rama
        UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

        ♥ Rama

        Comment


          #5
          Thank you, you helped me a lot!

          Comment


            #6
            Originally posted by Div1ne Duck View Post
            Thank you, you helped me a lot!
            Yay!









            Rama
            UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

            ♥ Rama

            Comment


              #7
              Originally posted by Rama View Post
              Casting

              I posted a complete tutorial that shows interaction between UMG widget blueprints and the My Character blueprint, it has lots of pics!

              https://forums.unrealengine.com/show...l=1#post146513

              As you will see in my tutorial you need to cast your UMG widgets and then access the variables of each of your widget elements.

              So there are a series of casts involved!

              If you walk through my whole tutorial you will have the answer to your question when you are done!

              Rama

              How about firing a custom event in a actor class blueprint.. from UMG
              RhinoGameHK | Twitter | Instagram

              Comment


                #8
                Originally posted by soulmapp View Post
                How about firing a custom event in a actor class blueprint.. from UMG

                That is in my tutorial as well!

                https://forums.unrealengine.com/show...l=1#post146513

                Check out the section about binding the button Event!

                https://wiki.unrealengine.com/UMG,_C...ate_Bind_Event


                You can put any BP code you want there!

                To get the actor so you can fire the event you have many options

                1. create a variable in the UMG BP, for your actor, and set the variable when the UMG widget is created, wherever it is created.

                2. use BP interface

                3. Get All Actors of Class, and find the one you want by name

                I would tend to prefer option 1, assuming you create the UMG widget in your level BP or your My Character BP, you should be able to set the var on your UMG widget right there!



                Rama
                UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

                ♥ Rama

                Comment


                  #9
                  Rama, one more question, when i create widget on level bp, i must casting it on my character bp ?

                  Comment


                    #10
                    Originally posted by Div1ne Duck View Post
                    Rama, one more question, when i create widget on level bp, i must casting it on my character bp ?
                    Can you show a picture of your question, or explain more?
                    UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

                    ♥ Rama

                    Comment


                      #11
                      UMG Tutorial Update

                      I updated my UMG tutorial to answer an important question!

                      So I now have a FAQ section

                      https://wiki.unrealengine.com/UMG,_C...amic_Array#FAQ

                      Rama
                      UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

                      ♥ Rama

                      Comment


                        #12
                        I'm trying to understand this problem for about a week, and no results.
                        But it should be easy, I just need to understand the logic. I need to assign a variable from UMG, to the variable of MyCharacter. Help me man! :C
                        There some pics, with my problem.

                        This is button click event.
                        Click image for larger version

Name:	Example 1.jpg
Views:	1
Size:	361.9 KB
ID:	1056862

                        This is how i create widget and add to viewport.
                        Click image for larger version

Name:	Example 2.jpg
Views:	1
Size:	310.9 KB
ID:	1056863

                        And this is how i set the "name variable" of my character. I know about casting, but what should i cast and on what ?
                        Click image for larger version

Name:	Example 3.jpg
Views:	1
Size:	379.3 KB
ID:	1056864

                        Comment


                          #13
                          Bump. still need your help guys.

                          Comment


                            #14
                            I do actually show how to communicate between My Character BP and UMG in my tutorial

                            https://forums.unrealengine.com/show...-Dynamic-Array

                            you need to save a casted version of your UMG widget in your Character BP to then get/set its vars

                            You should look closely at my pics in my tutorial!

                            Beyond that I do offer tutoring services:
                            https://forums.unrealengine.com/show...Game-Mechanics

                            Rama
                            UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

                            ♥ Rama

                            Comment


                              #15
                              I try to understand the same thing, but can't use casts because I did not generate the Widget in the graph Editor,
                              instead I placed the widget into another Widget in the Designer which seems to work out. But now I have a button inside
                              one Widget and if that is being pressed, it should deactivate a Widget and activate another one instead.
                              I have Boolean vars to set if the Widget is active or inactive, but don't know how to access those Variables from another
                              Widget. Can please someone explain it a bit so a newbie would understand it ? Until now in this thread there are only
                              fragments of information that seem to make no sense.

                              Comment

                              Working...
                              X