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?
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?
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.
thx for full reply