I am having the most stressful days trying to polish the level transition in a multiplayer game.
I checked all the different loading screen solutions and found the one posted by Jamsh is the cleanest (A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums).
The problem is that I need to manually turn off the loading screen on clients to hide all the ugliness when loading an online map. The problem is that this doesn’t seem to be possible since “I can’t call stopmovie() myself if the game thread is frozen… AND I need the game thread to set the game up while the loading screen is still on.” (as mentioned in Loading Screen won't go away without mouse movement - Programming & Scripting - Unreal Engine Forums)
That being said, I would like to find a definitive CLEAN solution to do loading screens that work for all level transition (Open Level and Seamless Travel), Since multiplayer games should work with Seamless Travel and upon joining a session an Open Level kind of transition is executed.
As of now, I have this code. It works if I comment out LoadingScreen.bWaitForManualStop = true; But that means that I can’t manually turn the LoadingScreen off and consequently can’t hide some ugliness that happens in the client in the first few seconds after joining.
#include "CustomGameInstance.h"
#include "MoviePlayer.h"
void UCustomGameInstance::Init()
{
Super::Init();
FCoreUObjectDelegates::PreLoadMap.AddUObject(this, &UCustomGameInstance::OnPreLoadMap);
FCoreUObjectDelegates::PostLoadMapWithWorld.AddUObject(this, &UCustomGameInstance::OnPostLoadMapWithWorld);
}
void UCustomGameInstance::OnPreLoadMap(const FString& InMapName)
{
BeginLoadingScreen();
}
void UCustomGameInstance::OnPostLoadMapWithWorld(UWorld* InLoadedWorld)
{
EndLoadingScreen();
}
void UCustomGameInstance::BeginLoadingScreen()
{
if (!IsRunningDedicatedServer())
{
FLoadingScreenAttributes LoadingScreen;
LoadingScreen.bAutoCompleteWhenLoadingCompletes = true;
LoadingScreen.MinimumLoadingScreenDisplayTime = 3;
LoadingScreen.bMoviesAreSkippable = false;
LoadingScreen.bWaitForManualStop = true;
LoadingScreen.MoviePaths.Init("LoadingScreen", 1);
LoadingScreen.PlaybackType = EMoviePlaybackType::MT_Looped;
//LoadingScreen.WidgetLoadingScreen = FLoadingScreenAttributes::NewTestLoadingScreenWidget();
GetMoviePlayer()->SetupLoadingScreen(LoadingScreen);
}
OnPreLoadMapEvent();
}
void UCustomGameInstance::EndLoadingScreen()
{
GetMoviePlayer()->StopMovie();
OnPostLoadMapWithWorldEvent();
}