Announcement

Collapse
No announcement yet.

[UMG]try to find the best way to add and store widget (HUD, gamemode, character)?

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

    [UMG]try to find the best way to add and store widget (HUD, gamemode, character)?

    Hi guys, try to ask, where is the best place to create widget and store it for future use ? for now i create it in character BP, but if i unposses from character --my widget stop updates or if i destroy my character how can i get access to widget?, so i think i must create it in other place with ability to access it from any place, so where?
    Last edited by zip; 06-28-2015, 01:03 PM.

    #2
    I tend to spawn my widgets from the player controller, so that when I swap pawns, the interface isn't lost.

    Comment


      #3
      Originally posted by Grogger View Post
      I tend to spawn my widgets from the player controller, so that when I swap pawns, the interface isn't lost.
      thx for reply, so I need create bp class player controller and create my widget inside? or what you mean?

      Comment


        #4
        This depends on the Widget. For example: MainMenu, GameMenu and other Widgets where you know that only one of them is active at a time,
        can be stored in the GameInstance class. This class only exists once on each Player and will persist throughout LevelChanges.

        You could create a State variable (enum) and switch between states and widgets when you change levels. Have a look at the "MultiplayerShootout"
        game on the LearnTab. There you can see a cool setup for this.

        Other Widgets that are created dynamically should be placed where they fit the most. InventorySlots for an Inventory Widget should be created in the Inventory
        widget itself. Although you can always think if the main Widget could be stored in the GameInstance.

        For example you could have a function in the GameInstance to create a certain widget (for example an inventory) and let the PlayerController or PlayerState
        call the function as soon as it is up an ready (BeginPlay of the class). I, for example, need this, because my inventory widget needs a ref to my PlayerState.
        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


          #5
          thx for full reply

          Comment

          Working...
          X