I’m working on a large VR project in UE4 at the moment and hitting huge brick walls when trying to implement a loading screen between the game’s chapters.
What we need to happen:
Fades the screen down
Loads up (or teleports the player) to a “loading room” with some 3D text and a few 3D planes (with some nice artwork on) for the player to look at while the game loads.
Fades out when loading is done and starts the new level once the fade is done.
I’ve been trying various ways of loading up new levels in code and Blueprint, but never getting anywhere.
My main issue is that UGameplayStatics::OpenLevel entirely blocks the game, meaning that any VR headset movement is frozen until the next level is fully loaded.
Has anyone had any luck with making a smooth loading screen in VR? Or what solutions have people been using instead?
I’ve found the simplest solution is that cheat exactly. Fade into black before loading your next level, and have it fade in from black. So while things are frozen you don’t notice that it’s not tracking your head.
I would presume that it uses a mix of level streaming and standard loading. Stream the “Loading screen”, which is a level in itself, albeit, a very simple one, during the game load event. As that level would always be sitting in memory, you can access it almost instantly. So:
Game Starts
Loading scene is loaded into memory
Player is teleported to loading scene
Level 1 is loaded, player teleported to level 1 with a fast cross-fade
When level 1 is finished, the player is teleported to loading scene with fast cross-fade
Level 1 is unloaded from memory, Level 2 is loaded, player is teleported to level 2 with cross-fade.
That would make the best sense to me. The cross-fades are really only in there so the “instant teleport” isn’t as jarring as it would be otherwise.
I’ve had some interesting investigations with something called a “Transition Map” with seamless travel.
This requires code as none of these variables or functions are exposed to Blueprint (because it’s completely undocumented?), but here goes.
In a custom CPP GameMode constructor, set the bUseSeamlessTravel variable to true.
this->bUseSeamlessTravel = true;
Now you can set a transition map in the project settings in UE4 (click the advanced arrow). Here you choose a light map that will have the 3D loading screen in it.
At the moment my editor crashes whenever I try to do a seamless travel (have asked on UE4 Answers, no reply). So, I’m currently doing this (where Level is an FString):
if (!GEngine->IsEditor())
{
// just doesn't work in editor. Crashy crashy.
GetWorld()->SeamlessTravel(Level);
}
else
{
UGameplayStatics::OpenLevel(GetWorld(), FName(*Level));
}
I have a button in my game for testing that is hooked up to a Blueprint Macro that fades down my level, waits for the fade to finish, then calls the above CPP to jump to the transition map.
The transition map runs smoothly for a little while, then hangs/lags horribly and eventually jump-cuts to the new level when ready (where I fade back in).
It’s not perfect (loading is super-jumpy, which hopefully will be improved with 4.6 and async loading???), but it kind of works? It could be that this feature is being used completely incorrectly. Would really appreciate any further thoughts on this usage or if anyone from Epic has any comments on usage on transition maps (since I can’t find any examples or docs)?
I’m testing Transition Map, the behavior is just like Cube said:
Instant jumping into Transition Map, then waiting for destination map loading, then screen hangs for a while, then instant jumping into destination map.
The problems are the screen hang and the second instant jumping.
The first instant jumping can be fixed by a fade in triggering by Transition Map’s BeginPlay(), but not the second, since there’s no obvious event to implement right before screen hang.
The desired behavior should be a smooth fade out when destination map is loaded, while Transition Map is also smoothly rendering.
And the screen could hang now since everthing is black, in the meantime player is jumping into the destination map.
I’ve traced some source code and thinking UEngine::BlockTillLevelStreamingCompleted and GEngine->BeginStreamingPauseDelegate->Execute might be clues but not sure.
Any help would be appreciate.
I’ve been unable to remove all screen hanging when loading/streaming maps, so we’ve abandoned that and are looking into something else using the VR layers feature coming in 4.11.
Did you mean the hanging still occurs with level streaming? Is the hanging occurring during the loading or begin/ending of the loading?
As my experience there’s tiny hanging during the loading with shipping build game, and I’m ok with that, even though it’s not supposed to happen.
As the layer, are you referring to stereo layer? If that could be a method to make smooth loading screen then it’s great news! though I haven’t see any detail of that.