x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

MultiPlayer: How to set a persistent loading screen while connecting

Hello,

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.

  1. Set the LoadingScreen Widget in Game Instance. Results: Widget gets automatically removed upon arriving in the new map.

  2. Set the Widget in the PlayerController OnBeginPlay. Results: Widget appears but not immediately. We can see the game for a frame or two.

  3. Using the Construction Script in the player controller to send an Event to the GameInstance (since it's not possible to create a widget in the construction script). Results : Error: CreateWidget cannot be used on PlayerController with no attached player.

  4. Using the Level OnBeginPlay to Create the widget. Results : The level is visible for a frame or two (same as 2)

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" ?

Thanks

Product Version: UE 4.10
Tags:
more ▼

asked Sep 22 '16 at 04:09 AM in Blueprint Scripting

avatar image

Genova
273 21 24 35

avatar image ziga.osolin Jan 21 '17 at 10:41 AM

I have the same problem ... How do you remove that frame or two. I tried many things and nothing seems to work ...

avatar image Genova Jan 21 '17 at 08:59 PM

I've put that task aside for a while, but I found out that using server travel instead of open map will keep the widgets alive during the loading. I think, I haven't dug much into that yet.

avatar image gon. Mar 07 '19 at 11:16 PM

Have someone solved this problem? I would also like to add a joining session screen when a client joins a server. Thank you

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

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:

 void UYourClassName::ShowLoadingScreen(UUserWidget *Widget, int32 ZOrder)
 {
     GetGameViewportClient()->AddViewportWidgetContent(Widget->TakeWidget());
 }
 
 void UYourClassName::RemoveLoadingScreen(UUserWidget *Widget)
 {
     GetGameViewportClient()->RemoveViewportWidgetContent(Widget->TakeWidget());
 }

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.

more ▼

answered Aug 22 '18 at 12:14 PM

avatar image

OliverKrieger
16 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Jan 22 '17 at 08:52 AM

avatar image

ziga.osolin
206 9 12 76

avatar image mgumley Feb 03 '17 at 10:31 PM

Which blueprint are you adding this to? I tried adding it to the map tick, the gamemode tick, and the player controller tick. No matter what I tried, the loading screen does not appear before you can see the half-built map.

In single player it seems so fast that I can't tell, but when joining a server I can see it for a couple frames.

avatar image ziga.osolin Feb 03 '17 at 11:06 PM

The game mode is only spawned on the server so that won't work. The player controller is also spawned on server and replicated to the client. For map tick I am unsure if you can set "Tick before Begin Play".

I just added a simple blueprint to level that calls this on tick. So create a new blueprint, use the Tick event -> DoOnce -> Spawn Widget that overlays everything and place that blueprint in the level. Do not forget to tick of "Tick before play".

avatar image song_zhi_hua_1 Apr 01 '19 at 04:20 AM

good job; thanks your idea!!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Apr 11 '19 at 02:46 AM

avatar image

WinterLanternPro
1 1 2 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question