where/how to spawn UMG Widgets?
i am not sure where i should spawn my UMG Widgets. In the official Tutorials they are spawned in the Character Pawn Blueprints. But i have concerns that this will cause all the UMG stuff to get spawned multiple times, everytime the player dies and a new Character Pawn is created?
I tried to spawn the UMG widgets in my PlayerController Blueprint but it seems it is too early, i can't see anything of the UI ingame if i do it this way.
So what is the best practice where to spawn my UMG Widgets?
edit: Also it seems if the UMG widgets are spawned in the CharacterPawn Blueprint and you run an dedicated server the server crashes because it "Failed to load '/Script/UMGEditor': Can't find file for asset '/Script/UMGEditor' while loading NULL."
If you want to spawn them in the player controller, there's some stuff you gota do in begin play:
1 - Add a small delay, like 0.1. There's currently a bug in the initialization order of player controller, first we create it, begin play is called, then we hookup the UPlayer to it, meaning that isLocalController actually returns the wrong data during BeginPlay for a PlayerController on the server (it thinks all players are local at that time).
2 - Check if the server is dedicated, don't remember the node offhand. Just search for dedicated in the context menu for in the BP graph. Don't create any widgets for dedicated servers.
3 - Check IsLocalController, only create UI for local controllers.
4 - Check if you've already created the UI for this player controller. Make sure when you create the UI you store it in a variable for the PC, so you know if it has been added.
5 - On destroy of the player controller, make sure to remove your widget from the viewport.
answered Feb 11 '15 at 11:18 PM
Nick Darnell ♦♦ STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here