Announcement

Collapse
No announcement yet.

Setting a variable in UMG, that is in another Blueprint

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

    Setting a variable in UMG, that is in another Blueprint

    I am a bit clueless here, I just want to set a variable when the button is clicked.

    So i did what I always do when I want to set a variable -> is sticked it to the key/button, but this wont work.

    I also tried to cast it to the character blueprint, but i think that i have done something wrong.

    I think that something needs to be connected to "Target", but what? I can't put in the Charater-Blueprint there - this is what confuses me. (or maybe I am just thinking the wrong way )

    I would appreciate any help: (NOTE: It is not connected to the "onclick" because I was experimenting around with it - I do get the String, but the variable won't be set)

    Click image for larger version

Name:	UMGBUTTONVAR.JPG
Views:	1
Size:	29.9 KB
ID:	1151927

    Thank you.

    #2
    What blueprint is the variable located in? If it is the character BP, then just cast to your character, using get player controller as object.
    Marketplace Assets

    Advanced Mobile Input: Marketplace Page | Support Thread ――― Easy Input Remapping: Marketplace Page | Support Thread
    Multiplayer Blueprint Chat System: Marketplace Page | Support Thread ――― Closing Credits System: Marketplace Page | Support Thread
    Minesweeper Template: Marketplace Page | Support Thread ――― Maze Creator: Marketplace Page | Support Thread

    Comment


      #3
      What blueprint is the variable located in? If it is the character BP, then just cast to your character, using get player controller as object.
      It is located in a renamed "MyCharacter" (YK_Character)

      I did this, does not work (top Cast can't even be connected to the SET):



      Or did i missunterstand what you said? (sorry if this is true )
      Attached Files

      Comment


        #4
        If the Character is a child class of Pawn (which is probably sould be) then you should use 'get player pawn'.
        Columbus Ohio Unreal Meetup
        @OCGameStudio | Sphere Complex | twitch.tv/WFMOz

        Comment


          #5
          This worked, thank you very much.

          Comment


            #6
            Sorry to hijack this, but what if the variable is located in the AIController blueprint? It's not an actor so 'Get all actors of class' and then using for loop to cast to AiController will not work. Any suggestions?

            Edit: And how would we access the widget reference from another level once the level containing this particular widget is destroyed by Gameinstance?
            Last edited by Markus Maximus; 06-19-2015, 08:58 AM. Reason: Additional information

            Comment


              #7
              Originally posted by Markus Maximus View Post
              Sorry to hijack this, but what if the variable is located in the AIController blueprint? It's not an actor so 'Get all actors of class' and then using for loop to cast to AiController will not work. Any suggestions?
              AIControllers are Actors.

              Originally posted by Markus Maximus View Post
              Edit: And how would we access the widget reference from another level once the level containing this particular widget is destroyed by Gameinstance?
              You wouldn't, you shouldn't store game state on widgets permanently, the UI should merely reflect the state of the world.

              Comment

              Working...
              X