Let's Make a Game in 2 HOURS in Unreal Engine 4 [Top-Down Shooter]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everybody what's up so in this video you're just gonna learn how to make a really simple top-down shooter nothing crazy but it's gonna teach you a lot of the core concepts and fundamentals of Unreal Engine 4 which is really important like a very basic UI spawning monsters having them chase the player attack the player damage the player having the player be able to spawn these projectiles that damage the enemy and destroy on contact so there's a lot of good things in this tutorial video that I hope you'll go through and if you're brand new to the engine I think it'll help you a lot with your development in Unreal Engine 4 so let's get started all right so the first thing you're gonna want to do is make sure you're on the Unreal Engine tab go to library click launch it's gonna open up the launcher where you can create projects so you'll so you'll be presented with something like this you click games for the next like third person even though it's a top-down game we're gonna use third person because I like the movement set up for it so do 3rd person click next and then in here call your game whatever you want I'm calling mine waves shooter and then create the project and I already have my project open so that I can just jump right in so if you click play you can see the character can move around and I like this movement this is how I want it to be all I'm gonna do is adjust the camera so it's up like this right so in order to do that I can actually click on the character in the level and over here in the world outliner I can click Edit third person character it's going to open up the actual blueprint here and you're presented with all this different code here this is just movement right so in the viewport what I'm gonna do we're not the camera but the camera boom here and then I'm going to rotate it so if I press E I have to turn off this now I can rotate it so when you turn off the pitch it'll let you rotate the camera boom which as you can see it's putting the camera above right so I rotated mine to minus 60 and then the length right here set it to 700 and save now the camera boom is way up here which brings the camera with it because the camera is attached through the camera boom so now when we play we got this top-down view like this right and this is how I like it for this type of game so the next thing you want to do is in the is you want to come to your launcher here go to market place and let's add the character so to find the character go to free Epic Games content and then just start clicking over and let's look for her her name is sergeant Bella cos we just have to find her she's on one of these pages he has to be on page one there she is the very first one okay so here she is just click ER and then add to your project it's gonna take a little bit to download so just pause the video and then come back alright so once you add it to your project your content browser might look like this just click this button here in the left now you'll have all your folders you can click Paragon lieutenant delica and what I want you to do is go to filters click on level and then open her level up the reason you want to do this is because it's gonna compile all the shaders for you and that's gonna take like 20 minutes maybe more maybe less so pause the video and when that's done just come on back alright when that's done here are the 5 characters 1 2 3 4 5 6 ok I can't count there's 6 characters it's up to you which character you want to use they'll all work with this project they all run on the same animations so just pick one I use this one in the example project so I'm going to select her I'm gonna come to the third person character here and under mesh I'm going to click the mesh and then right here is where we can add that character so what you need to do is select the character you you want click the magnifying glass it'll browse to it and with this character selected you can now hit this arrow and plug it in so there she is and we need to add in her animations so this is where you put the animation blueprints right here if you don't do this if you forget this step then your character will just look like this all the time and when you play wrong level let me open up the level and when you play she'll just look like this so you have to plug in the animation and these characters come with the animations which is awesome so what you can do here is either find it in the drop-down I know what it's called this one's lieutenant bellick ax but if you didn't know what it's called then you can always just look for it it's right right here so I just grab that and plug it in nice little shortcut we don't have to make an animation blueprint from scratch you want to learn how to make animation blueprints there's plenty of tutorials out there so anyway now she's plugged in and when I play she does animate but we might have to make some changes because she does that long introduction which is kind of annoying but yeah we'll get to that when we get to that okay the next thing I want to do is set up her firing that's pretty fun right so let's do that let's go to edit project settings go to input and this is where you input actions and such that you want players to do so in our case firing is an action access is more about movement as you can see moveforward and moveright these are things for your mouse and your game pads and keyboards and things like that but for action mapping this is more for like attacks and things like that so I'm going to type in fire and in our case I want this game to work on both a gamepad and the mouse so I will type in left left mouse button here it is and then I'm going to click the plus sign gamepad here I believe it's the right trigger axis right button on the gamepad that should be the fire I think it is if it's not you can always come in here and change it and mess around okay all right now in the third person character we're ready to set up firing so what I'm gonna do here is I'm gonna delete this because that's a virtual reality we all need it this is gamepad input so we want that cuz I wanted to work with gamepad mouse input we want that jumping I'm actually gonna delete jump I don't want jumping in my game you can leave it if you want and then I will also delete touch input because this isn't a touch game we're not making an android mobile game alright compile save I'm gonna select all of this stuff here I'm gonna press C for comment and I will type movement this is just to keep it organized and I'm gonna move it over here off to the side and you can change the color of these comment boxes if you want I'll do something like that compile save alright so the next thing we do now to fire I'm gonna right-click and just type in fire and this action event will pop up which we just made so if you've never used blueprint before this might seem a little difficult especially if you're brand new to the engine which you probably are if you're watching this but we do logic through blueprint you do all of your game logic through it so for example up here this input access turn and look up these are from the project settings right here the input here's turn and look up so this is for the mouse and these two functions here are from the engine they're from pawn right it says pawn so the reason why this is able to work here is because we're actually a character you can see in the right corner it says character a character is actually a child of pawn so that's why we're able to inherit this stuff here these functions come from pawn but the character can use it because it's a child of the pawn okay so all the movement logic is actually in the pawn class you can actually go into C++ open up the pawn class in Visual Studio and look at this logic in C++ if you wanted to if you've programmed before in the past then this might make sense if you've never programmed then this probably doesn't make sense and that's okay you'll learn eventually just like anything it just takes hours and hours you put in you know a thousand hours into learning the engine and you'll be really good at this stuff okay so think of your journey in Unreal Engine 4 as a very long-term lifestyle as what I like to say okay like commit to learning this stuff for the next several years and just make this a part of your life it's a fun hobby and just always be getting better at it that's the key a case of firing now how do we know if this works well there's this function called print string so if I drag off and type in print string when I click the left click or when I press the fire button in our case the mouse is left click or the right trigger axis but again you could set but again you could set it to whatever you want either case when I press that button it should print whatever it says here so I can say firing for example and this is a good way to help you test things as using print strings I use them all the time and you'll see in this project so when I play and I click left click it says firing right every time I press it says firing so that means this input is working now I do want to get rid of that little this little introduction she does I kind of want to get rid of actually know what we'll leave it well we'll set something up so the player can't move until that intro is finished so what I'm gonna do is I'm going to browse to the animation blueprint here I'm going to open it and in the event graph here it's just blueprint as you can see this is this is what's happening so the player starts the game it's gonna run this begin play event and it's playing this montage montage is an animation so it's just playing this when we when we start the game that's what begin play any class you make and blueprint anything you run off of the begin play will fire right at the very beginning of the game or when the class spawns okay so as you can see begin play plays that animation right here level start I'm gonna do is I'm gonna open it up and what I did here is I just browse to it again so see it plays this at the beginning I'm trying to get the time here so it's about a four second it's about a five second animation so I'm gonna do something that's kind of interesting here back in our third person character blueprint I can right click I'm gonna type in begin play you get this event begin play and like I said anything we do off this will fire it right away okay so what I'm gonna do is I'm gonna drag in this character movement this is a cool little tip that you can do all of these components up here on the left you can actually drag into the graph editor here you can do things with them can drag off of this and there's lots of stuff that you can do with the camera boom for example but basically if you click on it if I click on character movement I have all of these things here on the right these are all the things that you can edit when you drag the when you drag the component into the editor here if I look off this for example it says gravity scale but I dragged this off and type in gravity scale you can see it's right here get gravity scale or set it so by default it has one but if I wanted to I could set it to five at the beginning of the game I'm actually gonna drag off of this and type in disabled I'm actually going to disable the movement at the beginning so when I play I won't be able to move right see I can't move right now can't move I can look around but I can't move so I'm going to disable the movement and then off of here I'm going to type in delay and the animation was 5 seconds long so I'm gonna delay or five seconds and then what I'm gonna do is there actually is no enable movement if you type in enable movement nothing will pop up so what you actually have to do is if they get a little creative I type in movement and it says set movement mode so I can select that connect these up and then actually if I set this to walking we'll be able to move again so if we play we can't move and then after five seconds we'll be able to move again so now we can move so it's like we're doing this little pause for five seconds letting the animation play and then enabling the character to move and if you wanted to get really creative what you can do is use the sequence editor here under since under cinematics you could make a sequence which might have the camera do something like coming in close on the character and then also it like comes back up here then the player can move again if we have time I'll do something like that but for now I just want to get you playing your game so anyway we got some very basic movement stuff going on but let's actually fire the bullet right we're gonna make that laser that's emissive that the player can shoot okay so to do that we have to make a new blueprint actor so up here I'm just clicking at the base content folder I'm gonna do it right here so I'll just right-click go to blueprint class and now you have all these different classes here so our third person character for example is a type character and like I said character is a type of pawn that includes the ability to walk around so here's pawn which is just above it you actually won't use pawns too often but there are cases when you will use them but for the most part you'll stick the character for doing things like AI and players and things like that player controller these are actually useful as well I use these all the time for multiplayer games game mode base will need this as well for the actual playing levels so as an example I use a I'll use one game mode for the main menu and then I'll use another game mode for the actual playing levels or like if you have a lobby system you might use a different game mode for your lobby and then a different game mode for the actual playable levels and the same thing for the player controller as well there are ways where you can use one for everything but to keep things simple I'll use a plate all these a player controller or the lobby levels are like the main menu things like that and then a different player controller for the actual game but for now what we want to do is just create an actor so anything in the level is an actor so characters or actors like a chair you place as an actor a moveable door is an actor a bullet that you fire is an actor so we're gonna create an actor BP underscore laser I guess I don't know how to spell laser' there it is this is what the player will actually fire okay so let's open it up and on the begin play here like I said anytime an actor is spawned in the level in our case every time the player presses the fire button we're gonna spawn a laser and so anything we do off of begin play will fire right away so in our case here because it's a bullet that's getting fired we might want to play a sound right we'll play like the laser sound so what we do is we rag off of begin play type in play sound it place down at location well and so the sound this is where you would plug in the sound I don't have a sound effect right now but we'll get one later and I'll show you how to get sound effects for free and then for the location here it's asking us where do we want to spawn this sound where are we gonna play it at and we want to play the laser where it actually spawns in the world so for example the player is at location negatives 75033 90 on the Y and 226 on the Z right that's just an example of the location so wherever this player moves to the location will change so you can see it changing so what we want to do is spawn the laser sound wherever the laser is gonna be so when the player presses left-click the laser actor itself will spawn right here on the muzzle so we want the sound to play right here okay now it's not it's actually not complicated I know it seems complicated but all that this means is that when the laser spawns right here it's gonna play a sound right here the way we do that is we can just right-click and type in get actor location and all this means is that wherever this laser is when it spawns in the world that's where we're gonna play the sound so we just plug that into here you can see the colors are the same so yeah that's actually very simple this get actor location is one of these functions that you'll be using all the time because you're just literally getting the location in the world of where this actor currently is so so this is what we'll do the very beginning we'll play a sound right it's just going to play the laser firing sound now the next thing you want to do is we want to come up to component and add a mesh click mesh I'm actually going to drag it on to the top here because we don't need that scene component and where is it if I select it and press a path but we don't have it it's just not done here so you want to type in sphere and which one do we do I believe it's just this one sphere there we go and now what I want to do is scale it can I type it in one point two one five there we go so I can't use the actual scale tool to scale here but I can type in the scaling so I'll just give you the numbers so instead of one do point one zero and then in step one do point one three seventy-five though it's just like a bolt compile save and then now we have to actually make the material so if you've never made a material before it's okay I'll walk you through it so come to the content browser right click go to material I'm gonna type in M underscore emissive and be a very simple emissive material and this isn't a lesson on materials there are people that all they do for their job is make awesome materials it's like that's their job right special effects type stuff anyway to do emissive you can see there's emissive color here all we're gonna do is holding down number four on your keyboard just pull it down and click at this color we want it to be a parameter now I'm going to type in color so make sure you right-click it and convert it to a parameter and right now it's black I'm going to change it to white so it's open it and go 1 1 1 it just does white now you can plug this into the base color and you could plug it into emissive but what we're gonna do is holding down em you get a multiply node here so just plug that in and then plug that in and then off of here if you right-click B you can now promote two-parameter will call this intensity and now you can set this to one for example now save okay so again just pause the video if you need to but this is how you make a very simple emissive material okay now this material we're not going to attach this to the weapon what we're gonna do is we're actually gonna right-click emissive and create instances so this is where you can have all these different colors so for example let's say we want to make a red laser right so MI for material instance then red and make sure you're doing create material instance now when we open this up we have these two parameters here so now we can adjust the colors in here that's why we took these two things here and made them into parameters so any value you have in a material if you convert it to a parameter you can then edit that parameter in the instances here so for example you want red I'm gonna select the box here I'm going to click this and then now we can make red C so let's do something like this I guess one on the red and zero and everything else that makes sense all right and then for the intensity I'm going to check it and then watch when I start bumping it up it's really bright right so you can see how bright it is here so we might need to do like 150 for example now I can browse to this material I can come back in the laser and then I can apply it to the mesh here boom right that is so again now with this material setup you can duplicate this so you don't want to right click and create another material instance because then you have to come in here and set up all the parameters again so what you do is you just duplicate the material instances so now I'll call this one a my you know blue for example open it up change this to blue right one here zero zero okay now I can take this plug that in we have a blue laser okay so you can just keep on making more instances here maybe we want green so now we do one on the green zero on the blue now we have green I can plug that in so now we have green okay so you can keep going making all different colors that you want leave that up do you okay so we need to set up away and make the mesh register hits and the way you do that is through collisions so if you click on the static mesh here you scroll down you have collision settings here okay collision is really important it's probably the most important thing to learn and understand as a beginner you have all these different collision presets here and you can actually come into the project settings and come over to collision and then here are all those presets you can actually make your own presets you can make your own object channels and as an example this static mesh by default has an object channel of world dynamic and what that means is that it's most likely just gonna block everything you can see the object type here or I'll dynamic we have pond physics body etc and so it's kind of confusing but basically in these settings so for example pond that's our character right our characters a pond we open up pawn pawns will block world dynamic objects that's what this means so a pawn will block all of these things right the vehicle hits the player it's gonna block it okay so this laser by default static meshes are world dynamic so this means that the player because the player here if you come to the capsule component this is the player's collision basically this capsule component is set to pawn that means by default it's going to block world dynamic objects now you don't have to use these presets you can go to custom here and then you can set them how you want and actually what I want to do is I don't want the pawn to block the camera so I can either set it to custom and change it here or I could come into the project settings open up pawn here and set it to camera I'm actually gonna keep it on custom because for me I always just set things to custom I'll just come to custom and then change things around so make sure I'll make it so the camera is not blocked and but I'll keep all these how they are here and then here's where you can you know you can disable collision enable collision do query only etc query just means overlapping not like physically blocking objects and will actually use query for a lot of things like when I do melee combat I usually use query or a lot of for lava combat because you don't want your actual weapon getting blocked by the model like the actual physical the physical model like imagine your sword is actually getting blocked by the player that means it would hit the player but not be able to like go through the player if that makes sense so queries really important for certain things then you have physics and all that but I'm not gonna really simulate physics or anything but again collision it's not advanced at all but it's very important for beginners to study the collision learn about it epic has a lot of documentation on collision so I highly recommend you check it out this one's really important here as well generate overlap events if this is false then the object that you're working with won't do any collision stuff so they might still be able to block objects and things like that but for the laser for example if we turn off generate overlap events then we can't overlap the player down here these are all the different events you can do but what we want to do with our object here is that I want this mesh - we're not gonna use an overlap so if I was gonna use an overlap for example I would come down here and say on component began to overlap and like I said overlaps are really important you'll use them a lot in your game development like Ford or like if you want the player have a door or if you want a door to automatically open when the player gets close to it then you would use an overlap event or maybe you have like a spawner like the player walks into a certain area and you have an invisible box there that will basically fire an event when the player walks into it like maybe it spawns a bunch of monsters then you'd use it an overlap for that but for our case what I'm gonna do was the static mesh here is I'm gonna click this simulation generates hit events look compiled save and now what we can do I want to use event hit this one right here this is the one I want this right-click type in event it and then you'll get that and this one's really important because we don't have to add an actual like here's closer down here we actually don't have to add a sphere collision or something on to it we can actually just use the mesh by itself now what I want to do with the collision here is in your project settings in the collision tab I'm actually going to set up a new object channel go to sew click new object channel I'm going to call it a projectile and by default it's block right so anything it hits will block it so accept that and I'm gonna do now in the laser is I'm actually going to set this to custom on the aesthetic mesh and the object type will be a projectile but actually I need a compiled save and close this and then reopen it and then it should show up yeah so now it shows up so you have to reopen the blueprint so the object type will show up so I'm gonna change it to projectile here and what this is gonna mean is that in the player so I I have to reopen this blueprint as well because down here you're gonna see it says optic responses when I reopen this blueprint you'll see projectile here watch so I'll close I'll browse to it first and then I'll close it and I'll reopen it and now under the capsule component see projectile and it says block so that's what we want now there know what's really important here is that the capsule component this is responsible for damage and things like that you can set it up to where the actual player mesh can register damage and things like that but I'm not gonna go over that in this video because this is just like an example simple game that we're making but understand that yes you can do mesh collision which is really important for first-person shooters right you don't want to shoot like in this empty area but register a hit because it's the capsule you don't want to do that you want to do it's through the actual player mesh and so I do have a tutorial series on making a survival game I'll link to it in the description and that one we are using the mesh okay so that's like an FPS if you want to I know that's still third-person shooter but we're registering all its shots through the actual mesh and that's because that's a multiplayer game it's designed to have other players and so that works for that type of game but for this type of game we're just gonna keep things simple ATS single player and the only thing that's gonna be hitting the player our actual AI right so there's no reason to get crazy with the collision but anyway you can see here that the third person character blocks projectile I'm actually gonna have the player ignore projectiles that's because it's gonna spawn close to the player I just want to make sure that this player doesn't collide with the bullet when it gets spawned the a I will have the AI block it though but for the player itself no we want to ignore the projectile now with that said we're still gonna have to do another check because in the actual laser if you come to the mesh it says it block spawned so this mesh might still block with the player and then if that happens we'll just do some additional some additional code to make sure that it won't collide with the player but for now this is what we're gonna do so let's just get the player shooting this projectile we're not gonna do anything with this event hit yet I just want this reject I'll actually spawn in the world so what I want to do is come up to add component I've been projectile and you'll get projectile movement so like you might imagine this is actually responsible for moving the object in the world when it spawns so this initial speed in this max speed here I set these to 3000 grab the scaling set to zero so there is no gravity hit simulate you'll see it moving see I have this check but I don't think it matters I come down here under planar movement I'm going to check this and then I'm gonna put a 1 on the Z and there is one more thing I want to set up so if you click on class defaults class defaults and any blueprint is very important any variables you make down here will get added to the class default so you can set those defaults in here so I'm going to disable the tick we don't need that and then if you're playing a multiplayer game you would turn on replicates here oh this isn't multiplayer so single-player so you don't worry about that and then down here is important this initial lifespan this sets how long this laser will last in the world so if I set it to zero it will last forever but we obviously don't want late the lasers lasting forever I'm gonna set to three so that you know what the player shoots if it doesn't hit anything it will just go away after three seconds all right and then we actually want the player to spawn it so well what we want to do is the player presses fire we can do what's called ace if you type in spawn actor you can get spawn actor from class I can actually plug in this laser months a spawn transform is what this is asking is where to spawn it in the world well obviously we want to spawn it near the player right so what I like to do in our case here you can't really spawn it on the gun here because the guns attached to the player but what we can do is I can come up here and I can add what's called just an arrow component unfortunately you can't use this one that's inherited I can add this and just call it spawner and then now I can take this and position it and of close to the gun okay something like that divvy up one more and from a top-down view it'll look like it's coming out of the gun okay it's a very simple way of doing it so it's not compiling because it needs something in the transform so I can take this spawner now I might need to move it under the mesh but for now let's just do this and I can right-click and do git or I can do transform you'll get get world transform plug that in and then now it will compile so now in the viewport you can see how it's here now what I want to do is by default these arrows are hidden in game so if you click on the arrow a spawner here you scroll down it says hidden in game this means the arrow will actually you won't be able to see it right but if I uncheck that just for debugging purposes I can now see it and I want to see what happens when we move the play around let's see what happens to the arrow so see how the arrow is attached okay our laser is huge and what's happening is we are I am spawning it but it's obviously huge and that's not gonna work so and what you actually saw there was the camera getting blocked by the projectile and the camera tends to get blocked a lot and if you remember I was talking about that earlier so in the laser here in the mesh I want to ignore camera let's see if that fixes that issue yeah so that fixes the camera issue obviously I got to fix the laser there but you can see I'm not getting stuck in the actor anymore to fix the actor this scale doesn't work you set it here I forgot about that that just doesn't work and the way we can actually do that to get this scale to work it's kind of it's not like a hack or whatever but basically whenever you have a mesh or an object that's just at the root here the scaling actually doesn't work or transform or whatever so for example if we come to the third person character I click on this capsule I can't really like move it around or rotate it even if I scale it it's actually not gonna scale I have to adjust it through the shape here so what you can do you can either add a scene component on top of it or you can set the scale when you spawn it and I'd rather set the scale when I spawn it because the less components we have in here the better on performance right just it's just one less thing for the engine to load so I will keep this scale number here because we're gonna need it it just has a reference but if I come to the third person character now what I can do here is I can actually drag off of this spawn transform and type in make transform and then down here I can now set the scale yeah so but I found a good scale to be as one on the X point one zero on the Y and point one three seven five right I think that's what we had here something like that and then instead of get world transform here we now need a location so now we can just drag off here and do get world location plug that in there's another there's another function we can use here it's called get actor forward vector this from this vector we can actually get a rotation so if I drag off this and type in rotation from expector there it is look that in so I know if you're brand new some of this stuff is foreign but more you play with this engine the more you'll start to understand what we're doing we're just getting the location of this spawner in the world and as you saw it's following the player around so as you can see spawner is in front of the player and once we start playing it's following the player so when I left click this location of this arrow is where will spawn right now the thing is obviously way too big now it's not moving because I'm pretty sure it's colliding with the player so it's stopping and again that's because lied with pong need to make this a lot smaller maybe something like that so this is the number I need to remember 0.8 and then this number here I can actually copy it and then paste it all right let's see if it's a little smaller yeah see so now it's actually firing it's not getting stuck on the player now now it is so I'm just messing around with the numbers here trying to get a good number I'm happy with the size there but is it still being stuck on the player that's the question so it is and the reason for that is because it's spawning on the middle so this the middle of the object here this is zero zero zero that's spawning right on this part here so actually half of the meshes over here so it's touching the player I just need to drag this out that now hopefully it won't collide with the player anymore see so it's not colliding with the player anymore so you can see it hits an object and then and then it disappears after three seconds so even if the player fires off-screen it will disappear after three seconds and then yeah so now we got shooting so now that we know it's spawning and shooting I can come back into the player here I can select the spawner arrow and then just set it back to hidden now it's going okay so one other thing I don't want the player to be able to fire while in this little intro animation so I'm gonna come down here make a new variable it's gonna be a boolean called can fire so if you don't know what a boolean does all it means it's a it's a true/false check I'll show you so I'm going to drag this off here so by default boolean's are false so after five seconds I'm gonna set can't fire to true so now it's true and then down here you can drag the boolean into the world or I'm sorry into the editor and then I can right click and get a branch this is like an if statement it's basically saying if can't fire is true do this if it's false do that in our case here we only want to be able to fire if it's true right after five seconds we set it to true and then once it's true we fire so just to go back here you can drag this into the world so can ask if you want to get it or if you want to set it if you get it it's gonna be small like this and then set means you can set values so if you have a float for example these floats here if you set it then you can set new numbers so you can set things like HP and things like that which we'll get into but now I won't be able to fire until five more seconds so I'm clicking clicking clicking clicking now I can fire five seconds later okay but I'm also gonna do is I'm gonna disable shadows on the static mesh I actually don't know where to do that there it is under lighting cast shadow no do not cast shadows I'm actually gonna right-click and type in self I'm gonna plug this into the owner so the player is the owner of this laser every time he shoots the players the owner that's what this self is this self is actually really useful as well you'll use this a lot in your game development and all it means is you're just plugging in a reference to this blueprint so in our case here we're just plugging in the third person character in this blueprint for example it would be the laser alright so now I want to actually register hit write because it's a single player game the laser is only going to register hits or cause damage to AI so let's come to the content browser here and let's make a new character we'll call this the VP underscore enemy base call it the base because from here we can make children and so you can have one base enemy where you have all the core functionality and then you make children for all the different AIS like all the different monsters you have in our case I'm gonna drag I'm gonna make a new child we'll call this the enemy underscore marine enemy and the reason why is because we're going to use this asset pack which is also from Paragon that's called minions and so you're gonna need to add this I forgot you have to add this as well so type in Paragon once again and we just got to find what's called minions here so we come over here and we have minions right here so just add this to the project do the same thing where you open the level let it compile and then come back to the video okay so pause the video now add this to your project this is the level when all your minions are compiled this is what it should look like and you have a lot of different minions here and I've gone through a lot of them and the problem is that some of the death animations are pretty weird like they end abruptly and I'm not really sure how they or how epic originally used the death but I know what this guy here his death animation is pretty good so I'll use him for this example I make a new folder here and just call it underscore AI and this just puts it at the top with the underscore I'm gonna drag the enemy base in here and this guy will call forest or something because he's got plants on him I already did enemy green here right maybe you want to use this one I'll call it enemy forest so in here I'm gonna open this up and now for the mesh I want to add this mesh here so I need to come to the details panel here here's the mesh I can just browse to it and with it selected I can just add it to the mesh alright and like before I need to rotate it 90 degrees because it needs to be facing this blue arrow and pressing W I can drag down and I'm gonna go to a right view here so I can get it really accurate I'm gonna turn off snapping okay let's now fix the capsule it's obviously way too big so I'm going to click on the capsule component change the height to maybe 60 and I should have actually changed the capsule first because now I want to bring this guy up b-66 is good back to a right view here think again okay so 66 is still too big let's try like 62 he's about right and now the width I want to change the width now so the radius is try 30 so 30 seems to be be good so anywhere that the player hits on this capsule will do damage to the AI now what we want to do with the player we have the player shooting the laser so in the laser we gotta set this hit event here now so we basically want to say that when this laser hits something and do something so for example you want to open up the base class and you can do that if you're in a child you can click this wrench over here on the right and it will open up its base class so the base class is where we do most of our logic unless you want this specific enemy to do its own like unique abilities or something you might as well just put all the logic in the base class because anything anything we do here in the base class all of the enemies can use it so for example I'll put health in the base class I'll do damage in the base class I'll do you know dying in the base class we'll do the a I like roaming logic and stuff in the base class we do that in the base class because then all of its children can use it so in the enemy base for example let's create a variable and just call it health and we'll make this afloat now we have health so now we have health in the enemy base if I come to the child here that's enemy force if I click on defaults you can see health up here so now if I come to health in the base class and change its category to help whoops but change it to health and compiled now in the forest it can say healthier in the category so let's say as a default will set itself to 100 and other enemies like if you were to make other enemies you could set their health to whatever you want I'm also gonna turn off tick here actually you got the the health is set to zero on the enemy base but you know and you know I'm actually gonna set this to a hundred on the base class too just so we have a base setting but maybe you have like a big enemy that has like 300 health or something so the next thing we want to do is with this hit event we got to do something that says whether we hit the enemy or not you want to know what we hit if I just do this if I do a print string here you'll notice print strings are really important to use because I can just plug in this other right here this is just other actor object reference and actors remember enemies are actors rocks or actors trees or actors everything's an actor right so I plug this in compiled save and then if I come to our third person example map when I shoot something it should print the name see in the left corner it's actually hitting itself they're hitting the wall 11 hitting wall 9 getting the linear stair hitting the cube mesh so you can see it's registering what we're hitting I take this enemy put them in the world here and then when I play I know I got this really annoying five-second intro but it is what it is and I play and see it's saying I hit the enemy forest actually just notice another issue the enemy is a little small definitely want to make him a little bigger so let's come to the enemy here we're going to scale them up let's do a let's hit this lock so it's all uniform go one point two let's just see how that looks still pretty small MIT but next to layer you can see it's still really small so let's try one point for okay that's better let's do 1.4 and now we got to fix a capsule again so let's just do default and let's move the mesh down again this is just part of game development and there you go that's actually looking perfect he's pretty big it's fine I'm happy with that there we go so you can see it's registering his name in the top left corner so I really encourage you to get good with the print strings use these all the time trust me any time you make something run a print string to see if it's at least feeding the proper information in the corner that'll help you a lot in your debugging process anyway we know it's working so now I can delete it we know it's registering hits so now we want to do something when it hits the enemy so and a lot of courses they'll have you cast they'll go like cache to enemy base like this but we actually don't need to do that you do what's really simple and just come to the enemy base here come to your defaults and at the top here just type in tag and we can add a tag to this and just call it the enemy and what we can say now on this BP laser off of this other we can type in tag and there's this function called actor has tagged and then right here we can enter the name of enemy and off of this boolean remember we use a branch node right a true or false so we just got a hold down B and then click and get a branch node and so now all we're saying here is event hit is this actor that we hit in the world is it an enemy if it is do this if it's not an enemy than do that well in our case if it's not an enemy let's just destroy the projectile right so play we're basically saying anything that this laser hits that's not an enemy let's just destroy it say so destroys on contact now if I hit the enemy it's not going to destroy see that's what's going on here now if we do hit the enemy what do we want to do well we want to apply damage so epic comes with these damage functions by default so if I come off the true here and I go apply we have this damage you can do just this is like any damage I'll just use regular damage apply damage in damage class make sure you select just damage type here it comes with the engine as well and then the base damage here we can just set the damage do you want to set it something like 25 all this means is that every time it hits the enemy in our case it will do 25 damage and our enemy has 100 health so after 4 shots it will die right now nothing's really going to happen because we haven't set up the event here I'll remember here remembering our third person character when we fire or spawning this laser and then I plugged in this owner right I said the self is the owner if we come into the actual laser now when this laser spawns it it knows the player is the owner so for this damage cause aright here I can type in get owner you can plug that into the causer there because it's acting it's asking for an actor instigator asks for like a player controller for example and you can use that as well you could also come in to the instigator here and plug in your player controller and in in our case we won't do that but you will have cases where you're spawning stuff from your player controller and maybe you want to plug in the player controller to the instigator because the player controller exists both on the server and the client and a person and it persists so like for example if you're playing a multiplayer game and if a bunch of character is running around your level right you're playing like Call of Duty or whatever when you kill a player it's it's character dies on the screen you know does like it's death animation then it D spawns and the player responds so in that case what's happening is this character actually gets deleted and then it gets respawn as a new character it's the same player but it's just like his new characters got all his health back and everything so the player controller doesn't get deleted but the character gets deleted if that makes sense okay so in our case were shooting with the character so we want the character to spawn the laser now in the enemy base here actually is come to the laser so we're doing this applied damage how do we actually transfer this damage to the enemy now well if you come to the enemy base I right-click and type in image we now have these events here event any damage point damage radial damage well we just did any damage so I'm going to grab that and now again if I do print string plug-in the damage type here and so let's see if we can register damage should say 25 in the left corner if it's working okay it's not working and the reason it's not working is because I didn't plug it in the damaged actor here mistakes I just got plugged that in the damage actor is this enemy right that's coming here we're checking we're making sure this actor is the enemy so now is plug it in you can see it says 25 in the corner okay now what I also want to do is after we hit the enemy I do want to destroy the laser as well or else it's just gonna keep hitting itself and we don't want that to happen there are other ways we can prevent it from collision as well so we hit the enemy we're doing 25 damage each time but just to make sure we're not hitting other projectiles I can come to the static mesh here in the laser and I can have it ignore projectile down here this is just so it won't hit itself okay even though we're destroying it it's just another safe thing that we're doing we actually don't need this break result anymore okay so now we're hitting the enemy we're applying damage remember this forest has a hundred health and the player is dealing 25 damage with each laser bullet so let's come here and we can do some simple logic we can say we can get our health for example so this health is a hundred damage coming in is 25 per hit so we want to update the health so how do we do that well because this is a hunt 100 and this is 25 we want to subtract this damage from the health of the enemy so we can just do something simple like a float - a float just type in - - so we go 100 minus 25 equals what it's can equal 75 if we do a print string here it'll say 75 so we need to set this health to 75 so the way you do that it's just drag off set health connect it up there so what's happening is the health is 100 we have 100 - 25 it's now 75 when the enemy gets hit again it's now gonna be 75 - 25 now it's 50 it's get gets hit again now it's 50 minus 25 so on and so forth basically what happens is after 4 hits the enemy dies so we can do what's called a custom event just right click type in custom you can now add a custom event we'll call it death just death right what we can say is when the health is equal to 0 or less than zero kill the enemy and the way you do that is I can bring out the health here and I can go is health less than or equal to zero we have a boolean here so we have to use a branch so I can hold down B and click so we can say every time the every time the enemy gets hit we're gonna check if the health is less than or equal to zero if it's not less than zero then just do nothing but if it is then let's kill the enemy right so let's see if this works I can do a print string and type in enemy dead so after four hits hopefully this death event will be called all right so let's see if that works woopsy missed one two three four up left corners enemy dead so we know it's working now with that what we want to do is actually play some sort of animation when the enemy dies and the way we do that is we can just play an animation right so let's come to the minions here but this folder is really big not sure where this enemy is so I'm just gonna select it here and browse to him okay so we come to this folder there's an animations folder here it's called buff underscore white so in his animations here there should be a death so here's a little death animation we don't want that one though it kind of stops Midway it use that one that one kind of stops as well maybe that one sees that one I know that one can see these deaths kind of like stopped abruptly it stops with this leg up in the air that just looks weird not really sure why it does that this one he's like in midair dead I don't really understand I'm just kind of the downfall of these of this pack I guess let's just use this one so we can grab this and I can say play animation from the mesh automatically brings out the mesh I can plug that in if this doesn't work we'll do another way we'll do it through the animation blueprint soon for times ladies the animation so you guys you can see it kind of stops abruptly looks weird and that's just because the the Paragon game I'm not sure how they program the actual you know death maybe it plays the death animation and then they do some like ragdolls setting or something I don't know anyway we'll just leave that for now like this and then what we can do we can delay for like you know five seconds destroy actor so basically what is happening here is the enemy loses its all loses all of its HP Dyess we play the death animation and then after five seconds we remove the enemy from the world okay so just to show this in action one two three four then after five seconds they'll disappear and there he goes okay so now let's make him actually chase the player right when I previously made this game I use behavior trees but we're not going to do that because it's such a simple project there's no reason to well let's do some simple chasing but we still need an AI controller so we got to go to the enemy folder here the AI folder and we need to right-click and create a class it's gonna be under this all classes tab so you got to click that and then type in AI controller you want the detour crowd controller hit select and then type in EP underscore ai controller okay now back in the enemy base here you gotta come to your class defaults and under pawn you'll see AI controller class we have to select this and choose our bpai controller and then for this auto possess AI just do a placed in world or spawned okay that's it let's open up this AI controller here so we got to do a few things in here you gotta add what's called a pong sensing component so in add components you can just scroll down there's pawn sensing we want the AI to sense the player right especially for like a wave type game that we're making the AI is gonna spawn and detect the player almost instantly and start running to the player so to do that set the peripheral peripheral vision angle to 180 this is basically 360 they'll see the player at any angle the site radius I'll keep it at 5,000 for now we might need to bump that up and then here in the event graph you want to right-click and there's an event called on possess basically what this means this is almost like a begin play but basically what this means is when the AI is spawned and the character is spawned you know has this AI controller class this AI controller is gonna run logic here too because it's going to say okay the AI spawn I am possessing this AI so now let's listen run logic here so all I want to do with this is I'm just going to cast to enemy base here then I can promote this to a variable and we'll call it actually no I'll just call it enemy access anything in our enemy from this variable here we can access death for example if we wanted to it access health so you could actually do a lot of logic in the AI controller but I'm not really going to do that but I want to do though is do the target sensing okay so here this so if you click pon sensing there's these events here on the right on see pawn here noise etc we want on see pawn so basically we this is saying when the AI senses a pawn meeting the we're gonna say if it's the player then do something okay so the sensing intervals every 0.5 seconds you can change that to 1 second if you want to be a little better on performance but I'll just keep it at 0.5 well how do we know if it's sensing the player well we can use the actor has tagged again I believe yep actor has tagged and so in our third person character which is the player and our defaults let's set a tag for the player now you can type in tag all player here I can type in player we can do something when we sense a player okay if it's true we actually want to promote this to a variable actually we want to take this off and do promote to variable we'll call us the player target okay and I'm gonna show you why we're doing this it's true if we sense a player set it to the player target okay now this next part is actually really important might be confusing so I'm going to drag off the player here we're going to do a get I'm going to right-click and do convert to validated get and what we're doing here saying if this variable is set already then don't do anything don't continue if this variable has not been set then let's continue it's not valid so we want to set this variable and the reason why we're doing this is because once the AI senses the player we don't want to keep running this over and over again right we don't want this logic running every 0.5 seconds so we'll just have it not do anything because the variable is now valid so we won't do anything so basically what's happening is this whole thing will only get ran one time the AI will spawn it will sense the player and it will never set the player ever again which is what we want unless the player you know in your game like you might have a situation where the player runs away from the enemy and the player gets far enough away and you want to reset the AI then you would set this variable to nothing you would just bring it out somewhere and do you just leave it empty but in our case the player spawned or in our case the AI spawns it senses the player it sets it to a variable and then because it's now valid it will stop it will stop running okay so I know it's kind of confusing but it's a it's a really important part of this logic here now once the player target has been set you want to run an event that will have the AI move to the player so I come to the enemy base here I can do a new custom event will call it move to player or maybe maybe chase players better and then we actually want to make an input now in this event what we want to do is we want this AI character you want the Forrest character for example to chase the player right so we're doing the chase logic here in the enemy base you could do it in the AI controller but I'm going to do it here so the way we do that is we need our character to know what this player target is the way we do that is actually here in the event we need to add an input what do we add here right well we need to add this target and this target is a pawn so here in the event I can search for pawn it's an object right it's blue and then here I can just type in target for the input its announces target and so now what I can do is in the AI controller cuz we set the enemy base here at the beginning I can actually bring out the enemy here and now I can type in chase player and then we get that event hook it up and now the player target we can plug in the target and I'm going to connect it like this now if you double-click chase player it brings us to the enemy and now targets coming through right so what we want to do is we want the AI to chase the player right so there's a function called AI a move to we want to set it here pawn is a reference to self I think in destination we can ignore because we have a target actor that we're moving to test this right now but before we test it we actually need what's called an navmesh so you got to place actors in navmesh they'll give this navmesh pounds volume and this basically is a volume that says where the AI can travel to so if I scale it up with the S key and then moving around if I press P all this green is where the AI can move to if I come to the world outliner there's this recast navmesh default so if you ever delete your navmesh and make sure you also delete this recast navmesh so when you drag the navmesh in the world it creates this nav mesh actor make sure you delete this also if you delete the nav mesh now when I play he moves to the player we don't want to stop on success right so what's happening is it successfully reaches the player that's it we wanted to always move to the player at least for the most part we're gonna make some changes where when it reaches the player let's do like an attack so actually let's just set that up now custom event attack all right we want the AI to tag so on success attack the player what we can do here is we can play an animation the animation to play is I'm just gonna hit this browse key on the death it'll take us the animations play this animation for example right so I have this animation selected I can plug this in there ái gets to the player the play so now this is an issue with the camera again this is why you have to set up the collision so on the on the mesh here you can see that the mesh on the enemy base I'm on the enemy base right now the mesh is blocking the camera so we want to actually set this to custom under the presets just so we can disable camera now let's play and then now it's not doing that okay you can see it does attack but this stuff is actually it's not the prettiest so we're gonna actually set up an animation blueprint make this much prettier okay so let's come to our a I folder and we need to make an animation blueprint here but it's gonna ask us for a skeleton I just want to make sure I have the right skeleton here I can open up the mesh the skeleton is called minion underscore skeleton the browse to it and then I can right-click and create an animation blueprint we'll call this the annum be P underscore am i calling this forest okay I'm just gonna drag it to our AI folder and move here alright so let's open this up so animation blueprint this is how we can drive just a better looking animation so we don't have to do all that play animation in our blueprint graph here but I don't want to get too in-depth with the animation blueprint because you definitely do a lot of crazy advanced stuff with it but I'll just keep it as simple as possible what I want to do here is on this update animation a drag off of this get pawn owner my typing is valid with the question mark and all we're doing is saying only continue animating this animation if the character is actually valid meaning this forest has actually spawned in the world okay so or enough this enemy this enemy has spawned in the world so anyway we want to do we want to get a few values here so again if you're a brand new to the engine it's probably gonna seem a little advanced but just I'll try to explain it as best I can we got to get the speed of the plug the enemy basically the speed that the enemy is moving so if you come to the enemy here and you go to the character movement come to the walking it has this walk speed here so we can actually get this number by calculating its velocity and converting that to a float so if I come to the animation blueprint off of this pawn here I can type in get velocity and then I and then off of this return value here this vector I can type in length this gives us a float so like I said I know it's it doesn't might not make any sense and it's okay just try to remember this just like memorize what what this is and then you can promote this and we'll call this the speed so this will give us the speed of the enemy like this is running on tick so this this variable is constantly being updated okay and what we're going to do with it is in the animation graph up here so the way animation blueprints work is you have your hand up like you have your blueprint event graph and then you also have your animation graph the animation graph we can actually create what's called a state machine if you type in state machine you get add new state machine I'm just going to call it the locomotion and when I enter into this I can create a new state we'll call this the idle state connected up all we're doing in idle is we're just gonna play an idle animation so if you come through the asset browser it'll show you all the animations that are rigged or rather that will work with this enemy so I'm just gonna draw dragon idle 1 or idle a and if you look in the right says you have like play right here you can adjust the speed of it you can say if it's looping or not we definitely want this animation to loop because it's an idle animation but now in the event graph in order to get this to work or I'm sorry not the event graph but the locomotion animation graph here we need to connect this up and when I compile you can see is idle and then what we need to do is we need to plug this animation blueprint into our actual enemy so in the forest click on mesh and then here it says animation class none this is or animation blueprints we can plug in the forest I disconnect this chase player now he's just idling see slip that back up all right back to the animation blueprint let's open up our locomotion so this is our idling state but when the AI is moving we want it to be doing something so let's make a new state and call it jogging and then it's connected up and then we also want to drag an arrow back and then these are basically boolean's here so if I open this up it's saying what needs to happen so that the AI is jogging well in our case if you come to the enemy here the enemy is idle when it's speed is zero right it's not moving so its speed is zero so we can do some logic that basically says when the speed is greater than zero the AI is jogging right so what I'm going to do is up here I'm just gonna bring out our speed variable in this transition here I can go when speed is greater than or equal to for example 300 then start jogging in our case the AI is gonna move at 600 speed so 300 is more like this is fine and this error is because I need to set up the transition for going back so what happens when so what needs to happen so that the AI starts idling basically speed needs to be less than like you can just put in 1 for example a I will go back to idling now if I come over here let's move the AI over here I didn't finish the jogging so we got to open up jogging here and plug in an actual jogging animation sales come over to our asset brother let's just look for a sprint sprint forward okay plug that in so now you can see him coming to the player in the attacks well so as you saw there though he attacks and then it looks it gets really ugly that's because we don't want to use just a straight-up back animation like this when you do play animation like that it kind of it kind of ends the animation blueprint so instead what we want to do is actually what's called a montage so we come back to its animations here we have this jungle attack I'm going to use this instead this actually comes with you can make your own montages just right-click great animation montage and montages are really powerful because you can add multiple animations in there you can add different sections so you can play random attack animations you can loop animations things like that I don't want to get too in-depth with them because they're kind of advanced but you go through my udemy courses I go over a lot of that stuff so anyway I'm just going to grab this jungle attack here I'm going to come back to the enemy base instead of this whole play animation thing I'm going to do play montage you need to plug the mesh back in here then the montage to play I don't want to plug in this montage right into the enemy base because I mean if you have a ton of different enemies they're not all gonna use the same montage so I'll just I'm gonna do is I'm going to right-click and then promote this to a variable this is now the attack montage and now what I can do is in the actual enemy forest blueprint I can set that attack now so I can come to the content browser jungle attack plug it in and I think he should attack so he's gonna run over to the player cuz we didn't set up the slot in the animation blueprint this is just something you have to do when using montages you have to come to the animation blueprint come to the animation graph here drag off of here and type in slot default slot hook it up and the way slots work is you can have all these different slots for like upper body full body all this different stuff if you actually open up the animation blueprint for this bellick a-- watch i'll open her up you can see they got a lot more stuff going on here if I come to the animation graph let's find where they're using slot slot upper body they got all these different slots so you can do all this different stuff depending on different poses and stuff like that but again this is pretty advanced I don't want to get into it I'm just going to keep things simple for it for you since you're a beginner we just set it to the default slot and I think it should work now yeah it so you can see how he attacked there so now how do we make the AI actually damage the player if you open up that jungle attack it comes with this animation montage window thing right here that you can move around you can also expand it move it all we care about is this beginning part we don't care about the endpoint we care about the beginning point and we want this beginning point to be the part in the animation that would actually damage the player so for example the AI swings like right here when they it when the animation gets to about here we're gonna see if a player is like in this area and then and if the player is then apply damage so the way we do that is in the enemy base there's this on notify begin and on notify end this begin is that beginning point right here and the end is that point so it's up to you you could do stuff on the end point if you want but in our case I'm just going to work with this begin point and what I can do is I can actually draw a collision sphere to check right I can do what's called a sphere overlap actors if it's overlapping a player the way we do that is I can drag off of object types here this is a this is an enum but it's an array so if I type in array here I can go make array and we can a sphere that checks for pawns right or if you wanted to you can even plug in just the third person character underclass filter so for example I can scroll all the way down actually I'm just gonna type third person character it still needs object types and make sure you do this I can filter for a third person character and the radius of the sphere let's have it be like eighty the good number and this position we don't want to spawn this the sphere at zero zero zero that's literally like I think that's like right here in the middle of the map that just wouldn't be a good spot to put it you want to spawn this on the actual enemy but the way we do that is you want to spawn it in front of the enemy if I just do a get actor location plug this in and every time the AI attacks it's gonna spawn a little collision sphere in the middle of the character so that's not correct we want to spawn it like in front of the player so there's multiple way or in front of the character or in front of the AI there's multiple ways you can do it you can either do a little bit of math and get the location of the actor and then get a point in front of it or we could add like for example we could add a little sphere collision here we can call this the attack point or something this in here and then do it gets get world location plug that in yep now the problem is is we won't be able to see this sphere so we have to do what's also called this is just to help us in the development process you can do draw debug sphere the same thing I'm going to plug in this here because this is where we want to draw it same radius make it red or pink whatever this is just to help us see the sphere this attack points in the middle of the player or the enemy so that means the sphere will spawn in the middle of the enemy hopefully everything works as planned okay I didn't see the sphere make a thickness of two oh I didn't do radius that's why 80 whoops stupid me okay so you can see the sphere spawning in the middle middle of the enemy 80s kind of big I'm and bring it down to 60 see that it's spawned in the middle of the enemy so I can actually take this sphere now and move it out we make the radius way smaller because this is just for us to spawn the attacks fear there you go so you can see it's a little bit in front now and that's actually good if you watch the actual attack you can see its blade comes out to about here so maybe we want it maybe we do want it to be about 80 and then maybe we want to bring it out just a little bit farther something like that I don't want to be well let's see let's try it again we don't want to be farther than the blade yeah so we definitely want to bring it in a little bit okay bring it back in a little bit like that all right okay so the blade pretty much made it to the end of the edge so you have to just do some testing on your own but now that we have that we know that's a good radius can setup what to actually do actors you can see that it's a we can see that it's an array and what we have to do what this is use for each loop with it that's just what we have to do and what this means is that every actor that gets hit in that pink circle that you saw let's do something to it in our case we're only filtering for third person characters so just to see if it works I could do a print string should print out the character so you can see it's printing the character so we know it's working so what do we want to do the player we want to damage the player so kind of like what we did with the laser I can apply damage so let's do that let's apply damage and how much damage well it's gonna depend on your monster right so we want to make this a variable as well call it damage make sure you set the damaged tire the damage caused er is the enemy so just do a reference to self here now in the enemy forest we can set its damage now souls come to class defaults let's say it does a damage of like ten now let's come to the player and like we did with the enemy where we have this damage event it's really cool so I can just select all this in the enemy base copy it and then here in the third person character and the player I can actually paste it give us some errors it's like oh you don't have a death event that's okay I'll just delete the death event and then it can say oh these variables what I don't know what this is oh my gosh all I gotta do is right-click and do a create variable health and then we're good to go for the player let's say the player has a hundred health so now every time the player gets hit by this enemy he's taking ten damage and the player will have ninety health or we'll lose ten health so just to show us an action I can do a print string can plug in the health here and should say 90 in the corner so it says 90 so the player lost 10 health have an issue where the I was only attacking once the way you would fix that is in the enemy here on success it attacks the player attacking what we can do again is maybe we delay for once whole second and then we chase player again I just realized we need to plug something into the target here but we don't have that set so on the chase player event let's actually make this a variable so so just pull it off and call this the player target so let's chase the player and then here in chase player we can plug in the player target okay so when we play he's now attacking and if I start running start chasing me so he's chasing me gets too many attacks okay so you can see how this games starting to come together and honestly this is way too quick way too fast so what we need to do is come to the enemy forest here actually is come to the enemy base let's make the default movement speed 300 if to come to the character movement component to do that so now the four should be at 300 okay now because we changed it to 300 I need to come back to the animation blueprint for the forest and in this transition I did greater than or equal to 300 I must set this to like 100 actually just to make sure it works for sure now the AI is much slower allows the player to escape and actually play the game so the player can turn around and kill him okay so you see another issue where the AI is still chasing the player even though it's dead to fix that what we need to do is when the player dies we need to stop this move to the way we can do that is you can drag off the character movement and do disabled movement look that in and then there was another issue if you noticed it every I hit the player a second time and the death animation played again so it's like repeated and the way we stop that is we can just do a boolean check here so on death we can set a new variable we can make a boolean here that sets the enemy to be dead so make a new variable call it dead and then up here let's make it a boolean and drag this off and actually set it to true here so the enemy's now dead the true and we only want to run this stuff here one time let me pull this back and I'm gonna drag this off and go we do a true/false statement here is the enemy dead if it's not true then let's set it to true and do all this stuff so when I shoot the if I shoot the enemy again after it's already done all this stuff it won't continue because dead is now true so it'll just not do anything else okay this is just a little fix for that animation issue that you saw if you caught it I can come over here and I can shoot them a few times I'm still hitting him but yeah hope he kind of did some weird stuff at the end there oh well there is another issue he is rotating show that I'm gonna disable this begin play I won't be able to move from the beginning whoops I just need to plug this in here this is just to show you what's happening okay so I can kill him he dies but he's still rotating towards me because he's still trying to to move towards me and the reason for that happening is this a I move to is actually being ran if you hover over it just says simple order for pong with AI controller so basically the AI controller is still trying to move the pawn to the player and so the way we can do that is we can actually stop this movement altogether with the AI controller so we actually don't need to come into the a the AI control to do this you could you could make an event here and then you know tell it to stop logic or whatever but what we want to do actually just type and get controller do and then type in stop movement you can see it's AI navigation stop movement this is one way to do it but no I know this one will work so if we play I kill them and you can see it just kind of stops all that so yeah so now you're kind of starting to see the logic here starting to come together so now if I started adding a bunch of different monsters here you start to see how the games coming together right gets hit I'm losing health each time I'm hit that guy stopped working for some reason not exactly sure why yeah you can kind of see how it's starting to come together this is the point where I would start to flesh out like a very simple level start plugging in the enemies and making them move towards the player and things like that so it's up to you how you want to do your levels you always come into here you're the free just look through the free content right every month check what's free for the month check what's permanently free like this environment set is free for this month I could add this into my game and make this the level so I'm actually gonna leave this part up to you the freedom of creating your level this is up to you what kind of level you want to use depending on when you watch this video who knows what's gonna be free I don't want to spend an hour creating a level I do want the player to actually be able to die as well right those come to the player here if this like this for now just for debugging purposes our own death event in the player health is less than or equal to zero let's do death so when the player dies just like with the enemy we want to play death animation now here you can see that in the enemy base we're playing this death animation we don't want to do that we want to make this a variable as well and actually you can't make this animation of variable I forgot about that so the proper way to do this is to actually kill the AI in the animation blueprint so to do that if to come into the animation blueprint we got to come to the animation graph when you need to do some logic here that will kill the player and the way we do that is if you right-click here type in blend poses by bool now blend animations together so I'm gonna plug this in to false and the ball here is you know dead right to promote a variable let's say dead all we're saying here is when dead becomes true the player has killed the AI let's play an animation here as long as this as false as long as this is false just continue running the regular locomotion so by default this is false so the regular locomotion will continue no problem but when it becomes true for this particular character we want to run this death animation so I'm going to browse to it and drag it do the animation blueprint test how this looks just come to the preview editor click on dead and it'll play the death animation right you can see it's looping that's not what we want so make sure you uncheck loop animation up here and then it'll stop okay so now back in the event graph how do we know that the AI is dead well in the enemy base we created a dead variable so now in the animation blueprint actually search for it the way we do that is animation blueprints have like a begin play I can go event scroll up event blueprint began play but I'm going to do an event blueprint initialize animation what I'll do here is I'm going to copy this try get pawn owner we'll cast to the enemy base to a variable and we'll call us the enemy and then now here I can drag off and I can get the dead variable and so we're constantly checking if the AI is dead so I can actually drag off the dead the variable from the AI here plug that in and so this dead variable will always be false until the enemy actually dies right here so this could set the true on the actual enemy base class and then the animation blueprint will update their own dead variable so now when I play you can see it dies X he's dying okay so you can see how the game's kind of coming together here of course is a little sloppy but I mean pretty good for you know just like a couple hours right once you get a nice-looking level it's gonna start looking pretty cool hopefully you're learning a lot so far beginning your you know hands dirty and the engine kind of just learning how things work at a very basic level so what I want to do but the player I want to do something very similar right when the player loses health want the player to die as well so you're in the player will make a yet variable - true and we'll come into the player animation blueprint this Bella Co one and in the event graph here I'm just gonna ignore everything else here because it's advanced and I'll just drag this down here and we'll do the same exact thing we'll do blend poses by bool plug that in this goes to false this bool here becomes a new variable called dead a true pose is gonna be death a make sure it's not looping now in the event graph here you can just check if the players died those casting here I'm going to make this a variable here player just gonna hook that up really quickly and then right here I'll just go like this what was it called oh actually this is incorrect right here we want to cast to third person character let me delete this player variable okay promote this to a variable call it player all right there we go about this we're not using this then we go player get dead and set this to dead and then make sure you hook this up here to okay all right so hopefully when the player dies I said get to true player dies so hopefully that'll work so let's just play just let them attack me for a bit get me low all that jiggling you see we'll fix it okay so I die so it does die correctly okay so that jiggling issue let's come back to the enemy base just come to our character movement scroll down we want to come to the navigation section I know this is called avoidance we want to use our Bo avoided zest true so what this does is this actually makes the AI kind of avoid each other see how they're kind of avoiding each other they're still jiggling around but they're a little bit better at avoiding each other they're not great but yeah they're better just not great so now let's create a very simple UI for the player just so we can see the players health so up here in the content folder I'll just make a new user interface widget we'll just call us the player UI can't open this up never used which a blueprint before it's kind of complicated but try to make it as easy as possible we want basically health in the corner here then maybe like a score over here but let's just do health first my type in box and we can get what's called a horizontal box I'll add this to the panel first and we use these boxes because you can put elements inside of them so instead of just adding a text and like a progress bar want to use actual box first as you can see it's anchored to the left corner which is good we want it there but I'm gonna do those rename this horizontal box to I'll just calls the health box I want to change the alignment here because I don't like it being stuck in the corner you can actually just move it with your mouse here do something like that some text into it now so in drag text and put it in and the order does matter when you're working with ease when you're working in the UI whatever order you have it does matter in our case this is a horizontal box so things will be going next to each other horizontally we did a vertical box they'd be going down yeah now we all on a progress bar so if I add it you'll see that it's actually to the right of it see it's kind of confusing but I'm gonna up the size here like that now I'll move this back for this text block I'm just going to call this elf : enter for the progress bar I'm going to rename this to the alt bar we actually want to do what's called a fill so it fills up the whole thing okay so now let's work on the color for it so the way we do that is in the style here background image I want the tint I want the Alpha to actually be zero and then I want the percent to be one so it's zero to one that's how these progress bars work it's not zero to 100% zero to one so 1.0 is actually 100% so point five would be 50% let's make the color red for health so by default we're at 1.0 okay now we need to draw this to the player screen this UI way we do that is in the in the third person character on begin play I do what's called a create widget and now here's where we can put player UI player controller there we go and then we can promote this to a variable and call us the player UI and we want it as a variable because we want to be able to update this progress bar so we can actually update this progress bar in the event graph up here on the right which we'll get to in a second for now we want to add the player UI to variable and then we want to do what's called add to viewport this will actually draw the UI on the screen so now when I play I have the health up here now obviously the health isn't being updated even though the players losing HP so we have to update the health bar every time the player gets hit and the way we do that is through the UI so in the UI here I can come to the graph I can make a simple event graph here I can make a simple event just do custom events just like in regular blueprint do update help and because our health is a green float value we want to make an input of type float all at Health and we just want to update the percentage right like I said it's from zero to one so we know the players health is 100 right here so all we want to do is update this health bar percentage so you can see by default this health bar right here it says is variable it's checked by default this text is not checked by default but you can always make text a variable and update text as well in our case we're just going to update the health bar so what I can do is I can drag in this health bar and then off of here I can set the you can set the values over here on the right that you see so in our case we have percent so I want to set this percent every time the player takes damage so I'll just drag off this I'll type in percent and we can set percent so what do we want to set it to remember it's from zero to one so we want to take the help and actually divide it by a hundred because the player has 100 health right now it's very basic you could get more advanced of course but and when I come to the lair now every time the player takes damage we want to call this update health event and the way we do that is we set our widget to a variable called player UI so I can actually drag the player UI here and then I can do call that update health function basically every time the player takes damage will update the health right so I can just plug in health okay so now when I play every time I take damage the health bar should decrease so you can see it going down there might be another issue here when I hit zero Oh No yeah so that works cool so the player is dead and doing another thing with the UI here we can get kind of crazy we can make this new text on the canvas panel I'm going to anchor it to the center here and then I'm going to reposition like this and I'm going to tie point five for the alignment this will Center it completely I can type in you know game over sighs to content and then I can come to font and really bump it up so now if I play it's just a big game over right that's ugly but what I can do is I can scroll down and set the visibility to hidden now when I play it's hidden but we want to make it visible when the player dies right so let's come over to the top here I'm going to call this the game over text oops gameovertext I will make it a variable then now in the graph I can do a little boolean here go if health is less than or equal to zero it's false we want to set the percent that's true we actually also want to we also want to set percent to zero as well if it's true but then we want to make this text and we want to okay it was okay anyway this just look weird here we want to actually what's call is okay let me show you how do we make it visible right so if your member down here was called visibility so in the graph I can actually come off here then type in visibility and we can set the visibility so by default we have it set to hidden but now we're going to set to visible when the player is at zero health so when I die hopefully that text will get set to visible there you go okay now there's a lot more things we could add on to this game we could add on to like sound effects visuals where every time the player is hit there's like a sound effect maybe like an armor or something like that but for the most part this is a pretty good entry-level video if you want to see a part two just let me know and we can do that but hopefully this tutorial has taught you a lot about the engine that's the whole point of this video I'm not you're trying to help you make a full-fledged game I'm just trying to show you how you can create a bunch of different stuff in the engine just to get just to get you started just to get you comfortable with the engine the goal is to get you comfortable as the name says it's just a top-down shooter you know you can come in here shoot the enemies killem and you have some very basic understanding of AI spawning projectiles dealing damage updating your UI things like that you have some very basic things going on here so now at this point without what recommend is that you're ready now to move forward into like a full-fledged course things like that like like like further into tutorials that will go into more details maybe start dabbling a little bit in multiplayer stuff like that so that's what I would recommend at this point I would say you're I don't say that's the next step right it's still you know game development is really hard no matter what anyone tells you it's hard so it's still like a long journey that you're gonna be on for a while learning all the basics I usually say that when it comes to Unreal Engine and game development in general you're a beginner for your first year and after your first year you're kind of like depending on how many hours you put in you're moving on towards being like intermediate and then after like three to four years of game development then you might understand the engine an advanced level so really approach game development as like a lifestyle this is like a long-term hobby slash lifestyle that you need to accept that's just gonna be a long time and you know with that said you should still try to create your own dream game I think that's the best way to stay motivated but just be realistic about it take your time and just you know learn things slowly and really try to master the fundamentals really try to understand how collision works understand how spawning and spawning things like spawning actors things like that works right understand how AI works and animation things like that there's so many things like that go into game development and then we didn't even touch on things like you know world building or materials and things like that so just so much that goes into it so just you know take your time have fun with it and you know going forward look for some courses I have courses on udemy that you can check out in the description those are pretty good people tend to really like them and then I have Dischord channel that you can come in as well and of course subscribe my channel if you like this video so that's gonna do it guys thanks for watching and I will see you again soon let me know what you would like to see in a second video and then perhaps I'll put one together so thanks you thank you guys and I'll catch you later
Info
Channel: DevAddict
Views: 131,426
Rating: undefined out of 5
Keywords: unreal engine 4 beginner tutorial, ue4 beginner tutorial, make a game in unreal engine 4, ue4 top down shooter, top down shooter unreal engine 4, how to make games, unreal engine 4 gamedev, unreal engine 4 tutorials, ue4 tutorials, Devaddict
Id: nI1KcW3mjAA
Channel Id: undefined
Length: 112min 39sec (6759 seconds)
Published: Wed Jul 15 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.