How To Load And Unload Sublevels In Unreal Engine 5 | UE5 Optimisation

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys and welcome back to another Unreal Engine 4 and 5 tutorial in today's video what we're going to be going over is using Su levels to load and unload different areas of your map to really help optimize your Unreal Engine games so let me hit play and show you what we're going to make today so you can see we have this level loaded if we're going to walk over here to this little Archway what you'll see is as we enter it the another level is going to load and as we come through that other level will unload and if we to go back that will load back in and this one will unload now obviously you can see it happening what you you wouldn't normally want that in a game main reason why I've done that is because I want to show you it actually working and because the only other thing you'd need to do is just create a little Alleyway here and make sure you load here and unload here for example so you can't actually see it changing and see it happening but for the purpose of today's video I'm not going over that because it's very easy to do all you do is just move the different things to different positions I'm going over the functionality not the level design now this topic can be a little confusing for beginners so please do let me know on Discord or email if you haven't understood it and I will help you out further and you might also be wondering why using Su levels instead of world partition in ui5 and that's just because for a larger level World partition you probably should go for especially open world but for a more confined level and smaller levels especially ones that aren't open world you don't really need to necessarily do World partition doing different sub levels like this is perfectly fine especially for team collaboration as well this works amazingly because you can all work on different levels but without further do I've talked quite a bit on this intro this is what going to be going over and creating today so let me delete all this and I'll show you how I've done it so what I'm going to do first is go to my content browser right click create a new folder name this Maps just so I have somewhere to nicely and neatly organize my folders so I can put everything in one place so I know where it is what I'm also going to do is I'm going to going to create a new level to do this in now if you already have a level where you want this that's fine I'm going to create a new one so I'm going to go to file new level and I'm just going to create a basic level here I'll create that and then you can see we now have a basic level I'm going to control s to save this and I'm going to put this in my new maps folder here and I'm going to name this one World Main now World terrible name for it but that's what I've got and then I'm putting main at the end or you might want to do persistent instead so this is the main level where all the other Su levels are going to be held so I save that like so and now I'll get rid of this tab here so what we want to do now is we want to get the levels tab which you saw I just closed so if you don't have that we're going to go to window and then levels and then we have this levels tab here it may appear somewhere else for you you can drag it where you want but we have this here and what you should see is we have a persistent level here this is what you ordinarily have anyway way but we're going to actually utilize this with sub levels too so we have a persistent level what I'm going to do is just above the persistant level we have levels we're going to click that and we're going to create a new level I'm going to create an empty level as I don't want any other lighting as that's in the persistent however you might want different lighting scenarios for different levels so you might want basic choose which one makes most sense for you and we will create that and I'll name this one for example World sub LEL one one now you can name these whatever you want for example you might have the world main be outdoors and then this Su LEL might be house one for example but you can name these whatever you like for what makes most sense for example if this specific level is going to house certain things it might make more sense to name it like that use a nameing convention which works best for you and we will save that like so and now you can see it appears under here like this now in the bottom right of our viewport we you can see we have level World Su L one and we can click on that and switch to persistant and so this is going to show which one we're currently working in I want to work in the world sub level one and what I'm going to do is just create some stuff so actually let's go back to the persistant real quick and I'm just going to modify this make it slightly smaller just so we can make some nice changes like this so let's make that nice and small like so in fact what you could do is get rid of this entirely if you don't really want many things in the persistent level I'm going to keep this here anyway and then let's switch back to the world Su L one what I'm going to do is just duplicate this so I have a different floor here and you can see in the bottom right it says selected actors in World Su Lev one if I click the other one it is in World Main persistence that's how you can tell which different level everything is in as well so I'm going to get this here like so then what I'm also going to do is let's just get some more cubes on here so this is going to be very basic stuff that I'm doing here just to show it off just so you get the examples of it I'm just putting stuff in the level so we can see it there's no real level design here that I'm doing I'm just making random stuff like so you can see all of this is in World sub Lev one but now what if you already have a level created which you want to add into this well that is possible what we can do is we go to levels and instead of create new we can add existing and you can see we now have access to levels here what I'm going to do is go to third person Maps third person map here open that up and that has now been added you'll see that we can't actually see it and I believe the reason for that is because this default third person map has World partition enabled which doesn't work with this so that wouldn't actually work so I'll get rid of that and then create a new one the reason why I still added that is because then I can show you how to delete a level what we can do is we can right click on it and then just simply remove selected press yes and that world is now gone so I will save this and then I'll create a new level in here I'll create a level and I will name this world sub level two and if we open this up you can see obviously it's completely blank if I add in let's say for example just a cube like this and I'll make it quite big so we can tell I go into unlit you can see we have this Cube here in this world I'll save that go back into World Main go back to LIT mode and then we can go to levels add existing and then we can add in World sub LEL 2 and it's now in here like this now this might not be where you want so how can we move it well if we click on world sub level two and then press this little pen icon here for summon level details and move this onto the correct monitor what we can do is we can change the position it's currently in so we can move it to be 500 on the x 500 on y and and 500 on the Zed for example so that is going to be moving it so we can move this to be absolutely wherever we want it to be perfectly like this so let's say we want it to be about here maybe down a little bit as well just like that and then we'll close this and then you don't have to open the other level to edit it again what we can do is just change the level down here to World sub level two which we already in and then we can still modify this as we normally would as we were doing before as well in World Su Lev one so this is now going to allow us to have these different Su levels now if I were to press play what we can see is those levels aren't there and now that is good because they are acting as Su lels you see on the right down here they are unloaded if we go back to that summon level details icon you can see we have initially loaded and initially visible if we tick both of those for World sub level 2 and then press play once again you'll see that that level is now there and on the right here we can see that that is loaded you can see it because it's not grayed out and it has an open eye next to it to show it it's visible so that's all perfect however what if you want these to load in the game because that's really the point of why you do this is to optimize it so you can have the levels unloading and loading while the player is playing the game so what I'm going to do is make sure that I untick initially loaded and initially visible again and if we right click on it change streaming method and it should be blueprint by default you want to make sure that it is it's not always loaded we want to do blueprint and then what we're going to do is we're going to create a new blueprint so if we go to our content browser and then let's just create a blueprint here so we create a blueprint class actor and I'll name this BP load and unload or whatever it is that makes most sense for you for example this might be a door so you open the door it loads in something on the other side and as you go through the door closes and unloads something on the other side so set that up how you want for me I'm going to do a box Collision again that would be the same for the door however you'd have a door on there as well so I'm going to add in a box Collision in here and then I'll compile and save that and I'll go to the event graph here what I'm going to do is delete those three nodes right click on the box Collision add event and add on component begin overlap what I'm going to do in here is then drag out of this and I want to load stream level by name and then this level name here is going to be the sub L that we want to load for example let's say we want to load sub World sub L one make sure you spell this perfectly correctly so we'll do World sub level one and we want to tick make visible after load as well so we can actually see it so we'll compile and save that now if we were to drag this into the level when we walk into it this will actually load this new level so let me also scale this up to the how I want it to be and you also want to make sure that this is in World Main persistent or a different sub LEL for example if we have this sub level here and then another one after it I could put this BP in World Su L one I'm hoping this will Mak sense and if there is more things you want help understanding feel free to message me on Discord or email me and I'll be happy to help out but if we press play we can see if we to walk into this it's going to load in that Su Lev perfectly like so now obviously I'm not done with this blueprint I'm just showing you that basic example there so if we were to open this up again what I'm going to do is go to the viewport and I will now actually scale this in here instead so let's make a very simple Archway I'm not going to use an actual door I'm just going to create an arch so let's do something like this along these lines again very very simple just to get the idea across so we have something like this so if we get this box Collision now and we to move it here on the front side example let's make this big enough like so when the player walks into this it's going to load something on the other side perfectly like that so we'll name this one entry box and then we'll duplicate this and move it to the other side and we'll name this one exit box now just so we also know which way around this is in game as well what I can do is I'll get an arrow and then we'll place that facing the way we want to be the so for example I'm going to rotate it this way as I know that the the way the arrow is pointing is the front you may decide to do it a different way so you do it on the other side for example you're going to be going through that way so the arrow is pointing the direction you're going through but for me I like to do the direction the arrow is pointing is the front side so if we compile save and go to the event graph we can now also right click on the exit box add event add on component begin overlap and unload a different level so what we can do is unload stream level by name and then we just do the same thing we did here so for example here I could do World sub level one so what I'm actually going to do is make this one load World sub level two and if we compile and save what I'm going to do is reset this size here and then also I'm going to move World sub level two to be over here so I'm just changing how I'm doing it to make it make a bit more sense for you so if we go back to levels panel summon the details for World Su L 2 we can move it all the way over to where we want it to be and if you click on viewport edit you can actually move the whole level like this as well if that's a little bit easier for you which I imagine it probably will be so we can move it like this so now we have the level where we want it to be if we unclick viewport edit that will then be saved like so and then you can obviously do some more editing what that you want to do for example I'm going to actually move move this a bit further back like this and also make it a little bit bigger I also move this over and then what I'm going to do is move my doorway over to here so I'll do that move it down and then I'm going to click on world one open the levels panel and then I'll make this one initially loaded and initially visible and I also want to make sure that I rotate this the other way as again this is the forward direction for me so now if it to go back over here and press play you can see that this level is already loaded in automatically if we to go over to our doorway it's going to load in the other sub level and as we walk through it will unload that Su level perfectly like so and that is now how we can unload and load different levels like that now obviously that's only going to be going one way so what you then want to do is create another one of these in the other level so for example if I had to move this over here so it's directly in in between them and also make sure that I move this into the sub Lev one so how can I move something if I put it into the wrong level if I select it and right click onto the level I want to move into for example World sub level one we can then move selected actors to level if you look in the bottom right here selected actors is in World Main persistent after I click this it's now in World Su L one so that works perfectly what I'm going to do now is go into World sub L 2 and duplicate this so it's in there perfectly like so we now have this in World Su L 2 as well what I'm also going to do is go back into the blueprint move these over and then create and then make this a dynamic blueprint so I'm going to right click promote to variable on the level name and I'll call this one level to load click the eyeball to make it instance editable and then do the same on the unload so I'll do level to unload and again make that instance editable perfectly like so so now back in the level we can now go to the details panel when we select it and you can see which level we're loading and which level we're unloading so this first one we want to make sure we're loading Su l two unloading Su L one and then on the other one what we're going to do is we want to load Su L one and unload Su l two however again we're going to want to make sure that we rotate this around perfectly like so just like that but now also obviously these boxes might be overlapping a little bit so what we're going to do is we'll press play and test this out to see how this looks so this is all loaded in we'll go over working perfectly that's now loaded in we walk through that's now unloaded that worked great if we walk back over here that one loads in we walk through that one unload so this works perfectly and because I've put the doorway in the same position it doesn't look like it's actually changing even though it is so this is how we can perfectly load and unload different sub levels to really optimize our game and again if I were to go to the levels tab over here you can actually see them loading and unloading in real time in the levels tab as well so you can see what it's actually doing behind the scenes now obviously you can actually see all of this working which you probably wouldn't really want and that's just because I've done it like this what you would normally want to do in a game is probably put this in an Alleyway or going around a corner or through a corridor or anything along those lines so you can't actually see what is happening I've not done that today just because that is level design as opposed to actually functionality I'm just focusing on the functionality today of actually loading and unloading the different sub levels as we have done here and this would work the same way as well if I wanted to do it differently so if I click on summer level details for sub level one and make that not loaded invisible but then go on sub level two and make sure that is this will again still work if we click on here this level is now loaded the other one isn't but we walk over here that will load in and this one will unload perfectly like that so I think that will be it for this video as we've done everything we've wanted to do what we've done is we've gone over using different sub levels in Unreal Engine 5 so that we can load and unload these different sub levels like so which will really help to optimize your game and help it work a lot better I really hope this video wasn't too confusing for you I know this can be a difficult topic to get into so I hope that I have explained it well and if I haven't then please do make sure to let me know and I will further explain it to help you out or if you think needs to be I will make another video as well so thank you so much for watching this video I hope you enjoyed it and I hope you found it helpful and if you did please do make sure to like And subscribe down below so thanks so much for watching and see you in the next [Music] one
Info
Channel: Matt Aspland
Views: 5,053
Rating: undefined out of 5
Keywords: ue4, unreal engine 4, unreal engine, tutorial, ue4 tutorial, unreal engine 4 tutorial, how to make a game, how to, blender, unity, games design, ue5, unreal engine 5, unreal engine 5 tutorial, ue5 tutorial, how to change, how to fix, modify, fix, ue5 optimisation, lag, laggy, editor, optimise, optimization, ue5 optimization, sublevels, sub, level, sublevel, load, unload, stream, world partition
Id: z5Yjnr7ryuA
Channel Id: undefined
Length: 17min 52sec (1072 seconds)
Published: Thu Feb 15 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.