What would be the best approach to do a loading screen?
At the moment I have my level Blueprint that calls the “Open Level” function call, however it is a blocking method and immediately shows the level once it’s loaded. I’ve tried using the “Load Stream Level” however at the moment, the loading level is separate from the level loaded in question and is its own persistent level. I am not sure if the solution to this is to have your loading level be a streaming level and have a primary persistent level that the user is about to play, load that stream level within it, call the “Load Stream Level” for the primary level after the loading screen has loaded, and then transition to that.
Ideally, it would be great if the “Open Level” function call within your loading level could have the same Booleans like the “Load Stream Level” function call does for choosing whether or not to block the primary thread and also to show it after it finishes. If let’s say, you wanted to show a “Press A To Continue” message after the level has loaded, then to additionally get a “Level Reference” and to call “Show Level” whenever you want to progress while the loading screen level is unloaded from memory in the background would be perfect.
I see an “Options” string input for “Open Level” function call but there isn’t any documentation on the arguments that you can pass, so it’s possible something is within there that can do some of this.
From what I can determine, there is no “simple” method to implement a loading screen. What you will most likely end up having to do is to have your loading screen Blueprint have a link to the loading level so that you know when the level has fully loaded, but instead of automatically loading into the level, the Blueprint will check for a Boolean that you will toggle on when a button is pressed.
Unfortunately there are still some sizable gaps in what I know about Blueprints, so I could very easily be missing something.
Our UE3 hack approach has always been the following, and I assume this still works:
Use Open Level only, never stream in the levels unless you really need streaming (but then you wouldn’t need a loading screen anyway)
Right before calling Open Level, draw a screen covering loading image on the screen. Then right after execute Open Level. This would freeze the screen to the last thing that was on it (the loading screen).
When the next level opens, you make that too render the loading screen on start up, so the loading seamlessly transitions into that one. Plus you add that Press A to Continue text on top.
When you then press A, the screen + text disappears + you gain input control for your character and it appears as if you’ve begin playing.
To work around the fact that the sound would be playing as soon as the level is loaded you can use Sound Modes or such to mute that while you haven’t yet pressed A. You can execute sound modes on specific sound classes to ensure they don’t mute the sound of pressing the ready button for example.
That would be my first plan of attack until a proper loading screen system exists in code.
Ahhh. that’s a great idea. Back when I was developing a game for Dream Build Play back in 2008, I used similar techniques to get a very smooth transition so that each screen transitioning to the next was seamless and I would do all my loading asynchronously so that there weren’t any hitches when it would go from screen to screen. That’s a good point about the level streaming and makes sense why it would be unnecessary for this. Now, if there was a way that could do this without blocking the primary UI/rendering thread and in an async way that could produce a callback, that would be even better but this is a good point to start from.
BTW Hourences, keep up the great work on Project Solus and thanks throughout the years. Indirectly you’ve been a big help to me and I’ve come across many of your articles, tutorials and thread posts off and on that have helped especially when I was heavily focused on engine development and GPU/Shader programming. So a big thanks and a real pleasure getting the chance to talk to you directly after all these years. Good luck on the game and looking forward to checking it out!
Following these steps, I’m none the closer. I created a blueprint for a Portal (Which loads the next level) but no matter what I do, I cannot connect the HUD to the Object, I can’t get either to talk to the other. I followed your videos on your site about Custom Events and also Event Dispatchers, but even referencing the HUD as a variable, debugging shows that it doesn’t make this connection. Even doing the variable as a class doesn’t work. Any ideas? Oh and just simply trying to draw texture from within the object blueprint is a big no-no. I’ve tried calling the HUD from Level Blueprint as well but it says no… Weird.
I figured out how to do it, so I’ll post here if future me’s or people in the same boat need a solution:
In your Player BP, Create a Bool (I called mine Level Changer). On the left hand side, click the eye to expose it to other places (Thank Hourences’ Tutorials on his site for that one!)
Now (In the player blueprint), create a OnActorOverlap event and cast this to your object that has the trigger inside it. Then simply drag from this cast to set LevelChanger (Or the name of your Bool).
Next step is go into the HUD blueprint; And away from your main BP timeline “Get Player Character”. From here, Connect this cast to your main Blueprint lines in your HUD blueprint. Add a branch after the cast. Now go back to the cast of your Player; Drag the blue icon and with the box that comes up, type “LevelChanger” <- Or your bool name. Don’t set it, just get it. Hook your bool up to the branch!
On the branch now, from the True node, Hook up a Material with your loading screen on it. (Bonus: Add a delay after this if it’s animated!) - If you’ve set up your screen X and Screen Y, You can use these to make sure the material covers the screen no matter what the resolution (See blueprint image).
Once you’ve drawn your material, simply add an Open Level node at the end, type in your level name and you’re done!
Hope this helps someone!
To totally plug Hourences: Don’t think about it, go and buy his tutorials. They’ll teach you so much and it’s explained so easily. All of figuring this out was thanks to his tutorials, and if you’re thinking about taking UE4 seriously then I highly recommend checking out his videos. Great stuff! I know people are a bit funny about paying for tutorials, when there’s free ones popping up left, right and centre but for the quality of the tutorial as well as the sheer amount of stuff you’ll learn, it’s definitely worth it. I’d even stick my neck out there and say his tutorials are even better then the one’s found on the Unreal Engine Youtube!
Appreciate bud Sorry about the delayed reply. I’ve been real busy on the new game I’m working on at the moment. I appreciate you taking the time on the layout :D, it’s actually very similar to the one I did the other day. My problem is I want to be able to do this so that the CPU is not being blocked so I could have maybe an interactive loading screen. I have a couple ideas on a plugin I’m thinking of programming to take care of this and expose the functionality through Blueprints or do it by incorporating level streaming in a hopefully cleaver way to make it seem like this is happening. I also agree that Hourences has some great tutorials. Unfortunately, I just turned my back on my job as a Senior Dev for a big company and am taking a big risk to follow my dreams of getting a new game company started which has been my dream since I was 5 back in the early 80s. Needless to say, I am very strapped on cash and would love to spread the love, but at the same time, as a programmer and an artist, and past time UE3 developer ;), UE4 has been a dream and very smooth in the prototyping process. I’ve also been doing game development for many years so UE4 was extremely quick to dig in from the Blueprints down the C++. It’s amazing in my opinion how much Epic nailed the perfect tool down and it’s going to really make game development much more productive.
One thing I love is that Epic’s community for UE3, UDK and UE4 is nothing short of amazing and everyone is doing their best to help others out. Even though I don’t have much time while I get things together, I have plans to release some tutorials of my own on the forums and some plugins as well. At the moment, the only tutorial I released was about doing a multi-camera setup for player pawns up on the BP forums and I am going to release a plugin shortly that gives you full access to Joystick input on PC including support with up to 128 buttons and all the different axis, rotations, povs and sliders. I also have a Saitek X52 Pro plugin that can control the LEDs and write text to the MFD but having a bug or two with the string encoding at the moment and I’m thinking about sharing that one on the forums as well.
Anyways, good luck as well on the future UE4 tutorials and community support I’ll have some more to show in soon regarding the game I’m developing and looking forward to seeing more of what you guys put out as well. Take care and enjoy the week of anticipation leading up to E3!
New: StreamingPauseRendering allows some rendering to continue while blocking loads complete so that the game does not appear to hang. Default is to display the previous frame with an animated widget in the corner. This can be overridden by providing a custom BeginStreamingPauseDelegate and EndStreamingPauseDelegate.
This sounds like it’s exactly what I am looking for.
But surely by the sounds of it, it’d only load on the current level, but not on the actual switch-over? Sounds good for a huge level which is broken into chunks ala Halo but how would this work for a game with two seperate level / maps?
It’s possible but depends on if the context of what they mean by “blocking loads” only refers to content within the current persistent level or is it in general with any backend loading. I’ll have to investigate this soon once I get things up and running on the new 4.2 build but working on getting some issues with some plugins worked out before I can dive in. If anyone at Epic could clarify if this would work when calling “Open Level” so I could have the current level continue to render and potentially take input from devices while the new level is being loaded into memory, that would be great. An example of this is an interactive loading screen or one that can display moving content, thanks.
Also, on a side note to the Epic devs, I know a lot of game companies use videos as loading screens instead of actual rendered content and I can see it’s supported on Xbox One currently in the release notes, is this feature also available on PC as well? If so, how could I take advantage of it.
Well the answer would be a Flipbook animation (Which is possible for even really long videos), that plays on a Material that is drawn on the screen as the levels behind unload and load in. I’m not sure how to get the whole “Keep this from hanging” which is why I’d interested in more information about this StreamingPauseRendering.
I really appreciate you trying to help but I hate to say it but you are wrong and that would not be a valid answer for my solution I am trying to achieve. If you are referring to the flip book to play out like a video would at lets say a constant frame rate like 30fps, then unfortunately that would be a very inefficient way of doing things and I can almost guarantee that no ones does that simply due to the added processing of not using a video codec along with any additional compression you would be foregoing not too mention the additional cost in memory and storage space on a per frame basis. Also, to sync up the frames would be a nightmare to ensure they are delivered at a constant rate. Now, if you wanted to do something akin to Metal Gear Solid: Ground Zeros where you have a loading screen and can advance, their case pages of text but that’s not what I am trying to achieve.
The way it works is that most games nowadays are multi-threaded. You could lets say have your Rendering Thread execute in parallel to the thread that is responsible for File I/O which would in turn allow you to continue to run while loading doesn’t have any effect or in the case that they describe in the release notes, “make your screen hang”. Because they said that it is there to alleviate “Blocking Loads” gives me the impression that it is exactly what I am looking for and not specific to just Persistent Levels. I’ll have to wait to see what they say on that one or test it myself once I get past a couple bugs.
Also, in most games, they play a movie while loading is executing. A couple great examples of this are the Mass Effect 2 or 3 and Halo 4 loading screens. This stated as documented for Xbox One but I am also curious if this is easily achieved at the moment on PCs.