UE5 - Level Streaming, Entering Buildings with Transitions & Simple AI Move to

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] foreign welcome to this week's video This is actually the first video of this year I do apologize for that but if you want to know a bit more about that um hang on to the end of the video and I'll explain a little bit however this video is going to be about level streaming uh level streaming is great it's where you can have multiple worlds within one larger world but then load them in as and when they're necessary so for example enter in a building so there's a quick example here which I've knocked up so you're logged into sort of the default top-down map I want to go inside this little building here but from a top-down perspective that doesn't really work so we'll go to enter the building it runs Us in little um little transition there and then we load into a separate level a separate world but it's all housed within sort of a greater world and then when you want it ready to leave you can just transition back out um and I'll just explain quickly here what's going on in the back end so you can see here we've got a like a whole world which we can just switch off so there's no world existing and then at any point we want to load in the rest of that building we can load it in and unload the world and we're left with just that building um and that's what we're going to go through today so stick around and let's just jump straight into it okay so I've just loaded up a brand new top down template and what I've also done is I've just opened up the levels um window now you can do that by going to window and selecting levels at the top now there is a chance that you have World partitioner open by default you can close this um levels sorry level streaming and World partitioning are slightly different um just a quick differentiate the two World partitioner is probably better suited to really large open maps stuff like GTA and stuff like that um whereas level streaming is probably better to be used in small to medium now that's not to say that either of them can't be used for the other Maps so you can use World partitioning in a small map it's just you'll probably find there's a lot more work involved for what it's worth um whereas levels it can be set up quite quickly but as your world gets really large it can get a bit more complicated um so that's that's probably where the two have been made for um levels I'd start with levels as the game grows I'd probably consider switching to World partitioning but if you know your world is going to be massive just go straight for partitioning and if that's the case that this video is not for you so we've got levels open and we're going to make just a simple transition so to explain this best [Music] um we're gonna we're gonna take all of these assets and we're gonna we're gonna make a world with it now you can see here that um levels or level streaming is disabled when World partitioning is enabled now that's because the default world that you get spawned into or is opened in the editor has partitioned and enabled so what we're going to do is we're going to create a different level uh without it and but we're going to Tech all these assets with us so we're going to press Ctrl and a and we're going to just copy everything on the map and then we're going to go file new level and you can see here we've got open world or basic now open world will have partitioning enabled by default so this is not what you want whereas the basic levels have don't have it so then streaming will be enabled or you'll be able to use streaming so we're going to select empty level which is a basic level I'm going to hit create and as you can see the level window is already updated with all this information this is now what's con considered a persistent level which is almost like the parent level and we can add children to it so what we're going to do is we're just going to go file save as we've got to top down and maps and I'm just going to save this one as persistent and then what I'm going to do is I'm going to create a new level but underneath the levels so I've got a level create a new I'm going to create a new empty level and we're going to call this one world and then within World make sure that you've got it double clicked and it should say level World here and then we'll just paste in and if you've done everything right so far you should have pasted in the top down template that we had just a moment ago and if you click this little toggle level visibility button here and click that everything should disappear and then the world should come back now if you was just to press play right away you probably just fall through the year but you can't see that but you are falling through the air because this world has been set up automatically to be enabled by blueprint so to change that we can right click and we can change the streaming method to always loaded what this does is when you press play it will always be there now you can turn it off using blueprints that's absolutely fine it's just as your sort of first area to run around in it's probably best to have it always loaded now you might be asking why didn't we put it in the persistent level um now this is possibly perfect personal preference but I typically well it is personal preference I typically like to have an empty persistent level so that's completely blank it doesn't affect anything whatsoever um on some games I've possibly put in the lighting so the lighting's consistent throughout the entire game but when you're going sort of like in buildings and um outside buildings you might not want to do that so what you could do is let's close out of that for example with the world selected you could select all of your light in here press Ctrl and X which will remove it and then go to your persistent World by double clicking and just pasting it back in you so now if you turn your persistent World off your game world's still there but there's no lighting but vice versa if you turn your world off your lighting's consistent so if we just create a new world now let's create a new empty let's call this uh Zone one Zone one and let's say we get rid of the world and we just have Zone one and the lighting is going to be the same no matter what we load in and what we don't so that's that's a useful thing for me um because we've got the lighting now on the persistent so now we're in zone one what we're going to do is we're just going to select the floor from world one and we're just going to copy and paste so now we've got a floor in zone one if we hide the world and what I'm going to do is I'm just going to drag this all the way to the right get the world in and we'll just overlap it just a little bit just like that and then what I'm going to do is I'm just going to delete this wall for the time being with inside the world what I'm going to do is I'm going to find the nav mesh bounds I'm going to drag that over to this side and essentially what that does is actually sorry I've made a mistake though we don't want to do that we want to copy the nav mesh bounds go to the Zone one and then paste and then what we'll do is we'll drag that over the reason we're going to do that is because you'll see that the entire area is now covered by a nav mesh but if we remove world one our zone is still going to be accessible so we can move that over and you can see our Zone one is still going to be accessible using navmesh so let's press player and let's go over here and you'll notice whoa someone's not there and that's because we've not told it to loads on one just yet so let's let's do that now what I'm going to do just to help me out a little bit here explain things I think the camera's just a little bit too zoomed in and it doesn't really help so I'm just going to increase the spring arm length to 1750 and hopefully that's a bit more zoomed out and it'll give you a bit more to look at as we as we're running around so we go over here and you can see that as soon as I get over here the nav mesh just doesn't like the fact that there's nothing there okay so here we are what we can do um inside the world so double click World make sure that you are in in World we're going to create a volume and we're going to create a trigger volume now that looks like it's close to the screen but it isn't so I'm just going to drag that over drag that down there I'm going to press the end key and drop it down to ground level if you press the End Key what it'll do is it'll drop whatever you've got selected until it hits any surface um which is very useful we're going to find where our world ends which is on this line so that's fine and then what I'm going to do is I'm just going to try and get this Cube let's trigger volume to sort of fill this whole area something like that so there's no way I can run past the way out going through the trigger volume now you wouldn't necessarily do this because you wouldn't want this to um this is going to look quite abrupt when we hit this trigger volume and we tell the Zone one to load in it's just going to go and it's just going to be there um you're probably going to want to hide this with like a building or a doorway or a transition but we'll get to that this is just an example uh for for visual purposes I guess so now with world one selected and the trigger volume selected so I just select your trigger volume we're going to open up the level blueprint so you can access that using this little widget here and that's a pretty neat feature actually about levels is that you can go into the blueprint of any level that you've got within your hierarchy so let's go into world one and what we want to do is we want to create an action when somebody walks in to that trigger volume so to do that we're going to right click and because you've selected it in the level blueprint it gives you the option to to use that trigger volume so we're going to add an event it's going to be based on collision and it's when an actor overlaps it so let's just get rid of those two for now and just focus on this now the actor that I'm concerned about hitting it is myself so what I want to do is cast to top down character now the reason I'm doing that is because if this cast fails I know it's not my character if it succeeds it is now in a multiplayer game you wouldn't use this I don't know what you'd use you might cast a character and check to see I'm not too sure um this is just a good way to make sure it's only you the player uh going into it um yeah pretty much I guess on a multiplayer game you may want multiple people to be able to go through it so you might be able to cast to character or something like that anyway so once this is triggered we want to check to see if the other actor is um our player we can connect these two if that's the case what we want to do is we want to load in a streamed level so load stream now you can either do it by name which we know Zone one or by object reference and the good thing about object reference is it gives you a drop down of every level that you've got so you can just pick it and then you've got the option of making it visible after load or or not now I typically always do it just makes it a bit easier and let's see if that works so let's compile let's play so we'll run over here and then when we hit our trigger volume our second area now loads now because that nav mesh was there or we copied that nav mesh over into the second area it it allows us to uh navigate this area now absolutely fine now one thing I want us to be aware of when doing this um is the num meshes are actually static so let's say something changes whilst you're playing the nav mesh One update to go around it um so the best way I can explain this really would be what I'm going to do is if I've got a Zone one to get rid of my world for a second I'm actually going to remove the nav mesh if I go back to this um world now you'll see that my nav mesh ends here I get rid of the zone but I select my nav mesh and drag it over I'll tell you what over to there when the zones there it loads the data but when it's not it doesn't so what I'm going to do is I'm going to press play now now remember my nav mesh covered that area but the floor wasn't there so if I now in the level load it in mine my um sort of moved to doesn't want to work because something's changed when I press play on the game that floor wasn't there so it hasn't it hasn't loaded that floor into its memory so it doesn't actually know how to walk over there like it doesn't exist to it now granted if you press and hold the mouse you kind of force it to go in that direction but that isn't right if you're going to have Dynamic things in your world and you need it to update live there is something you can do now if you scroll down um in your outliner you should find a recast nav mesh default now basically this is all the data of the area is captured so if you can see this green area this is the nav mesh bounce this is what it can see as an area it can move in and when you press play this is the data that it works from but it's not Dynamic by default if you go to the details or put the top and scroll down now bear in mind you need to have the recast nav mesh selected for this if you scroll down you will find run time eventually and you can change the runtime generation from static to Dynamic now what this does is every time something changes in your world it allows the nav mesh to recalculate this will have a hit on your performance now I've made some somewhat I wouldn't say really big games but some larger games and I don't see a massive performance hit but if you've got a lot of dynamic lighting and you're loading in quite a lot of sort of moving parts that are going to need this to up there I can't I can't say for sure that you're not going to see a performance here you'll just have to try it and see now if you read up online there are ways you can work around this a little bit but I don't find them to work well enough for me um to use them so I try to keep things as static as possible anyway if we now press player and do the exact same thing now bear in mind this is now Dynamic so if I run into this and it is now just dynamically updated and we're good to go so you can see though that that really didn't make any performance visual but this is a really really small setup so just work with that as you will now what I'm probably going to say is it's probably just a good idea just to have enough mesh in each Zone just so then that data's there so when your character moves into the new areas it's not expecting anything um unusual let's say so let's continue so now we've got this kind of um this Zone loading in what I'm going to do is I'm going to find where my camera is so I'd say about so when my camera is in between these two posts this this this world or this this new Zone isn't visible so what I'm gonna do is while I'm here I'm going to trigger this new area to load so then as I get a bit further down I don't see Blue Sky in the background now in the example I used a building so we went in and we transitioned we'll get to that in just a minute but what's probably best you're better off doing um is if if you're going to use this for like non-building areas is try and find a way of um sort of adding like a little path to your game where it separates the two large areas from each other so quite like a very simple path that you could just walk down it's quite out in the open let's say or um quite small but it gives you a good opportunity to unload the big area that you've just left and then load in the new area um this is more evident in third person games or first person games where when you go through a doorway or let's say if you've ever played like Warframe you go through um a portal or you go through doors and then it leads to another door you're kind of in like a a separated chunk of map so while you're in that they can load the next area and unload the previous area so you're only staying in each chunk which is pretty neat anyway enough talking let's get this trigger volume move so we'll move that to about there so now if I run over here I don't even notice it like it just seems to be one consistent map so I can do the same over on um on Zone one which I think I've actually put this oh no I've selected an actor in world one that's fine so what I'm going to do is I'm actually going to copy this uh this actor will be placed outside the bounds of the current level so let's not do that let's just select the trigger volume and copy it and then within Zone one we're going to paste so this asset should now belong to Zone one let's check that that's true and what we're going to do is we're going to try and find what position oh let's let's just copy that and then again I will paste that here what we're going to do is I'm just going to try and find an area of the other side where the rest of this map is invisible so we're not far off probably probably here so I'd say that's about why not so let's get rid of that and this one we'll select this trigger volume and we're going to go to the Zone one blueprint get rid of those right click we're going to add an event Collision on Activision overlap if this is cast to top down character so if that's successful I want to unload Stream So at the bottom unload stream level by object reference select that I want to unload my world and that's pretty much it so let's compile let's save so we'll run over here so my new zones loaded we'll get over here a bit further and I just quite saw it in the top corner but the other world now has disappeared um and I don't think we put that nav mesh back in did we because we've just deleted it so let's just check that ends on one do we have a nav mesh we don't but we do have a recast however that's not great that's got to world one let's find the nav mesh copy that got us on one paste that in um and obviously it's absolutely massive now we don't need that covers that that's fine let's find the other nav mesh and we don't need that to be that big anymore do it so that'll be fine like that hit player run over come seamless let me run over here we see our world disappears um and now another mesh has persisted so obviously we've just unloaded it so when we run back it doesn't exist anymore um that's where doorways are pretty good because then you can have that doorway stay shut and we can we don't have to see all the sky around it um yeah so let's work on a transition so I do apologize I've not built out sort of like the building stuff like that but um you can sort of you can improvise I just want to show you the basic bits um I've already recorded this video Once by the way um and with the building and everything that goes along with it it ended up being like an hour and I don't really want to keep you here for an hour I'd rather to show you the elements that you need to use and give you some tips along the way where you can sort of build anything with it rather than you can only build that doorway [Music] um so yeah let's continue so now what I want to do is I want to get this a little bit closer but I want to create a transition so the screen goes dark for a second as we as we load that news on that will be useful for when you do doorways because you can approach the door load the room behind it and then unload the world and that only takes a couple of seconds so it just looks like a going dark like the example at the beginning were um I shot a clip of it now well you run inside it goes dark and then when you're inside the lighting of that building takes over instead so let's move these that was a good timing because of the saving but let's move these trigger volumes uh world one trigger volume let's move that a little bit closer now if I remember rightly Zorn one's floor is just about there so let's go for the first one so it looks like we're going to be right on the edge now when it transitions okay that's except in zone one we don't want it to unload anymore or do we never mind um let's just work on this transition to stop so our trigger volume is hit and then we're going to load this stream now before we do what we want to do is we want to go into darkness just for a second now we can do this with every character in the game that has a camera has a camera manager and what's good about that is you can get the player camera manager pretty much from any blueprint so you can select that and then the camera manager will return the um basically it will it will return the manager sorry but um is always responsible for the camera that the character is using so what's good about that is there's some pre-built functions within that which allow you to fit um and appropriately named it's called start fed so you can start a camera fed very useful so we've we hit this trigger volume we're going to start a third now let me just talk through what these do so from alpha to Alpha is basically the opacity how visible do we want it to be so we want it to go from no opacity so invisible to completely solid which would be one and then the color is black which is already selected and how long do we want this to take so from zero to one we have it either instant which won't look very nice or we can have around about a second which is okay it's good enough and what we wanted to do is we want it to hold the hold when finished that means after one second it's going to remain black until we tell it to change back so we'll tick that now obviously this this uh third is going to happen for a second so we want to just delay anything else from happening for at least one second just so we know the screen's definitely dark and then at that point we can load in our new area so if we didn't add this delay this would start to fade but then instantly the world would load and the FED would be pointless so we can hit play now and we can run over to see our new area we can click on here you can see the world feds and then I assume that it is loaded so then what you can do is you can either um there's two ways you can do this actually you can either use the same node again to reverse this at the end or when the Zone one is loaded it actually triggers the event begin player all right so you could also get the player camera manager here and do a start fade now it sounds funny there's a stop fade but it literally just turns it off and so you actually want to start a new FIB but then do it in reverse so from alpha one to zero one second and then hold when finished now I know that sounds Daft that you're holding no third um I don't know what nose is really itchy um you can hold the third and then technically you could stop the FED just so that it's off but you really want that transition um to go through first um and that's going to be connected to that so now we're going to run over hit that and then boom that's really quick so let's let's get rid of that and that's because I didn't leave the one second so the layer one second and then stop fed oh and I didn't we go let's plug that in and that's why you need to do the delay because it allows the animation to happen so we come over and before you know it the world is loaded and we can speed that up a little bit sorry slow that down a little bit add a couple more seconds just so it looks a little bit more I think what we could do we could have 1.5 and then uh one 1.5 on here like that and let me move that should look a little bit cleaner that was a little bit quick so I fed I don't know maybe who knows so with all that being said the other way you could have done it is instead of having it on the event begin player like that uh you could you could then redo it after you've loaded with the FED again so from from this we can copy it and paste it here um then that way you you've you're controlling it as much as you need to there's only one downside to this which I'll explain in just a minute um so you could have that Fed so it'll start fed it'll load the level and then it'll have this fed um ease out which will actually be the other way around like that um the downside to this is if the level that you're currently in if the world that's triggering it so this this is the world's blueprint if when you load this level if then the world gets unloaded this blueprint can no longer run so let's say we load the new area and then unload um ourselves so we'll load the new Zone that's fine and but as soon as we unload the world that we're currently in nothing else can be triggered after that because the world isn't there to sort of execute it that's kind of it anything after this node will um will not work so that's one thing to to bear in mind so that's one of the benefits of using the event begin player because when the zone loads in it sort of takes over the camera fade so what you could do is event begin player something like this and then unload the world behind it like that now you may want to add a delay um so to prevent any complications let's say sometimes this can happen so quickly if you don't have overlapping floors you could fall through it and so that little delay just prevents that from happening and so now what you'll see is that this will actually never be triggered um technically the screen should just stay black so we'll do that we run over and the screen will stay black because that chord never gets this blueprint here never gets chance to be run um so that's where the get or player camera and the start fan is beneficial here so through that duration we'll do two seconds and then hold so what you'll see now is will come in this will get loaded and you can see like the other world now is gone um and it was all hidden with that transition which is where this is where it's pretty neat because um if were this um this border is if you were to put for example actually let's just grab a random wall here um let's grab that wall and let's say let's hold alt and we'll drag this over to here like that so what I'm doing is I'm just leaving a little bit of this green box on the outside of this wall and you'll see why in just a minute I'm going to pull that to there like that so that should be enough for our camera to be able to click inside now what I'm going to do is I'm going to select both of these copy I'm going to go to Zone one I'm going to paste so they're in exactly the same place except they won't exist but then when we swap they will and it'll look seamless um so I'll do is we'll play it we're going to run over here we're going to go in between these walls that's going to Fed out we're going to transition and then we're now in the new Zone now granted for a top down I think it would look better if we uh we shrink these down like that these are all sort of like designs uh design ideas that you're gonna have to think about if you're doing a top down especially um so we'll come to there like that that transition happens and then we're in the new area and then vice versa you can run back and we can set up a trigger volume uh in the zone one so let's hide that let's set up this trigger volume and essentially we're going to be copying what we've already done it's the other way around so we're gonna um starter fade let's just copy all of these like that so I'm just copying everything from the world back to the zone paste let's just drag these down a little bit what I'll do is I'll just zoom out a little bit though just want to pause and then you can check that but essentially you're doing your cast starting your third but instead we're going to be loading the world and unloading Zone one hit compile and then we're going to go back um so what we've done here what have we done I've just broken something somehow so when we trigger that fine okay my world wasn't loaded with planet so it's right over here click on that we're in the world run away we gotta do our thing we now want to get back into this zones we'll come here so what's happened is the Zone has unloaded and the world has ah I know what's happened So within the world [Music] um in the world we don't actually tell the camera to stop the Third so similarly to Zone one we can copy that come back to the world paste that in but we're going to delete the unload that in like that paste now you could see that flash just there now that's the only downside of this actually let's not do that so the world having an event begin to play a camera fade isn't really a good idea so in that case when we come back what we want to do is we want to we want to start this fed and then unload the zone so we'll copy that paste it here so from one to zero or two seconds but we'll unload the Zone immediately so this transition will still happen but hopefully we want a visibility of this disappearing let's just try that out get over here transition in come back let's go on to that perfect so obviously that was a little bit of um a broken down Basics I hope the way that I've structured this where we talk about how to get the nav mesh to update and then we slowly add bits and pieces together there that I've given you a good enough understanding to put all these parts together to create yourself a little world where you can transition into each building um yeah now there's one thing that I haven't touched on really is the simple move to so in my example when we run to this part the character automatically runs into the next Zone um that's just basically an advanced model of what we've previously just done um I'll just show you quickly what you need to do is in your world is just have your where's the floor gone so that the floor you just need to have your floor extend just a little bit past your trigger box and what you'll do is you'll just set up a if you go to your quick ad go down to all classes and look for you can actually search in this menu by the way we want a Target point I think it's called Target Point yeah it is called Target pipe so if you get a Target point you can see my search that's failed though where's he gone did we add it or not Target Point here we go Target Point add a Target point to the world hit the End Key just to drop it down into your world if you don't do that this won't work it needs to be sort of either touching the floor or just above it have that somewhere not quite off the Hedge but within within enough space let's have a look that's pretty good and keep your trigger point selected for this um this is going to happen in world one now you need to decide where you're going to do this so start the camera fade as the camera is fading we want the character to run towards the next Zone to give it the appearances as you're running into it so in between your delay and your third what you can do is let's just drag that out you want to look for a simple move to actor now you can do move to location you just need to know the sort of vector or coordinates of where you're moving to using Target points is so much easier so just use the move to actor and then you can select your actor um and if you had your target Point selected you can right click and you can see here you've got the target Point sort of selected create a reference to it create reference to Target point you can then drag that into your goal the controller is just going to get player controller uh let's move that down and make it look a little bit nicer plug that in and plug that into that and then what you'll see is as your transitions happening it'll appear like your character started running ahead well let's do player so as we get to here as the transition starts okay so that didn't actually work which um that confused me a little bit um what is the reason for that not working so that is definitely I'm just going to press end and get that on the floor I'm just going to double check where my nav mesh bound ends that might be the reason okay so that's actually the reason so that's not actually within the nav mesh so that will not help so let's just let's just make that a tiny little bit bigger my nav mesh um where are we 3 900 um go for four thousand so I'm hoping four thousand one hundred will just cover it just to be safe what I'm going to do is I'm just going to pull that Target point in just a little bit so I know that it's within my area um obviously yeah you're not your simple move to uses the AI nav mesh system if it's not in the area it can't run to it so now let's hit play again and um if I've not forgot anything else this should work so we'll click on that and you can see as the transition is happening it pulled the character forward and I think that's just a nice little addition to Transitions obviously if you start at the front of a door to enter a building that might not that might not work but either way I think it's a nice transition to that so this is becoming quite a long video again so I do appreciate it if you've watched this far um if uh if you did like it please consider giving me a like and if you want to watch more videos like this consider subscribing uh there's also a Discord link down below if you want to join the Discord server uh ask any question you want and or just have a chat that's up to you um really appreciate you watching this far so thank you um now as to where I've been for the last couple of weeks now at Christmas I decided to take a bit of a break and essentially I just got comfortable um after a two-week break from work because I do have a full-time job alongside this YouTube channel um after after two weeks off work over Christmas when I returned um wife and getting started back at work just got a little bit stressful and I just didn't think I was ready to come back to YouTube just yet and as the weeks went by um unfortunately I did just get a little bit complacent with not having to make a video um so I've considered it an extended brick it was much needed um but now I'm I'm finally ready to get back into into things so with that said I'm looking to pick up older projects if there are videos in the past that I haven't continued or you want me to build on please comment down below and let me know which videos you want to watch and um and that's that so I think my son's trying to break into the into the room now so that's my time over thank you for watching this part and I'll see you in another video bye [Music] thank you [Music] I wonder why [Music]
Info
Channel: Steven Ormerwood
Views: 7,506
Rating: undefined out of 5
Keywords: projects, unreal, ue4, engine, game, development, game development, tutorial, unity, blueprints, gamedev, dev, UE5, UNREAL 5, UNREAL ENGINE 5, NANITE, LUMEN, prototype, quick, easy, simple, modification, UE4, UNREAL 4, UNREAL ENGINE 4, SHOOTER, TPS, FPS, auto, shooting, shooter, combat, call of duty, halo, movement, advanced locomotion, aiming, fire, advanced, loco, locomotion, system, adv, ik, line trace, level streaming, stream, AI, move to, transition, world partitioner, world, partition, streaming, buildings, open world
Id: kyMFOiQIqdM
Channel Id: undefined
Length: 45min 10sec (2710 seconds)
Published: Sun Jan 29 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.