World Partition And Data Layers - Unreal Engine 5 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys mizo frizzo here and in this tutorial I'm going to be talking to you about world partition and data layers World partition has basically supplanted levels and Su levels as unreal engine's way of streaming your environment to optimize your game so in this tutorial I'm going to be showing you how to convert a level from the old system to World partition and I'm also going to be showing you how to stream data layers at runtime which has changed a little bit in 5.2 I believe it was and onwards um it's a little bit trickier than it used to be but I'll show you how to do that and just as an example here I have this free asset pack from the epic games Marketplace it's a free uh Factory environment asset pack and if I just press f8 to eject here and move up you'll see I've got the level right here and if I move back you can see a little bit of it streaming in and out with the world partition I basically made the load range uh big enough to load the whole area um but if I go back to my character here and I press L you'll see some stuff has popped in there I press f8 to eject again and what you'll see here is I've got a whole copy of the entire level over here and it's on its own data layer so I can load it in and out by pressing L on my character and what you'll see if I go back to my character here I unload that data layer is I've got a certain number of frames per second that I'm able to generate at the moment so you can see it's uh if I just go over here and face the wall you see I'm pushing about 140 frames per second here and if I load in the other data layer you'll see a marked drop as it loads in and then it's dropped down to about 122 frames per second so again I'll unload that data layer and it's pushing now 136 137 frames per second and when every single frame per second counts in optimizing your game obviously you wouldn't want to have an environment as complex as this uh you know loaded in just over there there where we can't even see it or run through it at the moment so uh yeah this is where optimizing your game really comes into play uh so without further Ado guys let's jump into World partition and data layers all righty guys let's start by just converting a level to World partition so I've got this uh free asset pack from the epic games Marketplace a free Factory environment and a couple of uh telltale signs that this is using levels and suble levels is one down here in the bottom right corner of the viewport you can see current context demonstration level persistent so uh this persistent is basically the base level for your level with Su levels within it if I go up here to window and open the levels window you'll see right here persistent level and then I've got this sublevel Tech art which is the Sparks and a few other things um if this had World partition enabled this would say that levels is disabled because World partition is enabled and if I go to the world partition tab you can see World partition is disabled for this map um so if I want to convert this to World partition sometimes I might get an error saying that you need to resave the map app and that can be a little bit uh you know uh not a little bit misleading um you know you could change something in the map and and then save it again you'll still get this this strange error so um I haven't figured out a way of actually resaving just the map because there's no options here for example that say resave but one thing I found that works and that uh you know removes the potential for any of these errors so that your conversion works first time is just to right click on your content folder and go resave all so that's the first thing we're going to do this might take a couple of minutes so I'm just going to cut to when this is complete so I'm going to hit resave all and now that that's done um I've got some warnings there um just going to dismiss all of those uh now that that's done let's convert this to World partition so um we're not going to need these levels this levels tab uh I am just going to go to tools and convert level I'm going to find the level I want to convert which for me is in maps and demonstration open this up and this basically is just saying do you want to replace the original map so yes I'm just going to replace it and I'm going to leave everything else as default and hit okay this may also take a minute so I will just cut here to when it's finished and that is done now you might find that parts of your map uh haven't loaded Don't Panic what we need is this world partition tab or window and if you don't have this already what you can do is go to Windows and uh where is it World settings World partition World partition editor and while you're here you may as well open the data layers outliner window as well I've just got that one docked up here data layers and I docked my world partition window down here and what you want to do is just select the whole area and right click and load region from selection that's going to load up everything like so nice and now if we go to to our world settings um window right here and again if you don't have World settings you can find that in window and World settings right here you should have this and down here in World partition setup and runtime settings you'll find this grids right here and you can drop this down and drop down this index and you'll find the main settings for your world partition streaming right here if we check check preview grids what it will do is show a preview of your sort of cell size and your loading range so right here we can change the cell size if you wanted to make this more sort of specific and load up small bits at a time you can change the cell size there you can also change the loading range right here so I'm going to jack this right up so it's just loading the whole level cuz it's not a huge level even though it has a lot of detail it's not a huge level you can basically see from sort of one end of it to the other um this is just a level that I'm using as an example so preview grids can be a little bit distracting so I'm just going to switch that off and nice now we have World partition enabled on our level let's jump into Data layers so we opened our data layers window right here and you'll see we've got our level here demonstration and if I rightclick here I can create a new data layer or create a new private data layer and you'll see if we highlight create new private data layer it says an editor only data layer that cannot be used by other worlds so this is Handy if you don't want to load everything up when you open up the editor you don't want to load everything up right away or maybe there's certain things you don't want to load at all so you know you might create a data layer like this a private data layer and then you could grab say for example all of these things that are kind of like background um this is just for example uh let's have a look at what that's called background pipe so what if I search for background here and find everything with background in the name and select select it all and then go to my data layers here and right click and add selected actors to selected data layers all of these background items are now in that data layer I can hide it like so and then you can see all of my background is hidden like so so maybe when you start it up uh start up the editor you don't want everything to load just so that your editor starts up more quickly this is an option that you have and let's just find What's this called grow smoke I'd call that a background uh background effect as well so let's just select all of these grow smokes right here and add selected actors to selected data layers and they will disappear because this data layer is hidden like so um this is this is loaded as well so you can also just unload it so they're not even loaded right now so you won't be able to make them visible you can just click to load it and click the little I icon to make it visible and you can also see there when I double clicked on it which was an accident by the way uh it makes it the current data layer so I believe that means that when you place an object it will be in that data layer so let's just place a cube right here place a cube scale it up so it's a bit easier to see yep so that's that's how you would work within a data layer if you wanted to if you were creating this level from scratch and you're adding a bunch of stuff in you wouldn't want to then have to select everything thing and move it to the data layer you can just double click on that data layer and it will make it your current data layer like so nice um there is a problem here I'd like to point out in 5.2 and onwards and it is that if I rightclick up here and just create a new data layer it will say unknown right here and it's because there's no asset assigned to this data layer so so it it simply just won't work and it won't work at runtime either which is uh pretty annoying so you can assign a uh an asset to that data layer but I think it's easier if you just rightclick and create one the uh the data layer asset and it is in miscellaneous and data layer right here so I'm just going to leave this called new data layer asset and then I'm going to open it up up and right here I'm going to change the data layer type to runtime and save and close that and then drag that into wh I've crashed the editor uh let's just restart the editor um that has not happened to me before but I have heard reports of data layers crashing from time to time so let's just load everything up again and you can see my my private data layer is gone as well that didn't save nice thanks unreal um that's all right we don't need that private data layer I was just showing you that uh you know how it works so I have got my data layer asset here I can drag that up here and now it's in my data layers tab right here under the level so it is now a part of the level and this is a runtime yep it's still saved as runtime just double check in that um so now we can stream data layers in and out at runtime you'll see here in the data layer um details right here we've got the data layer asset right here oh let's see if we can create a new data layer and assign it data layer asset boom assigned like so okay yeah so that works you can you can assign a data layer asset right here that's all you need to do to get that to work um you'll see here there's editor options is initially visible and is initially loaded and that is what we were talking about with uh putting stuff in a data layer so your editor fires up more quickly so you could have it uh unloaded and invisible when you load up that is just an editor option but then here we also have the runtime option initial runtime State you've got unloaded loaded and activated unloaded is self-explanatory it's not loaded at all uh loaded is it's loaded in but it's not visible and activated basically means loaded and visible so both of these are checked as true basically in activated so let's go ahead and add some stuff into a data layer let's take this office right here um you know this is we we can see this from out here but this is just an example of basically a su LEL so let's say you wanted this office here to be on a su level I'm going to go into the outliner here and search for office and these windows are the windows right here so I'm not going to select those I'm just going to select everything here in the office that basically isn't a window so there I'm going to select all of that there and you'll see some of it is indeed not in the office it's in these locker rooms down here um it doesn't matter too much this is just a demonstration of how this works so I've selected all of these actors right here and then I'm going to go to my data layers Tab and I'm going to right click on this data layer and add selected actors to selected data layers now you'll see if I check this visibility icon it is hiding everything in that data layer and let's say you did have a level that you've already made like this very complex level with lots of actors within it and you you did want to not just hide this stuff but you wanted to hide and unload sort of everything in here so you can see I've hidden that and there's some stuff remaining but let's say you wanted to you know you wanted to also add this stuff to the data layer so it's hidden I could select all of that like so and I'm not going to select absolutely everything but let's say I've selected this stuff I can right click add selected actors to selected data layers and you'll know that it's been added to that data layer cuz is Now hidden so you could go through and you know keep on adding stuff to the data layers like so um what I mean is is that if you can see it still it is obviously not in that data layer so if you wanted to continue finding stuff to add to the data layer you can do it that way okay now let's have a look at loading and unloading this stuff atun runtime so we've just got this one data layer it's the stuff in the office right there I'm going to leave it as initially visible and initially loaded I'm going to change the run the initial runtime state to activated so that if we hit play that that data layer is indeed loaded I'm just going to find my character which I believe is in Blueprints and porn is this old ue4 mannequin and go to the event graph and I'm just to find the L key like so and what I'm going to find now is the data layer subsystem data layer subsystem can be accessed from anywhere um so this is how you'll access your data layers and then off of this if I just search for data layer again you'll see a few more data layer options and I'm going to set data layer runtime State like so I am going to just grab a flip-flop going to duplicate this one plug this in here and plug B into the second node and we changed it to loaded so we're going to make the first one unloaded and the second one activated like so and in data layer here we can just promote to a variable I'm just going to leave it called in data layer and I'm going to plug it into both of these and if I compile I can now set the default value of that data layer and I'm going to send set it to new new data layer asset like so um in is recursive we're not going to mess with that right now if you want to learn more about that I suggest you check out the unreal documentation um I suggest checking out the unreal uh documentation on any function that you'd like to uh learn more about there's a lot of information there very exhaustive um maybe not as exhaustive as some people would hope but uh there is a lot of information there all righty so now when we press L it's going to execute a and unload that data layer and if we press it again it's going to activate it so I'm going to hit play now and I'm not going to bother bringing up my frames per second because this is actually not going to make a huge impact on performance because this is a relatively small amount of uh data that we're actually hiding here um that is why in the demonstration I loaded up a whole another copy of this entire environment so that you can see the difference but if I press L here you'll see that that data layer is unloading and loading and you can add anything to these data layers you can even add stuff like lights so I could grab these lights right here and go to my data layers and add selected actors to selected data layers and now if I hit play just going to jump up here to the same spot so we can see up in there if I hit L it is unloaded you can see those lights as well now nice and if uh you wanted to do this to optimize your level you probably wouldn't just have it as an input for your character you would have a uh basically a box Collision that when you overlap it it would load those levels so let's have a look at that now what I'm going to do is just delete this door so that we can get through here and I'm going to add my box Collision right here that's going to load that level so all I want to do is create a new blueprint an actor I'm going to open it up I'm going to add a box Collision got caps lock on there sorry about that uh grab this box and I'm just going to scale it up a bit make it nice and narrow and I'm going to move it up so that the root is down at the bottom like that and I'm just going to drag this out to see the size that'll do that fits uncannily well into that door um I might just make it a little bit taller so that we can't sneak over the top very nice and I'm just going to go to my character here and I am going to copy this like so contrl C go into my blueprint I'm going to right click here and add an event on component begin overlap going to paste in these nodes whoops I've just hit contrl C again CR X that's fine paste this stuff in here and if I hit compile I'll probably get an error about this no didn't get an error about that uh variable strange in data layer I'm just going to create that variable again and new data layer asset plug this in so I'm going to activate it when I overlap and I am going to change the initial runtime state to un loaded like so and I'm just going to right click here go play from here I'm going to delete that play From Here and Now when I overlap this box right here I've loaded in this data layer like so and you could make it so that uh let's just have a look at this blueprint I'm going to make two boxes so I am going to duplicate this box and box one I'm going to move just a little bit over like that and just so that we can see which one is which let's also add and arrow component and this first Arrow component I'm going to put on this one scale it up a bit and I'm going to also duplicate it and the other one I'm going to rotate around 180° put it over on the other box like so and I'm going to make this one blue and this is going to be the one that loads in the level and this one is going to be the one that unloads the level or data layer so I'm also going to add this event on overlap of the other one I can copy this plug in the data layer and the subsystem and make make this one unloaded so when I overlap with this box it's going to activate that data layer when I overlap with this one it's going to unload it completely and that is the way around that I would like it to be because when I walk in I want to load it and then if I walk back out I'm going to unload it you could make this slightly more performant by having this blueprint contained within a certain dat data layer so that for example when this office is unloaded uh the blueprint is unloaded and it wouldn't trigger um that's up to you to you know fiddle around with that for optimization but I'm just going to have this one blueprint and it's not contained within the data layer it's just contained within the level um but yeah that should work now so if I right click here and go play from here now when I walk in this data layer is activating and when I walk out it is unloading like so nice guys that's pretty much all we set out to do so that's it if this tutorial has been of any use or value YouTu whatsoever please hit like And subscribe and I will see you on the next one
Info
Channel: MizzoFrizzo
Views: 930
Rating: undefined out of 5
Keywords: optimisation, loading/unloading, load and unload, streaming, open world, blueprints, how to make a game, make your first game
Id: lkjlP0Y4zvc
Channel Id: undefined
Length: 26min 33sec (1593 seconds)
Published: Wed Mar 06 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.