MultiPlayer: How to set a persistent loading screen while connecting
I'm having trouble to set a loading screen that will persist several seconds after a player joined a game. My project is prepping several things that I need to hide when a client join. Issue is not happening to the Host though.
I tried several methods, none worked perfectly.
I'm out of options here. Is there some kind of option somewhere to magically fix this ? I dunno, like a bool "Auto Remove Widget on map travel" ?
There is another option - in C++ you can access the UGameViewportClient::AddViewportWidgetContent that does not need a player controller. So on the game instance, create two functions, one for adding the loading screen that takes in a UUserWidget and a ZOrder and then one that removes the loading screen that takes a UUserWidget you want to remove.
Then using the TakeWidget function, you can pass that widget in as such:
This loading screen will persist through server travels, so you can remove it once everything is loaded. I exposed the functions to blueprints so I can create the widget in the game instance in BP and then feed it into the show loading screen function and keep a reference of it so I can use that to remove it later if it is valid.
answered Aug 22 '18 at 12:14 PM
I actually found a solution. The problem with connection to server is that BeginPlay is called a few frames after the first frame from the login is displayed. This is because (I presume) there are additional things needed to be done to connect correctly.
The solution is to not use the BeginPlay event but rather Tick to setup the initial screen. Additional, enable AllowTickBeforeBeginPlay option. My setup is like this: on Tick, I just do DoOnce node, and then execute everything there instead of in BeginPlay. You can disable Ticking after the initial tick to save performance.
answered Jan 22 '17 at 08:52 AM
This is a fairly old topic but if you don't feel like doing it properly with the load screen plugin then there is another hack that works. Make a custom GameInstance class and on your Init function, add a custom timer and set it to loop every 0.016 seconds. In the loop, add your widget to the viewport if it is not currently added to the viewport. This way it'll add the loading screen to the viewport instantaneously when you arrive at the new map.
It's dirty but it works.
answered Apr 11 '19 at 02:46 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here