Make a Top Down Shooter in Unreal Engine 5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone so this video is for those of you who are brand new to unreal engine 5. maybe you just heard that it came out and you want to get into game development so we're just going to be making like a really simple top-down shooter like this you can just fire these laser bullets at some ai and kill them move around like this and you'll also learn how to create a level like this there's these new features in unreal engine 5 which makes level building pretty cool there's no landscapes or anything and you'll be learning about using qixel bridge to bring in these meshes and just getting around the engine so the way i teach is i teach pretty quickly i like to get you into the engine and just making stuff i feel like you learn best through just doing things and through repetition so we're gonna dive straight into it and just get your hands dirty but before we start a word from our sponsor and that sponsor is me i have five courses got this horror course for beginners wow how neat you got this action rpg course this dungeon crawler a multiplayer first person shooter and a multiplayer grid inventory system for those advanced people out there so if any of these courses look interesting link in the description back to the video all right so let's just launch unreal engine 5.0 now when it launches you'll get this screen and these are all the different projects it also shows unreal engine 4 projects but what we're going to do is go to games here and i'm actually not going to do top down i am going to do third person and i'll show you why in a bit so down here i think this is a bug you got to do like a slash i believe just like that or you can click this i'm just going to put it on my h drive we want to do blueprint here um just keep all this the same and then for project name let's do top down ue5 that's how i'm going to call it and create okay so now we are in the project and immediately if you click play you'll be able to run around this character so the reason why i did a third person project for this is because with just a few adjustments with the camera we can make it so the camera is above the player and stationary but we can still move the player around like this so that's why i want to do it this way and if you're brand new to unreal engine 5 like this is your first time ever using it this is a beginner tutorial so this is the interface i don't want to spend too much time going through it because i want to get to just creating the game but and so your layout might look a little different you might have like a window over here on the left side all i've done is just i've just moved tabs around and when you move tabs around it just saves it for every project so for example i just grabbed that one i moved it over here you can you know just start grabbing your tabs and move them around how you might want them this is how i like to have my screen because i feel like it just gives me a lot of room here to work with so this place actors tab yours might be over here i can't remember how the default setup is maybe it's something like this you might have a content browser down here might look like this whatever the point is that you can just move tabs around and give yourself some space maybe you want this down here maybe you want your content browser down here but i like to have my place actors up here i like to have my world outliner up here i like to have details right here and then world settings here because world settings is where you set up the game modes and things like that which we're going to do and if there's a tab here that you don't have you can go to window and then these are the different tabs you can have so for example here's place actors world outliner world partition world settings so you want to get these tabs these are the most common to have there's also levels that you can have so i can take this tab now and just put it somewhere there's also layers i can take this tab put it somewhere and then you can always just close your tabs and i'll close the content browser as well so the content browser this is actually new in unreal engine 5. there's a little button down here which opens it up and this is actually really nice i'm starting to really like it because then you can just open it close it right and you can just drag actors in so like i can just drag this like cube in here for example and yeah it's really nice what i want to do is set up our own level so let's go to file and new level and i want you to pick empty we're just gonna start bare bones with nothing don't save so now in here this is just an empty level there's absolutely nothing in here there's no light there's nothing so i think it would be fun to build out a simple world really quickly before we get into the blueprint stuff that'll help you get used to the ui up here and we don't even need to build out a landscape actually so unreal engine 5 came out with this demo called valley of the ancients and you can download it if you want but it's a hundred gigabytes and if you're a beginner it's not really useful to download it's just pretty it's just nice to look at but something i noticed with it is they actually don't use any landscapes it's all just static meshes that have been built into blueprints placed across the level that's all it is and they're instant static meshes which reduces draw calls blah blah blah i'm a nerd but yeah the point i'm trying to make is that we actually don't need to create a landscape now you can if you want but then you need like a landscape material and things like that i don't want to get into that so we'll just use meshes we'll just use qixel but first things first we need some lighting here so if you go to place actors here and search for atmosphere you'll get this sky atmosphere let's drag that in next up we're going to do a directional light let's add that in then we're gonna get a skylight let's add that in and then we want fog so type in fog and you'll get this exponential height fog drag that in and that will start to give us the light so you actually need all four of these actors to start getting some basic lighting in here and what i'm going to do now is go to the world outliner tab let's right click create a folder i'm going to call this lighting and just take all four of these actors you know you can just hold down shift and select them all and let's put them in the folder this will just make your life easier if you have like a thousand actors in your world and it just it can get hard to find your lighting setup so if you put in one folder here it's all in there and then you can actually disable everything in the folder so we'll start out with these four and we'll come back to the lighting in a minute let's actually get some meshes in our level but what i want to do now is i want to save everything so a little handy shortcut is ctrl shift s this will let you save everything let's make a folder here in the content so if you click the content at the top let's make a new folder just right click maps and let's save this as i'm gonna save it as level one right level zero one and this is just in case you want multiple levels so this is our level one and it's going to be a top-down game so our view is going to be like this so we don't care about like clouds or anything like that which is good because we can save on performance that way but what we want to do is actually get some actors so in our content browser just go to content here and right click and you should have this add qxl content so open this up and this is how we're going to get our meshes it's just a very easy way you don't have to do this you could get the the meshes from the marketplace there's free packs on there you could download it's really up to you how you want to build your level out but this is how i'm going to do it just because i can show you guys how to use qixel bridge but yeah the marketplace you can just go here and then once you're here you can browse and you can just click on free and all these collections are free right you can just go through here get whatever you want there's this really cool pack called rural australia right here it's free and you can just make your level from this if you want it already comes with like two or three pre-built levels anyway you can just use those or you can just use all the meshes that they have so i encourage you to go in the marketplace and just find some free stuff to use but just for this particular video we're going to use some qxel assets here so in order to actually get them you have to click here and then sign in and you're going to sign in with your epic games account so whatever account you're using on you in the marketplace here you're going to use this same account for qixel bridge here so click sign in and then sign in with epic games and go ahead and sign in it always does this annoying security code i hate it alright so i should be signed in now and what i want to do is where is i think it's this button here yeah this is collections and so again you kind of have the freedom of what you want to do but what i want is i want an environment here so i'm going to click environment and you can either come down here and just look at the latest assets what i want is some like floor meshes like a bunch of different floors because that's going to be our ground so to make this easier let's go find a collection here let's go to natural let's do limestone quarry so we've got all these different rocks we can use we don't really now remember the game it's a top down we don't really care about these huge like rocks on the side like we'll get to that but what's most important are these like floor meshes here it's like anything flat can act as a floor so all of this stuff i want i want this these and the way we do this now is let's just start from the top like we want this one for example what we want to do is stick with medium quality like yeah they have nanite and all that nanite's cool don't get me wrong but the problem with nanite is these meshes just sitting on your computer take up a lot of space because it's like 8k textures or something like that it's like i downloaded one stair mesh and it was 711 megabytes whereas like these medium quality ones even the low quality we could actually just go with low quality like you can download whatever you want don't get me wrong but i'm gonna go with low quality just because it's gonna download really and it's a top-down view it will still look good so i'm going to go ahead and do low-quality download and it's already done downloading it took about two seconds so now when i click the add button let's pray that it gets added so let's open up the content drawer in there so here's this mega scans folder 3d assets limestone so it got added automatically let's open it up and there you go it's only a thousand triangles and yeah like up close obviously it doesn't look good but from up here a top down view that looks perfectly fine to me it doesn't take up any space but so what i want to do is go to show and then i want to show simple collision and it doesn't look like there's any collision so we have to set up collision and that's totally fine what i'm going to do is on the right over here we have all this collision stuff here so for collision complexity i'm going to do use complex collision as simple just like that and now you can see we have some collision i wouldn't recommend using this like on a mesh that has a ton of triangles but because this is only a thousand triangles i think we'll be okay doing that you can always add in your own collision as well so let's say i leave it as project default here and it doesn't have collision but i want to add collision i can click this tab and just add a box like this and maybe we'll just do this because again it's a top down game the player is just going to be walking over it we can just take this box and i can just move it down oops it has snapping i'm going to click this to disable it we can just move this down like that right so this looks like it's about on the mesh and when the player walks it'll be walking on this and it will look realistic so this is our first mesh i'm going to go ahead and close this now and in the content drawer let me just move this down i can now drag this out in the world so now we kind of get an idea for our lighting and the lighting is okay we'll worry about the lighting in a little bit but yeah there's our first mesh and i'm gonna start to bring out a bunch of meshes so let's just go back into qixel here so we have quicksilver i want this mesh i want this one anything flat and floor so i'm going to download that going to add it i'm going to download this one it's got like a flat surface here this is how we're going to do our floor instead of using a landscape and the reason why is so we don't have to set up a landscape material and yeah just start going through find the meshes that you think will look cool in your little game i'm just going to keep adding these because they got these flat surfaces anything that looks like it could act as a floor and when they're done downloading they'll have this green check mark and there you go so all five have been downloaded i can now just click each one and then just click add just going to add each one into our project all right so i think that's enough meshes for this demo game so i have these are all meshes here so if i click this mega scans folder and then i click this filters here i can select static mesh it's going to show all of our meshes so the downside is we're probably going to have to create collision for each mesh and that just takes time so to make it easy just open up each mesh scroll down and let's just do the complex collision just do that just to make it easy you can always go through and set up collision separately but for time purposes i'm just going to do that for every single mesh here and then once these are all set up we'll just continue so i'm just going to do that really quickly so remember it's just down here collision complexity use complex collision as simple and doing all this will help you kind of start to get comfortable with the engine so for example nearly every single actor you're going to open up is going to have a details panel which contains all the important information so look this is a low quality mesh but look how good it looks just from this distance like of course when you get close it looks bad but from right here looks great okay so i've set up all of our meshes here so what i'm going to do is holding down shift i'm going to select every single mesh and this is going to help with just world building in general so just take each one drag it out here this is every single mesh we just added to the project so obviously they're all stacked on each other and what we're going to want to do is we just want to separate them and have this like little shelf over here where we can just grab each mesh and start placing them so this is just some like world building tips so i'm just going to do this and yeah these can be like our small ones over here but the thing is is that we can scale these now even though this is small you press the r key you can actually start to scale these up see so you can always do that if you want but the point is is now we have all our meshes here we can just grab them and duplicate them start placing them in the world this guy is down here for some reason let me just bring them up and remember to save often so just do control shift s you're going to want to save all the time make it a habit and now what i want to do is i want to start building out our world now so remember top down view what i'm going to do is i'm going to go to place actors and we're going to get a player start i'm going to drag it in here and this is going to give us a size of our character so our character is actually going to be not small so you can see it's not small but this does show us that the collision is working so you can see how the player will be able to walk on these and let's exit out of that we kind of have an idea for scale to make this even easier if we go to content up here let's uh uncheck static mesh let's filter for skeletal mesh this will give us our mannequin this is like the size so we can bring that out here and now we kind of have a scale to run off of for building our world and so here's our player start and this blue arrow represents the direction of the player let's say that the player is going to be over here actually let's drag the player like over here so this is where the player is going to start now we can kind of start building out the floor so let's bring this over here so this is like directly under the player and what we can do now is we can start to like scale these up a bit just to get a decent size going if you want you can just scale on the x and the y here oops it's a little too much and then you can kind of just drag it down and get a bit just to let it blend and then now is where i kind of already screwed up because i brought these out what i should have done is left these over here like this i'm going to click this arrow here to reset the scale so it's at one one one this one's at three four one let's just reset it there and what you wanna do instead of just dragging this out we want to duplicate it so hold down the alt key and then you'll make a duplicate okay so now let's scale this up let's go 3 3 on the x and the y the z i'll keep the same because it's top down and now we can kind of start doing this for each mesh so i can bring this one out here on the x let's go like 4 on the x 4 on the y and you can see how they kind of blend together right so if i play they blend right together like that so you can see how we can start to make this look like a decent ground so i can duplicate this guy here i can scale the whole thing maybe do that and now you can see how it looks a little different there and we're just going to keep doing that until we have like a decent like floor setup so what i want to do with some of these rocks here is let's bring this guy over here now i want this to be like a flat ground type thing so i can scale this up i can go like you know something like that maybe move it like that so again from a top down view it looks okay and we just want to make like a nice decent playing field nothing too big at all like obviously if you want like a huge world you'll use a landscape but for this type of game it's just like a top-down shooter it's like a wave-based shooter monsters are going to be coming at you and the whole point of this video is just to kind of get you comfortable with the engine and do some very basic blueprinting with some ai and some shooting and stuff like that so what i want to do now is i want to do something with these big rocks these big rocks are going to be kind of like the boundaries for the arena so i want like right here to be the edge right so i'm going to drag this out this will be kind of like the edge of the arena we'll end up moving the player start way out over here somewhere so let's start making this like the edge right now the problem is is that the camera might get to here and could see the back of this so i'm first going to scale this up a lot because it can be pretty big like that all of these actors are starting to get in the way so i'm just going to hold down shift and i'm actually going to move all of these so just selecting all of these here kind of showing you some little ways to move across the editor here let's put this guy here now to give us a scale like that so this guy's now on the floor so we have a sense of scale now and so i'm going to start setting up some boundaries here i'm just going to bring this guy out scale him up pretty bigly there i'm going to rotate 180 about so i want these two kind of line up here they're not the same color unfortunately but whatever so now at this point i kind of want to do something with the lighting i think we have lumen enabled by default let's go to project settings type in lumen and so we have lumen enabled by default that's the new lighting system it's really good but right now the global illumination isn't working so in our world outliner here let's go to lighting let's see what's going on so with our directional light selected i'm going to go movable make sure it's movable here with our skylight also set that to movable and now we're starting to get that gi that global illumination but we have some auto exposure i want to disable that so again let's go to project settings type in auto exposure and let's just uncheck it now if you do want auto exposure you can obviously leave that checked but i'm just going to disable it from the project completely and so now we'll have like an even thing going on auto exposure has been disabled but it's still kind of doing it i don't know why maybe this is a bug so what i'm going to do is go to place actors i'm going to add a post process volume i'm going to move it into lighting and i'm going to scroll all the way down and down here i'm going to check the infinite extent like that i'm going to go back up and open up exposure here and i'm going to enable the min and the max here and then do one one for each all right so that solves the exposure issue so disabling it in the project settings is currently bugged i guess it's all right it's early access but yeah so we got the one one this is just like a like the basic lighting and i can tell it is too bright so with the directional light here what i want to do is i'm going to set the intensity to like a three like that actually no let's do an intensity of one i'll show you why let's scroll down these are all just your lighting settings for the directional light you can change the temperature here for example maybe we want it to be colder so we do like 9000 you can see it gets a little bluer and we'll fix the brightness don't worry but i just want to show you this stuff um if you do like 3000 it's gonna be warmer so you can see how it gets red so these are colors you can mess with and then 6500 is the default but let's fix the brightness really quickly so select the post process volume and this is actually how i like to do lighting i like to have the directional light really low at like a 1.0 on the intensity and then with the post process i mess around with the exposure settings here to affect the brightness so i can do 0.5 for example this will start to make it a little brighter and you can come even lower like 0.3 and so you can see how it's starting to get bright again so that's how i like to adjust the brightness and then with the fog this is too foggy so i'm going to do something like .005 like that so i think that's starting to look pretty good um the skylight here we can make adjustments as well we definitely want to check the real time capture so make sure you check that and if you uncheck effects world you can see how the skylight is working in these dark areas so you can see i check it and we start to get the global illumination popping in you won't notice it as much in bright areas like this you can kind of notice it in the background in the dark areas but yeah so here's the intensity depending on how you want your game to look because i'm doing a top down here changing this you won't notice too much but i'm gonna leave it at one and i'm gonna go back to the directional light and we can check this atmosphere sunlight there and this just helps it work with the sky atmosphere a little more so if i press e i can start to rotate the sun and it will start to give us different colors so you can see when i get to like this sunset how different it looks you see the sun over there so just by using the sky atmosphere with the directional light it automatically updates with the skylight things like that and you get some really cool lighting here um you can always turn off the snapping for the rotation and get some and get like a more specific color that you want i guess let's see top down game what do i want maybe something like that now the bottom with all this white pretty sure that's the fog yeah so you can see if i disable the fog how it does that keep in mind you really won't see it once you fill up your level still might be too much fog so we can do like a point zero zero two i think that's like a decent number but yeah so let's build out our arena here i guess you want to call it i don't want to be too big but i'm just going to start bringing out some of these meshes here and i'll build it out so remember to hold down the alt key and then with the r key we can really start to scale these pieces up and so i'm just going to build like a like a square i guess and then we'll get started with the blueprint so i'll see you in a bit all right just showing you a little progress here's like my arena this will be plenty big enough for the demo here again in this video it's just about you learning right let's just make more of this floor here scale this guy way up bring him down like that and i'm going to start grabbing just more meshes over here so just keep building out your world after all we're just trying to learn here just trying to get comfortable in the engine and you get good at this stuff by just repetition that's how you learn so just coming in here just starting to like and just dragging around a bunch of actors like this this is how you get comfortable okay you can scale this up even more make it bigger bring this guy in like this and just keep doing this over and over again and eventually you'll be so comfortable with it you're not going to have any problem right so obviously in third person you can see how there's like gaps and stuff like that but from the top down view for the most part you can't really see those and we can always fill those in later like i can always take this guy hold down the alt key drag it in like that to cover up those lines there see see so that looks pretty good and then we still got all these little rocks i can bring in i can bring in this guy over here maybe i want this guy to just be like a big rock that's just like kind of like an obstacle for the player like that and then what you can do so check this out i'm going to select all these actors here holding down the shift key let's just get all these selected right i think i got all of them maybe i don't but what you can do now is i can just move this i'm like oh i missed one so i can press control z so i missed an actor in here somewhere where is it oh i see it it's this guy right here so i press the shift key i can select it and now i have most of them so just press ctrl z to undo that there's this guy here and then that guy okay i think i have all of them selected yeah so what you can do now and this is like a new feature with unreal engine 5 is you can right click and you can do this create from selection so this is going to create a level instance and this is what the valley of the ancient demo did all over the place that's how they made their entire landscape and so you can create from selection here a level instance click ok and now in the content folder here let's create a new folder and call this the level mass or something like that this is how they did it and you can just do like round mass underscore 0 1 or something like that and you save it and now this is actually one whole actor now you can see up here it's a level instance you can hide it and if we go to the content drawer here we have this level mass so make sure we unselect skeletal mesh there and it's like it's its own level now and you can move it around you can rotate it and if you don't like where some pieces are you can click this edit button and now you can select the individual pieces here and start moving them around you can duplicate them as well add more to it and then when you're done just select the level instance up here at the top in the world outliner and then click commit change save selected and then that's it now what you can also do is you can right click and you can create a pack the blueprint and so the value of the ancient demo has a bunch of these as well so you can click this and in the level mass i'll just save it here it's going to create a blueprint so save selected and then now you have this so automatically creates this blueprint for you and if you open this up all of these meshes in here are now what's called a an instant static mesh and this is great because it really saves on draw calls and performance you can't really edit them too much in here and so now what i can do is i can click the browse button here and i can take this this blueprint drag it in the level here so now this is a blueprint now so if you look in the world outliner this first one we created here is a level instance and it has all these meshes here and all that but this one here is just a single file it's just one file in your world outliner it's just a blueprint and you can still edit it if you click that you can still edit and you can still you know hold down the alt key add more to it like that whatever and then you can select it and click commit changes like that and you notice it did update this one over here as well so what i'm going to do is i'm going to delete this one here and the reason why i did that is because this blueprint ground mass this is just one file now in our world outliner it's just one actor it's a lot easier to deal with in the outliner here so what we can do now is i can drag this guy out here and i can start to make duplicates just to make our life easier we can start to duplicate it and go like that rotate around and they're all going to be at similar height here maybe this one's a little too high i can bring it down i don't know but either way the point is is now it kind of makes our life easy and it's not going to be the prettiest obviously but for demonstration purposes it's pretty freaking neat and you can make as many of these grounds that you want you can go ahead start grabbing more meshes over here and just start making like 10 to 12 different chunks or masses and you'll have a ton of variation i'm not going to do that just for time purposes but hopefully you kind of get what i'm saying here but i'm just going to do this quickly fill in our floor here and this is one of the coolest new features of unreal engine 5 that's why i really wanted to spend some time on the world building here i mean just like that i now have a floor right okay so obviously it's not perfect got some issues here but again i can still always just grab one of these guys over here scale it up and fit that guy in there it's not gonna hurt at all looks fine whatever good enough so now i can run around my world yay so now we're ready to set up the character so it's actually like a top down type game i'm going to delete that guy and i'm going to move the player start in the middle here let's go find our character blueprint so go to the third person bp folder blueprints here's our character and in the viewport you can see that the camera is right here so we don't want the camera there so select the camera boom i think we uncheck uncheck use pawn control rotation and now we can start to rotate the camera up like that let's make the target arm length i'm going to go 1000 to start compile it up here in the left corner and save and now when i play this is kind of a good view i like this view um obviously the camera is moving around like that we don't want that so back in our character okay so these are the settings we want to get the correct movement i've been messing around with a bit trying to figure it out and i finally got it so go to your character movement make sure orient rotation to movement is checked make sure that's on i think it should be by default but just in case if yours is disabled just enable it here then we want to go to the camera boom here and you want to uncheck inherit pitch check inherit yaw make sure that's checked and then uncheck inherit roll and then you want to check use pawn control rotation so so make it look like this compile that save it and now when we play you got this classic top down look and you can still look around with your mouse as well see i can look around like that and i can also just move around and we still have jump as well so this is exactly what we want we got some holes in our landscape we can always fill those up i think it was right here um let's see i'm gonna grab a rock from over here bring it over and then let's see let's just kind of scale this guy up and bring it in here all right cool there we go filled in another hole i'm only working with one of these mask pieces here that we built ideally you'd probably have 12 to 15 different ones so you get all that variation and at any time if you don't like how you rotated something just come over here click these arrows reset it let's scale this up pretty big actually just so i can really fill in these gaps here but what's important is that we have our camera angle now so now we just need an actual character with a gun and all that and for that i'm going to use a paragon asset so come up here type in paragon and the character i used in the previous version of this tutorial was this character here lieutenant bellica she just has a gun on her so it just makes it easier in my opinion so i'm going to go ahead and add her to our project and what you'll notice is it's only showing unreal engine 4 projects it doesn't show our unreal engine 5 project so i'm gonna click this show all projects i still don't see our top down project it does have value of the ancients 5.0 so what i'm going to do is i'm going to restart the epic launcher because i think it's just not detecting our top down game so i'm going to close it make sure you close it down here and let's reopen it and now our top down project is here in the library so let's go back to the marketplace and i'm just going to type in bellica here and we get lieutenant bellica so i'm going to do add to project show all projects scroll down and there's our top down ue5 project so what we need to do is we now need to select the 4.26 version so it's just going to add the 4.26 version into our real engine 5.0 so just to add the project and then it's going to download it and add it so when this is all done we'll get back to the video it's 1.7 gigabytes so it might take a little bit all right so she's done adding so in our project let's go to the content here and here's the lieutenant bellica folder now it's kind of hard to find the character actually so what i want to do is i just want to do skeletal mesh again so here's all the different characters and when you open up these characters for the first time you're going to have to compile a lot of shaders so the best way to do this is actually let's go to level here and open the lieutenant bellica level here and then it will compile all the shaders so once that's all done then we'll continue it's been about five minutes nice i'm only 10 of the way done compiling but i think we got enough shaders compiled to pick a character here so just pick whichever one you want or you can use your own character so for the demo purposes i'm going to use this yellow character again this is what i used in the previous tutorial i made like a year ago i'll just use this one again because it's bright it's easy to see so i'm going to do is i'm actually going to open up the skeletal mesh here in the corner just open it up and so what i'm going to do is now in the third person character here i want to replace this guy this mesh with her so to do that i actually need to click this browse button this will take me to the skeletal mesh right here and then now in the third person character i can select the mesh over here on the left and then i can press this arrow and it's going to plug in the girl now when i do that she no longer animates and that's because we have to assign an animation blueprint here in the animation class so luckily she comes with an animation blueprint but if you don't have one you would have to make one but that's why i like these paragon characters because they come with an animation blueprint so if i go into the bellica folder here here's her animation blueprint we're not going to worry about the character here you might be thinking like why not use the blueprint character here i don't want to do it i just want to use the third person character because i like to make my own custom code but i'm going to use the animation blueprint because that can just fit right in here yoink and now she's animating look at that so make sure you compile this and save and now i'm going to go back to our level so just go to file recent levels level one you don't have to save this we can just click don't save and now when i play i have my character look at that and i can move around with her she is ready to go it's going to be a little laggy because we're compiling shaders still so even though we change levels it's still going to compile 4500 shaders so it's whatever just let do that but yeah we can like jump around the stuff and cool so there is one issue though when we play she plays this like startup animation i guess that's cool if you want to have that you can leave it but if you don't want that then what we can do is we can browse to the animation blueprint we can open it up and in the event graph here so here's blueprint if you've never seen this before you're probably like dude what the heck but the reason why it plays that animation is because of this right here so on this begin play it says play a montage and so it plays this level start montage right here so we can browse to it here it is right here we can open it and there you go this is the animation montage that it plays so what i want to do is i'm just going to hold down the alt key and click boom that disconnects the connection there and now it won't play that anymore so when i play she just is idling and ready to go so i don't want to get too much into the animation blueprint here a lot of it has been set up for you already by epic so thank you epic but i just wanted to show you how to disconnect that intro animation this begin play will fire at the very beginning of your games so now i want to actually be able to shoot some laser bullets here so in the third person character here let's go to the event graph and this is just movement stuff we can just kind of move this out of the way we want to do something when the player presses the left mouse button now if you want you can just right click and do left mouse button and have this run the event but what i'm going to do is i'm going to go to our project settings and in input here on the left we can actually set up our own inputs so this is actually the correct way to do it you don't want to really use like oh left mouse button things like that we want to set up our own action here so open up action mappings click the plus button and let's call this just fire for example and then in here we can do left mouse button so if you click the plus button here you can add more inputs for firing if you want that's why it's nice to use these action mappings instead of just hard setting it in your code so now in our code we can do just type in fire like that and then we get our action event so now what this means is whenever the player presses the fire button which in our case is the left mouse button this will fire every time so for example i can just do like a print string here every time i press the left mouse button it's going to say hello on the screen so when we play and i just start clicking you can see it's saying hello so this is where we're going to do our fire logic every time the player presses the left mouse button we're going to shoot a laser so how do we do that well i'm going to teach you that's why you're here so let's go to our content drawer let's go up to this content folder let's just do it here i'm going to right click and we're going to create a new blueprint class and we want to create a new actor so an actor is just an object as you can see here it's just a very simple object or it can be very complex but at its base it's just simple so i'm going to name this the bp underscore laser so let's open this up maybe laser bolt would be a better name but yeah we just want to shoot like a laser bolt nothing crazy and so the easiest way i have found to do this is to add some collision here let's just scroll down and we have a box so let's add a box and i'll show you why we're going to use a box i'm going to take the box i'm going to drag it to the scene root there and it's going to remove it so now the box here is the root so let's compile that and save and now with the box selected we can add a sphere now with the sphere what i want to do is i want to scale it into a laser but first i want to add it into the world okay and that's because i want to get a general size of it so let me go ahead and add our why can i browse to this what's going on oh there we go i'm going to add our character here and i'm still compiling shaders so i'm a little laggy but this is just to get a scale so i'm going to bring this out here obviously this is way too big right that's what's going to be coming out of our gun that's way too big so if we drag this tab around we can actually get our own window like this and now what i can do here is i can start to scale this uh this sphere here and i'm just kind of opening this up and so with the sphere selected we can start to scale and now if you hold down the left mouse button we start manipulating the scale so at this point i'm messing with the x value like that now i want to mess with the z value so let's see how that looks see from a top down view i think that's still too big to make it a little skinnier there and then on the y i'm going to bring it in maybe something like this and then like that okay i think this will be okay so let's compile that in the laser here save it and then now what i can do is i can just delete this from the world and i can delete the character because now we have the size that we want i'm just going to drag this back up here and what i want to do is i now want to take our box here and this is the collision this is actually what's going to register hits so the sphere here what i want to do is i want to remove collision i don't want it to have any collision so i'm going to scroll down to collision here i'm going to uncheck generate overlap events and for collision presets i'm going to set this to no collision i don't want the mesh doing any collision the box is going to handle it here that's why we have this box here so now with the box this extent here this is where we can kind of size it around the sphere so just hold down your mouse and start to drag the extent here whoops this is the z value and then the y like that so let's come in more on the x and honestly the perspective isn't that good here so i'm going to click the perspective button and let's go to a left view zoom in and now this is like a perfect view from like this angle so now let's go to a front view and yeah so i think this is good so now we can go back to perspective and our collision is set up so now what i want to do is i want to scroll down here and let's click this little arrow here for the collision presets i want to do custom and i want to click ignore everything but i want it to overlap a pawn so a pawn is a character so when we make the ai this projectile when when the collision overlaps the ai characters it's going to detect it as a pawn and we'll have it do damage but i also want to overlap world static and world dynamics so this will be like things like rocks and terrain and things like that so when it hits those things it'll also overlap and we'll set up some code so it just like destroys it when that happens so make sure you compile that and save and we don't have any ai yet just for time purposes we're going to make a really simple ai so what i'm going to do is in the content here let's just create a new blueprint class create a character and i'm just going to write like ai underscore enemy whatever let's open this up and for the mesh let's just we can either select another bellica like maybe we want like this one here and so let's drag it down we want to make sure her feet are at the bottom of the capsule here and turn on rotation snapping because we need her to face this blue arrow exactly 100 so rotate 90 degrees exactly she's now facing this arrow and again i'm just using her as an example you can use any character you want but we need to plug in the animation blueprint now so we're just going to grab the same one that we're using in our character here so let's browse to it it'll select it here and we'll just plug that in like that with the arrow okay so this will be our enemy now i'm going to just take this and i'm going to put some here so now when we play and run over here we have an enemy right so we're just gonna have the enemies kind of stand there this is just to test our shooting logic we want to shoot the enemy in killer so in the third person character when we press the left mouse button we want to spawn this laser and we want the laser to go flying forward so first things first in our laser we actually need to add what's called a projectile movement so just type in projectile add it at the top here the initial speed let's do like maybe 3000 that might be fast enough uh gravity i don't really want gravity so i'll just do zero and then when we simulate here you can see it moving okay so it's moving that way so that means i actually scaled this the wrong way okay well we have to redo that so let's just select our sphere here and we're just going to swap some numbers here so the x needs to be 0.5 and the y needs to be 0.08 so let's just do 0.5 point zero eight okay there we go now it looks more like a bullet going the right way and then same with the box collision we need to swap the x and the y here so we need to do a x of 26 and a y of five i think yeah okay so compile that simulate and there's our bullet all right so when this bullet spawns it's gonna go like that okay so in our third person character here when the player presses the left mouse button we want to do what's called a spawn actor from class we want to spawn this laser so just browse to the laser here and then plug it in right there okay it's not plugging in why not plug in there we go okay plugged in now when you try to compile it's going to give you an error and that's because you need a transform so we need a spot on the player to actually spawn this and the easiest way to do that is we can just go to add here and we can add what's called an arrow so it's just a very simple component so you add that and we can say this is the projectile spawner or something like that let me go to the viewport because i want to move this now so i can press the w key and start moving this and so the end point right here is where the laser will spawn so i'm actually i know the guns over here on the left but we do want to spawn from the middle of the character just so it's accurate and the player is not going to be like confused so spawn it like something like that and so now with that we can bring out the spawner here you can drag off the spawner type in transform and you'll get this where is it get world transform so take that plug that in now when you compile everything is going to be good for the collision handling here set this to always spawn ignore now in the viewport this is where the laser will spawn like right here and that's gonna happen every time the player presses left click so an issue though is that when you spawn this actor that's a new actor in the world and at the moment it's never going to disappear so we need to go back to the laser and then in our class defaults up here we need to scroll all the way down and for this lifespan this is actually how long it lasts so just in case if the laser just for some reason never deletes itself let's do like three seconds so after three seconds it will destroy itself no matter what this is like a good performance check here just like a safety check and now when we play we should be able to spawn these lasers so i'm going to play yeah so see i press left click you can see the laser is now it's going wherever the character faces so if she faces over there it's going that way now it's not the most accurate shooting because when you press left it's like a quick left or right as you can see but for the most part it's not bad now we don't have anything set up so when it actually hits an enemy it destroys itself or does damage or whatever we have to set that up but yeah for the most part you're now shooting lasers yay we don't have any sound effects or anything like that but it's still pretty cool so let's come to the laser now we need to do some programming here so when the laser here actually hits an enemy we'll do damage so select the box collision scroll all the way down on the right and let's do on component begin overlap right here so this is like an overlap event you're gonna use these all the time when you're making games these are like probably the most common collision events you're gonna use so this other actor is what you're hitting so if i just oh if i just do a print string and plug this in when i play every time i hit this character it's going to say the name see in the top left corner it's also hitting the player though and so that's an issue as well that's just something i'm going to fix here really quick so we don't want to hit the player so an easy way to fix that is back in the third person character we have this instigator it's asking for a pawn object reference and so the character is a pawn so if i just right click type in git self this is a self object reference meaning this is a character reference and because the character is a pawn i can actually plug that in and so we want to do this because now in the laser we can do a check here to check that if this laser is hitting the instigator which is the player we can make it ignore the instigator so it doesn't do anything to the player so that's very important so we want to do we want to drag off this other actor and we want to do what's called a not equal actually so if the other actor is not equal to the i'm going to right click type in instigator right here let's plug that in so what we're saying here is if the object or whatever that's hit by this laser is not the player then we want to continue so we want to drag off this and do what's called a branch node and now we're only going to continue if we're colliding with a non-player so in other words it's only going to continue if it's the enemies so we can do now is we can actually cast to enemy like this and if it's the enemy we can do damage if it's not the enemy this is going to fail and we can just say destroy actor so this means if it hits like a wall or something like that it'll just destroy itself if not it's going to destroy itself after three seconds anyway so it's okay but anyway what we want to do here now is we want to apply damage so let's go into our enemy and i'm just going to delete all this and let's right click let's do apply damage so you have so this is an event that comes with the engine just like this actually no it's not this we want to do what's called any damage so if you type any damage you get event any damage this is the one we want this we use in the laser but this is an event that comes with the engine so what we can say and so actually before we do this let's go back to the laser i'll show you why so drag off of this and now type in damage and now let's use apply damage okay so now we're doing this and we can set how much damage we want to apply here and when this function gets called it's going to run this event on the enemy so whatever number of base damage we put here that's going to be the damage here so let's make a variable actually i'm going to drag off i'm going to drag off this and do promote the variable and we'll just say health right this is the health of the enemy so compile that and then i'm going to delete that i just did it this way because it's an easy way to make a variable but now down here we have our health variable and let's say our enemy has let's just say 100 health right pretty simple and let's go back to the bp laser so let's say the laser does 30 34 damage and so this means the enemy can take up to i think three shots and it's dead like the third shot will kill the enemy so we want to do that the damage type here just do damage type whatever and then now back in the enemy we now have 34 damage coming out of here so the enemy has a hundred health we just to do some simple math to calculate when the enemy has zero health so to do that we just bring out our health variable we want to get it we want to say health minus we want to do health minus and then we get subtract here we want to subtract the damage so essentially we're saying 100 minus 34 equals this is like the new value right so it's gonna be like 76 or something we want to actually set this to the new like we want to set health to this new value so to do that we just drag this out go to set plug that in connect that up and now we have 76 health after one shot okay so when the enemy gets hit again it's gonna be 76 minus 34 and then whatever that is we set that and that'll be 32 minus 34. this will be like negative two now and so now we got to do another check here and all we can say is if this value is less than or equal to zero let's do a branch and so if this value is now less than zero we want to kill the enemy so you can do some like complex functionality here where you have like the enemy do all this like animating it's like falling over dying whatever but just to show you that's working i'll just do a destroy actor and so after three shots the enemy should just disappear instantly from the world that's just to show you that it's working so hopefully all this is working now let's play i'm gonna go ahead and one two three he disappears yay something i forgot to do is in the laser here when we apply damage i also want to destroy actor so if you're wondering how i got this to come out so quickly there's a really good shortcut ctrl w just duplicates things so this is very useful when you're programming in blueprint and then another shortcut is you're going to be using these branch nodes all the time for these booleans these true false nodes so just hold down the b key and click you'll get these branch and yeah so now when we play the bullet should disappear so see how it disappears boom he's dead okay so three shots he dies so now the next thing is how do you get your ai to actually move to the player so i don't want to spend another hour doing ai but we'll just do something very simple here the first thing you need is in the place actors here we need what's called a nav mesh bounds volume so just type in nav mesh drag this out and normally you don't want to use these like you don't want to make them too big but this level is way small enough where we can use it i'm just going to make sure it covers the whole level here and then scale it up and then press p and this will show you where the ai can move all the green is where the ai can walk around so there's plenty of paths for the ai to take to come after the player so now let's just make several ai here i'm just going to add several around the player all over the map here so i got like 10 ai or something like that and what i want to do is i just want the ai to move to the player so come up to add let's go to type in perception and you'll get ai perception add that and then in the ai perception over here on the census config we need to add one and then do ai site like that open this up open that up and the site is 3000. now this is the distance to which an ai can detect a player 3000 might be enough actually or maybe not but we'll just leave that as 3 000 and so what i'm going to do now and if you scroll down we get this on target perception updated click that i'm just going to put it right here above the any damage whatever this actor will be the player so when it detects the player it should run our code but let me just check this um no there's one more thing so in the ai perception here i forgot about this but in the sense here make sure you expand the detection by affiliation just check all three of them just check all three of them just makes it easier and then compile that and now the actor here instead of casting to the player what we can do is just in our third person character here we're going to use tags so just go to class defaults at the top here type in tag and then let's add one so click the plus and then just type in player and i love using tags for stuff like this because it's just a lot easier than casting and and you don't even have to use an interface or anything like that so what we can do now in the enemy is we can drag off this actor and we can just type in tag you'll get this function called actor has tag and all it's doing is is so so all that's happening is when the ai detects an actor it's just going to check if this actor has a tag and the tag we want to check for is the player and then we do a branch node with the b key and we're essentially saying like okay i've detected an actor is the actor a player if it is let's chase the player if it's not let's do nothing that's all we're doing so off of this true we can do what's called a imove and you get this ai move to the pawn here is that's actually the ais is right click type and get self we want to plug the ai into pawn but then the target that's going to be our actor here that's going to be our player we want the ai to move to the target acceptable radians do something like 50 and just save that okay very simple ai logic here if everything's working correctly when we start the game the ai will just move to the player so let's play yeah so you can see the ai coming for the player ah it's chasing me help die die so if we go back to the enemy go back to ai perception this uh peripheral vision at a setting of 90 it actually gives the ai like a 180 view so you actually have to be in front of the ai but if you want the ai to chase the player no matter what direction the ai is looking in like an mmo for example then you would do 180 and this gives it like a 360. but if you're trying to do like a stealth type of game where you only want the ai to chase the player when it's actually like looking towards the player i would do something like maybe like 40 and that gives it like an 80 degree or maybe even like 50 to give it like a little more than 90 degrees i don't know maybe 120 maybe 60 would be best for like a 120. but something else you saw it was when the ai finally reaches the player it stops moving and that's because this uh success ran so what you can do is on success if you want to move to the player again you can just make a little let's just do a custom event called chase player i can't spell and then you could plug that into here and then on success just call chase player like that so when the ai reaches the player it's just it's gonna call this event and it'll just chase the player again so in other words it's gonna chase the player for for life so it gets to the player and okay he just ran off i don't where is he going let's go see where he's going oh he's chasing that guy oh it's because i didn't do this check here okay no we need to we need to plug it into here all right let's try that again okay so he reaches me he's coming after me again they're coming after me again they're coming after me so you got some issues with the camera there so you see how my camera gets messed up at certain angles here and i'm trying to get to shogun like that so to fix that go to the enemy ai go to the capsule component scroll down to collision and in the collision presets you can see it's blocking the camera here so i'm about to set this to custom and i'm gonna have to set camera to ignore so hopefully it won't block the player camera anymore but you actually do that in the enemy ai actually which is interesting but now we shouldn't have issues oh it's still doing it i'm gonna select the mesh now maybe the mesh here is blocking it so again i'm going to open up collision presets going to go to custom ignore cameras and hopefully that works now let's try this again still blocking my camera i don't think so i think it worked i think that did it okay so now i can kill these guys got a little error here but we can kind of ignore that it's not a big deal and one last thing is the ai isn't really moving with its animation and that's an animation blueprint issue so i think we're going to make a separate animation blueprint just for the ai so the way we do that is i'm going to browse to the ai skeletal mesh here this heavy armor i'm going to right click and go to create animation blueprint and i'm gonna do anim bp enemy and the reason why i'm doing this is because i can make a very simple animation blueprint in here that will work with the ai and make it so it moves so this is your first time in animation blueprint it's not the easiest thing ever but to make it easy for us here's the players animation blueprint and on the left hand side we have this animation graph so i'm going to go into here and there's all this stuff going on it's pretty confusing but all i care about is this ground locomotion here so what i want you to do is i want you to actually just select this and copy it ctrl c and in the animation blueprint for the enemy here just in the animation graph here just paste it and if you open this up it it brought all this in here which is nice so we actually don't have to mess with any of this so at the top up here just go back go back one more just plug that in you can compile it and you're gonna have an error because it's asking for all these different variables here that we don't have and all those variables are in these transitions so these transitions is how you move from one state to another so by default we want the character idling and then when the character starts to move it does this jog start and then it's running and jog stop but these transitions here you can open them up and here's all your variables so to make it really simple i'm just going to right click this variable and create a speed here boom and do the same with that you can do the same with that all right let's compile so now that fixes most of our problems and we got the three variables here now we got another error down here so just click this get ya delta takes us here let's just right click create a variable compile oh look at that now all of a sudden we are working and we're animating so i'm going to browse to this asset here our new animation blueprint and in the enemy here let's plug it in right there boom okay let's play and see if the enemies are idling so yeah look the enemy is definitely idling its feet aren't moving but we'll fix that right now let's go into the animation blueprint here for the enemy again i'm going to close all this and we want to do stuff in the event graph now so the way you get the speed of the enemy and that's what we need if you remember in the animation graph here we transition to jogging when the speed is greater than zero very simple right what i'm going to do is i'm actually going to delete these just to make it even more easier i'm just going to plug that in so now for our transition we move to jog start only when the speed is greater than zero so that makes things very simple for us and now what we can do in the event graph here is on this update animation if we go back to the animation blueprint that we're using for our player you can see how they get the speed that you get the velocity of the character and then you run this vector length function and it gives you a float values that's literally all you do so you can just copy paste this if you want or we can just drag off this and go get velocity and then we want to get the length of the vector so you do vector length and then now you can bring out the speed here and set it and that's it so that gives us the speed and now when we play now the ai's feet are moving yay so just a very simple setup for an animation blueprint there we could actually probably delete all this stuff because all we're really saying is from idle to run here you can see there's this transition and all we're saying is by default it just had it as if if speed is greater than 100 which it is because by default if you go to your characters go to character movement you scroll down to movement here that's walking your max walk speed this is the speed that the player moves at we have that 600 so if you want your ai to be slower do something like 300 and now when we play the ai is a lot slower see so sometimes their feet stop moving when they fall off these rocks or whatever so what i'm going to do is i'm actually going to delete all this stuff here i don't care about any of that i just want idle to run and i'm going to set up a another transition back to idle so just hold down and connect it and then here we want to go from run to idle when the speed is less than or equal to zero right so bring out speed here go less than or equal to zero plug that in so now it's working everything looks good nice and pretty there is some issues with the ai jittering like that i'm shooting over this guy i have to get down here to get him die thank you all right guys so obviously there's a lot more you could do to make this game like way higher quality but this is just what we made in like an hour right just the basics just trying to get you comfortable with the engine so if you enjoyed this video guys check out my courses link in the description and if you want like a part two or whatever just let me know maybe we'll do like sound effects hit effects dyeing like ui stuff like that but yeah guys that's gonna do it for this video hope you enjoyed it and i will catch you next time
Info
Channel: Unreal Engine Tutorials
Views: 227,231
Rating: undefined out of 5
Keywords: unreal engine 5 beginners tutorial, ue5 beginner tutorial
Id: ROMWCMmNBHE
Channel Id: undefined
Length: 75min 8sec (4508 seconds)
Published: Tue Jun 08 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.