How to Make Your First Game in Unreal Engine 5 in 2024 - Full Course

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys welcome to new Unreal Engine 5 tutorial today I am going to show you on how to make your first Unreal Engine 5 game as the end of the video you will have different features and mechanics such as a player character enemy AIS a wave spawner system a map and much more if you are a beginner starting to learn on real this video will be perfect for you remember that you can get the project files through Patron or YouTube members it's going to be a very easy video to follow so let's get started all right so the first thing that we need to do is create a new unre engine 5 project in this case I am going to be using the latest version 5.3.2 and I do recommend to use the same version as me or above okay so let's go ahead and select the third person template now even though we are selecting the third person template we are only selecting it to grab the character mesh and animations this will also include a player blueprint but we will delete this because we will create a wrong one okay so let's select blueprints select the Tet platform which in my case will be desktop the quality preset this will depend your Hardware but let's go with maximum then s content we will disable this because we will not need some more materials or models and R trace and let's just leave that disabled then let's go ahead and select a private location and a prate name like for example first game tutorial and now let's go ahead and hit create okay as you can see the project has been created and has opened up now the first thing that I always like to do when I create a new project is to Anchor my content browser at the lower part of the screen and if you don't have this already you can just go up into window go to content browser select the content browser one and then when this opens up you can just grab the tab and drag it to the bottom and there we go okay so let's go ahead and cover the basics of the interface so the main window is the viewport and here we can hold the right Mouse button and use turn the camera as you can see we can look around and then with that hold that we can uh move with W ASD just like an a normal game and just navigate around our level we can also go ahead and select objects and then move them around with this gizmos we have different options we can also go and click this button to rotate it and also to you know enlarge it and make it smaller so we have a lot of options here that we can play around then we have the outliner which is also known as Hier in other game engins and it's basically a list of all the actors or objects in our level or we can do the same select them on here and organize them in folders then we have the details panel which will display all the parameters about the object that we are selecting for example it's location rotation the mesh materials and so on then we have the world settings which is basically a details panel about the levels so in here we can set the game mode and such more advanced things as World partition and so on but don't worry about that right now and then of course we'll partition but that will not be included in this video and then last but not least we have the content browser where we will find all of the Assets in our project and they will be organized basically in folders so we can have everything you know organized and find it so that's very important and then we will also have some extra things at the top as when we press play to you know play the game and then we can go ahead and move around we can exit with uh just pressing escape or shift escape and then we can also have this drop down with more settings but don't worry about that right now the thing is that now we just covered the basics so you know how the engine basically looks and what we can do with the engine okay so as as I mentioned at the beginning of the video we are going to be deleting the player blueprint and so on that right now we have available when we press play and that's because we will create our own one okay so in this case we will find that in the third person folder so you can see in blueprints we have a third person character and a game mode we will delete both of those and also all the input which again we will create our own one and then also the map we can go ahead and delete it so we will need to create a new map so let's go up into to file new level and create a basic level hit create and there we go so now what we need to do to save it is basically modified so we can just maybe move this just a bit and now we have this little start icon at the top so now we can just basically hit save and now we can save the level and let me just you know right click create a new folder and call this levels so we have everything organized and let's just go ahead and name this something as testing great great so that said let me also make my UI a bit bigger because maybe at my 4K screen it's bit hard for you so let's go ahead and just go here and let me just put this on 1.5 and that will be basically easier for you to see great so now we are going to go ahead and delete that necessary stuff which is basically the whole third person folder and don't worry because our characters will be in a separate for this you can see characters which is the things that we need so let's go go ahead and select third person press delete on your keyboard delete and then yes Force delete and there we go now it is gone so now what we need to do is basically create two new blueprints which is going to be our player blueprint and our game mode blueprint so let's go ahead and do that okay so to have everything once again organized let's right click create a new folder in the content browser and let's name this blueprints instead of this blueprint folder let's right click and create a new blueprint class and here is where we can basically create new blueprints now you will see that we already have a class to create a game mode which is the one that we want so let's select this and name this something as gmor as game mode and then we can just type whatever in this case for example just single um single player okay if I know how to type and now with that selected we can go to world settings and assign it so we can just go ahead and drag it and now this level has this new game mode assigned now for now let's not open this up because we still not have a character blueprint to assign it okay so first of all let's create the character blueprint let's right click go to new blueprint class and as you can see we will already have a character class that we can use and this is the thing that we want because it already have a capsule Collider a character mesh and a character movement component which we will use so let's select this character class and let's name this something as BP uncore as blueprint and then just player and now with that said what we can do is assign this player blueprint to this game mode so the game mode knows what player to spawn in here because right now when I press play as you can see I just have the default on Real Player but not the player that we just created so let's double click on the GM single player and now you can see that we have a whole bunch of different options don't worry we'll cover this better in the player blueprint but just in the det spanel okay you will see a bunch of classes and the default Pawn class which is set as default Pawn needs to be set as BP player which is the one that we created and now with that we can compile and save and when we press play it will spawn our new player but as you can see it's completely empty we cannot move around or anything so that's what we need to do now so let's go ahead and double click on BP player to open this up as you can see we'll have a lot of different Windows once again first of all we have the viewport we already covered this basically you can move around and see the player in a 3D space but the difference is that the viewport is not from the level anymore is for the blueprint then we will have the components window which we can see basically all of the components that the player has in this case or this blueprint this is very similar to the outliner but instead of um objects or actors we have components as you can see the capsule component the mesh and so on then we have the details panel once again we can see all the parameters about the object that we are basically selecting and then we have my blueprint option where we can see all the graphs that we have all the functions variables Etc that we will look further uh when we advance in the tutorial and then we have the event graph where we can basically go ahead and add all our blueprint nodes and make our logic and then the construction script which is basically like an advent graph but that will also be executed inside of the editor without uh pressing play but don't worry we will not really use this in this Toral the main focus will be the event graph but with now that said let's go ahead and assign a default mesh for our character so let's select the mesh component and in the dets panel we can find the skeleton mesh asset and we can put for now this one which is skm Manny simple and as you can see we have this simple mannequin so let's place it correctly we're going to go into location and put a minus 89 on the uh you know Z axis so go down and then in the rotation we're going to apply a minus 90 also in the Z axis so we'll be looking in the correct way okay so now as you can see when I press play we are kind of inside of the mesh but if we now press f8 we can eject from the player and move around as you can see it is here so things are working but now what do we need well we need a camera right we need to be able to you know see the player from outside so once again let's go back to the player blueprint select the capsule component which is the parent as you can see those are indented that means that they're basically a child of this capsule component and let's add a new component and this will basically be a spring arm now you know we are selecting this spring arm so we can attach the camera at the end and then we can simply move this spring arm and we'll have some space in between our player and the camera so let's press enter and then what we need to do is Select this spring arm and add a camera and now as you can see the camera will be a child of spring arm and it will be at the end of this spring arm so here we can you know change the arm length how much we want our camera to be you know far away from our player and so on now very important thing to make sure is to enable use Pawn control rotation so later on when we add our player input we can move this spring armor around and therefore you know move our camera so with that said let's compile and save and now when we press play as you can see we are previewing our camera so all that is going ahead and working so now what we need to do is create some inputs so we can you know press the W ASD and the mouse move it around so we can move our player and our camera so let's go ahead and do that okay okay so for this let's go to the content folder right click and create a new folder and let's call this input so in this folder now we need to do is create this object which will be under inputs which is the input mapping context let's call this something as IMC as input mapping context underscore simple as just you know player input this will work so this asset will contain a list of all of the player input actions that we will have in the game and then we can simply just add this you know input collection into the player so the player will be able to use all of the input actions that this contains so now before open this up because well we need to create the input actions let's create the first input action so let's right click go once again to input and create an input action and this will be called something as I aore as input action and just move because this will basically be the action to move the player in you know forwards backwards left and right and everything let's double click this input action as you can see we have a whole bunch of different parameters for now the one that we are interested in is the value type as you can see right now it is set as digal bull basically true or false so are we pressing this key or not but what we can do instead is Select and access to the vector to D so we will have two axes the vertical and horizontal axis and this is perfect because we want to move forwards and backwards which is on the vertical axis or left and right which is on the horizontal axis so that's why we want to select this access to the vector Tod so now with that said let's close this and open up the IMC which is the collections of all of our input actions that our player will be able to access and let's create a new mapping and let's select this new II move that we created so now what we need to do is assign the keys that we want our player to be able to access in this case the first one that we want is W to go you know forward now we can you know manually search for w keyboard but a quicker way is just to click this button and press W on your keyboard and this is just a shortcut and it will assign it now we need to do a modification because by default as we selected this um access to the vector to the value type this will not know if we are on the vertical horizontal axis we want to go and a postive space or forward negative space backwards and so on so what we need to do is add a modifier Now by default this will be using the horizontal axis but for w we want the vertical axis because we want to go you know forwards so let's add a modifier and this will be the Su input access values so this will kind of switch it to be using the uh vertical axis which is the on that we want and then what we need to do is add another key because well we have W sorted but now we want s and this will have exactly the same modifier this us input axis values because we are still in the vertical axis okay we want to go uh forwards or backwards in this case backwards also in the vertical axis but this needs another modifier which will be negate so it will basically make the values negative invert them so we can go backwards instead okay so now with that said we have forwards and backwards but we need also left and right so let's add a new um player input well actually mapping sorry and let's assign the player a and now this modifier will have the negate because well we are by default in the horizontal axis so we don't need the Swiss input access values anymore because we already on the horizontal value and then we want the negate because we want to invert the movement and then the same will be for D but this will just simply not have anything because it will be going uh horizontally to the right which is positive so with that said we can close and assign this new input mapping context to our player so how do we do this well let's enter in the player blueprint let's open the event craft and delete this two notes except the G play the G play will be called when the game starts so when the game starts we want to assign this IMC player input to our player so he can can use it so let right click and access the get player uh controller node so all of the input is basically accessed uh through the player controller in a view so now from here we can get the new enhanced input local player subsystem so this is the player input system that our real engine is using in here so that's why we need to access this system and then we can just call this node which is the add mapping context and now we can just select the one that we created which is player input and there we go now our player will be able to access the that you know that input action move that we created so now what we need to do is create the logic here so we can access those inputs and move forwards back towards left and right so let's go ahead and do that okay so let's access that input action that we created so how do we do this well we can right click and just call it by the name so I aore move of course and underscore there we go and now you can see that we have two um nodes the one that we want is the enhance action events with the arrow that's always the one that we want to use when you uh call an input action and now we can use it because we have the mapping context as you can see we have this pin out here while it is being triggered so while we are holding any Keys we will execute some code and then we have the action value which is a vector to the structure but we want to know which AIS we are going vertical or horizontal so we can just right click and split this and now we have X and Y so now what we can do is just add some movement input with this node which is using the character movement component and we can now just set a world direction that we want to move on in this case uh if we want to go forwards backwards whatever so let's begin by using the X um you know value which will be horizontal so we want to get the uh right and left Vector of our player so first of all let's right click and get the control rotation there we go and now what we can do is basically from here get the right Vector now there's no get left Vector so what we need to do is basically get the right vector and inverted but as you may remember we already added that negate modifier in the mapping context so it will already inverted when we're going left now there's a thing that we want to change here so let's hold out and you know left click and let's right click split split and we only want to connect the X and Zed and now the pitch because the pitch will be basically looking up or down and if we look down our player will slowly stop moving and we don't want that you understand it later on we actually hit play but we basically want to disable this pitch um you know route then we just want to plug this to the W Direction and plug X into here and now you can see that when I press play I can move left and right with the A and the heys and there we go our player is already moving very cool so now let's do exactly the same but for forwards and backwards so after this once again let's add another movement input node and in this case the W direction will be a bit different but let's copy this control rotation node and let's paste it and let's right click and get the forward Vector now this is exactly the same there's no get backwards node because well we can get the forward and just inverted so that's why we add that negate modifier right click split it connect x and z and not y you'll see later on why but we basically want to drag this W Direction here and then the Y plug it here because that's the scale value that we want because it will be one or minus one with the negate modifier and now we can move in all directions forwards backwards left and right so there we go it's working okay so now what we need to do is move the player camera okay um so what we need to do is create once again another input action so let's right click go into input action I aore and this will basically just be called something as look and once again think about it we want our camera to look up down left and right so this is exactly the same as the AI move action value we want to change it to an AIS to the vector Tod so we can move vertically and horizontally and now very important once again let's add it to the mapping context add a new action mapping and then select the AI look we can close this one so it's a bit more organized and we can just add a one which is going to be the Mouse um XI to the AIS and this will already go ahead and get both aess which is pretty cool it's a kind of a short recut and then we can use this here so use right click I iore look and then we want to right click split it once again we want to get both values and then we can use the add player yaw so we can uh basically move um you know looking up or down and let's connect Y into here and now you can see that I can basically uh move my oh actually sorry it will be X because we want to move uh from left to right against see there we go that is working we can move left and right and very important if this doesn't work make sure that in a spring arm you have you spawn control rotation enabled which we did before because that enables our um player to control the spring arm and then we want to add the controller pitch because what we want to look up and down and that will be basically why as you going to see boom now we can do so but the controller is inverted so we can make a very easy fix and just get the Y and times it by by minus one and there we go now this should be resolved and we can move you know right left up and down and there we go that is great but you can see that we have this strafe movement where we are always looking forward and we cannot basically look at our player so let's change this so let's go to the player controller let's select the C movement component go down and on this rotation settings let's enable a rent rotation to movement so the player will go at the direction that the movement is going and then we want to go to class defaults and search for yaw and disable use control rotation y because this is basically making the player always look at the direction that we are uh facing which is not what we want now as you going to see we can turn around see our player and the character will turn to face the direction that is going and now we have this really cool play controller like an Uncharted or something like that where we have a kind of free loc of motion what we need to do is add the player animations so let's go ahead and do that as you may remember we now have access to the characters folder mannequins folder and in animations we have inside for example man all this really cool animations as Idle jumping uh walking forward Etc that basically we will use now if you go one folder right side you can see that we have two animation blueprints once again we are going to be creating our own ones so let's select these two guys and just press delete because we will not use those animation blueprints that came in with the third person template let's create our own one so let's create one here right click and just go to animation blueprint basically in the animation blueprint it will you know just have some states and logic and it will just choose what animations we want to play in this case we can select an skeleton in this case Cas it will be SK mannequin make sure to not select the old Unreal Engine for SK mannequin skeleton we're using the new one so it is just SK manin set create abore as animation blueprint and then just player for example if they double click in here you can see that I have this anend graph where we will be able to add things and then just put an output post so in this case what we want is to basically you know have an idle animation and then when we move have a jog animation but just as an example I could drag here the idle animation connected and then Mark it as Loop in the details panel and then if I compile you can see that it will be playing that idle animation but not in the player while well because we need to add that animation blueprint to our player's mesh so let's select the mesh go to anim class and select the one that we just created which is AP player and then we go and now it has that idle animation but of course when we move it doesn't have dat so a very cool solution that we can use is a blend space what is a PL space well let's take a look let's right click go to animation and now we're going to go down into Legacy and use a PL space 1D why 1D under Legacy I will cover this in a second but let's select this and then let's select once again the SK mannequin and let's go at the start of the name and just rename it to be the idle jug Blank Space 1D open this up so basically in the Ben space we can go ahead and transition between different animations depending on a value the value in this case will be the player speed so as the speed increases we can transition from the auto animation to a walk animation to a j animation and this will just look perfect and it's very simple to do so why do we use the 1D version of the blend space under Legacy well that's because for for our Locomotion we only need one horizontal Vector because we only go you know uh from uh idle to walk to run in this values but we are not going in different directions or climbing or whatever so just the one D One Direction value it is what we want so now in access settings we're can change that value name this SP you know speed the minimum speed will be zero but the maximum 500 now we need to match this up with the player max speed so let's let the character movement component go down and let's change the max speed from 600 to 500 which basically looks a bit nicer now let's go back here and let's drag in our animation so in the asset browser search for idle and then we're going to select this mm idle and then just drag it and put it at the left where the speed is zero and then let's get walk and this will be just mm walk forward for example drag it and let's place this at the center kind of of here at you know 250 and then let's get finally jug um actually it's not jug it's called run and let's drag this mm run forward and put all the way to right where the speed is 500 and now what we can do is hold control and move our Mouse around this timeline as you can see as the speed increases it will transition from stationary idle to walking to running in a very smooth way which looks absolutely amazing so now we can just save close this and use this on here so let's find that idle jug PL space which is here drag it connect it and if now we compile you can see that we're seeing once again the AO animation that's because the speed is zero but if we change this to be 500 and compile you can see that now it is running so what we need to do is update this speed param parameter to whatever speed the player has when it plays the game so first of all let's set this back to Ser speed default and what we need to do is right click on here and create a new variable and now what we can do is just update this variable the cool thing is that the animation blueprint comes with its own event graph and we can implement the same logic that we do on here in the player blueprint so what we can do is here use this update animation node so every frame it will constantly be calling this so we will constantly be getting the player speed in this note we'll basically get the owner blueprint in this case Pawn but we can access the blueprint so what we need to do is just get the velocity of this Pawn Pawns in un R are just basically um blueprints that we can possess basically control basically they're like players and then what we need to do is set the speed to be this velocity but as you can see this doesn't match this is a vector and this is a float so what we can do is use this very handy node which is the vector length node and connect it to Here and Now what we can do is convert that Vector to en ni float and when I press play Boom when I'm in idle where ID do but when I walk or run in this case we transition and it looks very cool now to make it a bit smoother what we can do is open up the blend space and enable smoothing time to be maybe 2 and now basically we'll have a bit of a smoother transition as you can see which is much better so there we go we have the basic animations done we can just move around and everything looks really really cool and it was very straightforward to do so there we go okay so now we have the basic player controller with the basic Locomotion of animations and now what I want to do is add a simple combat basically just attacking when we press the left Mouse button so later on we will have our enemies which will spawn in a wave system we can you know go ahead and eliminate them so to do this what I would do is leave a free really cool animations as pack in the description so just go ahead and download it and you have access to a lot of different animations now the one that we are basically interested in will be this um paired push Shu attack okay which is basically a push animation and that's the one that we want to use so you drag this into our content browser and now we can import this now make sure to click reset to default just in case you mess with the settings previously and now let's select the skeleton that we want to import this now in this case this animations are using the old on real Engine 4 skeleton so let's select in this case the SK mannequin skeleton with the old version from real not the new one and we can just say import and now boom that we go we have it here it looks very cool you can see it's like a push animation and that's the one that we want to use but we want to basically convert this animation to use our new R engine 5 skeleton because if not we can simply not use it or at least it will not look very nice so what we need to do is retar it now in this case because we already selected the third person template we have access on the characters mannequins and rigs to this um Ika retargets and this will automatically uh have an option to retarget from un real Engine 4 to un real Engine 5 now you don't need to right now long about retargeting I do have some tutorials on that so if you want to check them out go ahead have a lot in my umre engine 5 YouTube channel but basically what you need to do is that means converting one animation to be compatible with another skeleton so let's right click go to animation assets and duplicate and an animation in this case let's select that retor that I talked about which is from un real Engine 4 Manny to un real Engine 5 Manny there's also an option to do the other way around from u5 to u4 but we want this one at the middle from ue4 to ue5 and now we can just click and boom we have this new animation basically going ahead and push him with a new mannequin so there we go let's rename this to be something as just push and now let's save and now what I can do is actually delete this old animation because I simply not need it anymore right we're using the new mannequin now let's organize this a bit so let's go to the C folder expand this go to mannequins animations Manny and just drag it here and say move here and now we have it nice and organized here with our push animation which is what we want now this is a bit too long there's some an needed part where it's kind of the preparation I want it to be quicker and sharper now also when I finish the animation it takes a long time to go back to its idle position and that's not very good so first of all let's just kind of start the animation already around here so let's right click and remove frame 0 to two and now it already start at this point which is going to be faster and then the animation finish cannons here okay so when I got my you know arms kind of already at the middle hip position I'm going to right click and remove from frame 18 to 37 and I will get that rest part deleted and I only have the necessary parts and don't worry this will blend nicely later on but for attacking it is very important to for them to be sharp and straight to the point because if not it would not look very nice so basically now to be able to play this animation from our blueprints whenever we want in a very uh compact way what we can use is an animation Montage so let's right click on this push right click create an name Montage press enter and this created a an name Montage for this animation as you can see it's exactly the same thing but there's different things as a default group uh slide some anim notifies what is this we don't worry about it right now but basically now we can play this animation Montage from our blueprints so let's go ahead and do so let's go to contents blueprints open up BP player and now let's first all organize this a bit so let's uh just change first of all the comment name because uh sorry the color because it's very ugly so let's go to edit um with this editor preferences search for comment and on here in the color we can change to be a bit darker and you can see that now it will look way nicer so let's select everything press C to comment and this will be uh just input this will be movement and with that we have things more organized so now what we need to do is create a new input action so we can press the um left Mouse button and attack so we can do this in the input folder so we have because we already have done it two times before I want you as a challenge to do this basically create a new input action just as we did but in this case you don't need to change the value type to an access Tod it will stay as Boolean so you don't even need to open this input action and then add it to the mapping context and in the mapping context just add the left Mouse button and that's it that's the only thing that I need to do so go ahead try this out and we'll cover this in a second okay so let's go ahead and do this let right click go to input create a new input action call this II uh AI sorry uh and this will be something as just attack right we can make it more generic rather than push just attack just in in the case in the future you want to add more attacks like I mentioned we can leave this as default as dual boot because we don't only need to know if we are pressing this key or not okay there we go now in the mapping context let's add a new mapping this will be basically a i attack and then uh we can just put a key so a cool way is to just press the left Mouse button and there we go cool so that's it hopefully you got that right if not don't worry because we have already done a lot of things you know after we added the input so it's okay all right so now in our player let's add a new input right click I aore attack and now in this case we don't want to use triggered why triggered will be always occurring while we are holding the key in this case we just want to attack one time when we start pressing the key so we're going to go use the started and what we want to do is use this play Montage note as you can see there are two we want the one above which is more complete we'll have more outputs which will be handy later on and then let's drag in the mesh to the skeleton mesh component because that's the mesh that we want to use and the Montage to play will be the one that we created and now if you take a look nothing happens why well because there's a thing that we need to do in order to play animation montages in our blueprint uh animation blueprint as I previously said before and if we take another look we can open open this up and you can see that it has a default group slack basically all the animation montages play on a specific slot so what we need to do is add that slot in our animation blueprint so we can play it so let's go to content characters mannequins animations open up our AP player animation blueprint go to the NM graph and right after all of our Jog and so on we want to add that default slot and this will basically override all of the animations because it is after the blend space and now you can see boom we can play it and it looks a bit weird why well there's the thing this animation blueprint uh animation blue sorry this animation is designed to move uh with rude motion what that means well if we take a look at the animation itself you can see that it kind of moves the feet and therefore the root so if we enable here down the enable root motion the character will be still but now that means that when we attack the whole character will move as you can see right now it is moving and that's what we want basically our player to move as we go and there we go now the thing is that we can spam attack and that doesn't look very good so we need to control this how well we need to do is create a new variable on here so there we go we are creating our first variable and this will be is attacking or can attack whatever you prefer in this case I prefer to go with the can attack route so later on uh you can set can attack to be false if you're interacting with something or whatever so what we can do is add a branch here so an if statement and if can attack is false we can go ahead and um play the Montage but I don't want to go through the false route so I want to go through the true route so we can add this not Boolean node and this will mean if can attack is not true there we go we can go here and it just looks a bit cleaner now make sure to select can attack compile and set it to True very important because if not you will not be able to attack and then when the animation is completed we can set can attack uh to be back to true and when it starts playing false so if you can attack you will attack immediately said Can attack to false so you cannot attack anymore and when the animation finishes you can set can attack back to true so now I cannot spam I spamming uh and then uh nothing plays why well that's because um you need to make sure that um Can attack is actually true I actually I don't know why I put it in not bullan okay I thought for a second that we were doing the ace attacking Noe so if can attack is true we can attack if not nothing happens okay sorry I I I I want to B crazy there okay so you can see now I'm spamming and nothing happens it will wait until the animation finishes to attack so that's great so cool with that said we can go ahead and attack which is really cool so now what we need to do is actually some logic because we are only playing the animation right we're doing anything else so we need to do some to basically detect the objects that we have in front and if there are objects in front basically you know apply damage how do we do this what we can do is create a sphere Trace what is a sphere Trace well basically it will be an invisible sphere that will appear in a certain position and whatever is inside of that sphere we can detected and then in this case apply damage to that so what we need to do is go and right click on here and do a sphere Trace by Channel now in this case we actually don't want to do a sphere Trad by Channel what is the by Channel well as you can see we can set the trace Channel and on the mesh we can also in the Collision settings specify what Trace channels our objects are available on uh in this case we don't want to go in that way because our pawns will just be sorry our enemies will be other pawns so an easier way is to do a sphere trace for up objects and now we can select an object type in this case for example the whole pawns or uh static meshes or what we want so let's connect this here and we want to set a start Point what will be the start Point well let's create a point that we want to apply this uh sphere Trace so with the parent selected we're going to add an arrow and this is a new component that will act as our attack Trace pause and we can just move this a bit forwards up and now our sphere will appear here so a bit in front of our player so when it basically attacks you know we can detect everything around here so we can now get the uh attack Trace post get the weld location and then just plug that there because that will be the starting point in the world location then for our end point what we will do is basically get get the forward Vector of this Trace so whatever is looking in this case that direction right and I want to basically times this by right clicking float a value and this will be how far away our sphere will be able to go in this case I think that 200 will be enough and then what we can do is get this and add this to no so we'll get the direction and put it to the end node and then we need to set the radius I think maybe 25 will be big um for our f here and then we can do set a um debug type now if we compile we have an error why well because we didn't set the object types so let's make an array and now we can set to detect pawns because our enemies will be Pawn which are just capts and unreal save compile and now we're good to go and why did I set this for duration well because now we can uh debug this we can test it out if I now attack there we go we are seeing this feere Tre so whatever is in front of my player we will attack it now it's very big so let's make the distance shorter maybe 100 will be bit better half of it and let's see yeah I think this will be good so whatever is in front of this we will detect it cool now as you can see immediately when I attack it is adding that spere Trace but I only want to do this when my hands reach kind of of the other body how do we do this well we can use an anim notify we technically just go here and add a delay for whatever uh amount of time it takes our hands to reach there but a better way is to use the notifi so we can go into our animation Montage just clicking browse double click on it and then on the notifi track find where we want our animation uh to basically send the attack which is kind of here right we can now go to notify track right click add a notify Montage notify and this will we kind of uh function that we can trigger which will be received in this node and we can now plug this here so whenever that animation reaches that point it will execute this because it's on the notifi begin and now as you can see it will take a bit longer for my attack as sphere tra to actually send and that's way better so that's cool now that is basically going ahead and working we can now attack and well we are not applying any damage for now whatever but because we don't have anything to play damage to so now what we need to do is start to create the AI enemies so let's go ahead and do so okay so it is time to create our enemy blueprint so let's go to the blueprint folder right click and create a new blueprint class in this case once again well what do we want our enemy to have well a Capal collider aage and so on so character will be the perfect class to select let's name this something as BP _ enemy and open it up so first of all let's add a mesh into it so we can see something let's select the mesh component go to the mesh asset and we can select in this case for example Queen to change the bit and you select a queen simple and put it in place with the - 89 and- 90 in the Z axis for location and rotation so it'll be perfectly there great so now with that if I drag my enemy to the world and I you know to be facing us Press Play I can go and boom I can already start attacking you can see that the uh sphere trades turns from red to Green that's because it's detecting that pawn because it is a character and we can now basically apply damage to that character how would we do this well let's open the player blueprint and in the player blueprint we can get information about what we have hit first of all let's check if we have actually hit something so we can use a branch with this return value if it's true we want to do something so we can get information about What actors we have um impacted with with this out hereit we can drag it break it and now we have all this information about what we have impacted with in this case we want to access the hit actor and apply damage now the really cool thing is that and real already has a damage system between actors integrated not like Unity which will need to make our own one in unreal that's already one that works great so we just want to get the hit actor and call this apply damage node because we are basically applying damage to whatever actor we have hit it which in this case will be this enemy Ai and now with this apply damage we can put a base damage for example let's say that for each attack we apply 10 of damage this is just temporary but imagine that we sent 10 of damage now nothing will happen because we haven't said any anything to do when the AI receives damage we have same damage but the enemy AI doesn't receive damage so how do we do this well let's go to the VRA where we out of the logic delete all of this because we want need it for now and we can use this very note which is the on any uh take damage sorry any no take damage sorry um any damage there we go event any damage so when the enemy receives damage which will receive it from this node we can do something in this case for example let's print on the screen hello if I now go and press play as you can see when I attack it is printing hello which is at the top left of the screen I don't know it's a bit small but it's there so it is printing hello so that's working what we want to do in this case is create a simple health system so let's go ahead and do so so for that let's create a new variable which will basically be health and this will be a a float because we want numbers to have decimals on and then what I can do is set a default value for this health make sure to compile let's put for example 100 so all of our enemies by default will have 100 of Health at the start but now what I want to do is get health and subtract a value which is the incoming damage and then we need to update this variable so I can use set Health to be with the new calculation so when we receive damage well in this case the enemy re damage we subtract the current health with the incoming damage and then update the variable and now that will work and then what we want to do is make a branch so we can get the health and check if it's greater or sorry smaller or equal to zero if that is true well that means that we are dead so what we can do is just destroy this actor okay the enemy so in this case what we want to do is just basically push this enemy 10 times and we should be able to go ahead and destroy it there we go boom it disappeared because it reached a health of zero so that's cool and you can see that the logic is very small indeed there's really not a lot of things going on so what we're going to do now is basically make it a bit more elaborate you know um instead of just destroying it we want to Rago the enemy so it will kind of like fall with physics to the ground we also want to kind of push it a bit we want to do some things so to do this what I am going to do is this you know delete the destroy actor node and get the mesh and use this set simulate physics on the enemy so I can set this to true and it will simulate physics so all the bones will come to life and he will just rack do to the floor now let's s the mesh because we need to change some Collision settings the first thing that we need to do is set this to be custom and on collision enabled we need to do this on collision enabled query and physics so all the bones will interact with with each other and now you can see that if I set the default Health to maybe 20 so it's a bit faster okay and press play I just hit it twice and boom he falls to the ground with physics and it looks absolutely amazing which is really cool so that's working R do is you know functioning when we um kill a enemy now in this case let's a bit let's add a bit of a force backwards right we want to basically launch the enemy a bit you know when we push it um backwards so we have this really cool feeling how would we do this well in this case for the false route in this case uh we are the enemy is still not dead so we want to push it so we can use this very cool note which is the launch character node and we can use apply a vector where we want to push in this case I want to basically get my forward Vector of our actor and then times this by what well a vector sorry a float which will be minus I don't know uh 200 maybe we're going to play with that and apply it here and then um if we now press play you can see that really there's a bit of a of a push going on but it's not very noticeable as you can see that's because first of all uh it is you know going with the ground so we also on top of that want to add another Force okay let's connect this another Force which will be the get up Vector of the actor because we are applying a force backwards but let's do it upwards too so now we can just times this by right clicking float another value which would be maybe 100 and now I can pass that there press play and boom we push it you know backwards and it looks pretty cool it's just a bit right maybe you can increase this a bit but for now I think this will work pretty good so let me just join this a bit there we go and we'll basically push the character a bit when we apply damage which looks pretty pretty cool so now that we have the damage system pretty much set it is time to start creating the enemy AI so let's go ahead and do so so for this beginner tutorial we are going to be making a a very basic AI we are not going to go ahead and create a whole Behavior tree or anything like that but if you want to go a bit more advanced and learn about that I do have a lot of tutorials about that in my YouTube channel so check it out but what I going to do is go to my BP enemy blueprint and let's create some simple blueprints so it can move around so let's right click and create a new custom event so later on we can C this event and move the player uh well the enemy sorry this will be just uh you know wander right so the enemy will simply just be wandering around and searching for the player so we can use this AI move to node and we can select what pound it wants to move in this case self so we want to move the player and to what destination well it will get a random point in reachable radius so it will just find a random point in the map how far away from the origin well maybe 500 and the origin will be the get actor location so from where it is right now will go 500 um of units outwards and find a random position and go there as simple as that and then what I want to do is go to the begin play and call Wonder so when the game starts I can well I I always say I can the enemy can basically move around and when it finishes I want a delay of maybe 1 second and then call Wonder again so this will be on a loop it will constantly be going to a location it raes that location wait one second and then it starts again so now if you press play nothing will happen why because real needs a very important thing to calculate of the paths that the AI will be able to navigate through so for that we need a component and we can access that component on the quickly add to the price section go to uh volumes and add this nav mesh bounce volume so first of all let's make this very big so in the details panel lock it and put maybe like 20 now if I press P you can see that we have a preview of all of the area that the AI can navigate through so this is how in real we calculate the paths that our AI can go and this is very important if not any AI will not be able to move if you now press play Boom the AI is basically picking a random position in our world instead of that nav mesh and move into it wait in 1 second and pck another one now it looks absolutely awful that's because well it is um you know just going at a very high velocity without any minimations and also it is turning very uh Snappy so what I want to do is basically change this uh rotation because it was like kind of turning very harshly so we can select the C moov component in the enemy go down and do exactly what we did with the player en a r rotation to movement because that will make it very smooth and then in the details um defaults panel we can disable yob because that will force the character to be looking um at the forward of the actor and now as you can see it will turn way smoother than compared to before you can see now it still looks very bad because well it is going like a rocket so let's make this a bit slower in this case in the blend space the walk animation is set at 250 so let's go with the Enemy go to character and go with maxb speed of 250 so now it will basically go ahead and go way uh you know slower and that looks way better now you can see that well the enemy doesn't have any animations and the cool thing is because we made our animation blueprint of our player generic there's no reference to the player blueprint or enemy blueprint it will just get the owner velocity and applied we can apply the same animation blueprint to the enemy even though it is called AVP player and now it will have the animations with the work and oh my God that looks absolutely amazing as you can see so right now is picking a random position going there and stopping and that's it but we are making a wave system right where the enemies will be constantly going to the player so we actually want to change this a bit and just make it to go to where the player is in the world so let's go into the BP enemy event graph and we are not going to be using the Wonder system we're going to leave it there just in case in the future want to use it but it will be just kind of you know they isolated now let's also commment the damage system and there we go cool so now with that said what I want to do is right click create any custom event as we did with the Wonder but this will be um Chase player and it will go ahead and use the AI move to node once again and go to where the player is what pound we want to move self the enemy itself and then what we can do instead of plugging in a destination we can plug in a Target actor which in real will have a reference to the player character in our level so we can use that and then when we reach that we can use maybe waight 2 seconds and call Chase player again so it will be constantly chasing the play player and then in the game play we want to go chase player to initialize the loop and now as you can see he will be going towards me when it reaches it will just stop and I go it will continue to work to me and that looks absolutely amazing so our enemies will be able to go and follow the player which is very cool now let's make this a bit more organized put this up put this up uh comment with C this will be Chase player and of course we're need to do we need to do a very important thing which is make our enemy attack the player when it reaches this okay how would we do this well exactly the same way that we did it with the player okay so we will need to play the animation Montage we will need to create a sphere uh object by here Trace by objects detect the player apply damage and so on so okay I'm going to be adding a mega challenge for you I know it is going to be a bit hard but you know if you can do this you're going to be an Master already with only one video and basically what you want to do is on the success basically disable this move this around okay because you don't want this and basically how you know uh you did it with the player um call the play Montage note that we used select that Montage then on the notify beginning go and apply the sphere trace for objects apply the pawns array and set the debug type to for duration and and then get the results and add apply damage like 10 of damage to the player now the cool thing is that if you get lost you can simply open the player blueprint and see how we make it basically it is this it is exactly this okay don't worry about the can attack variables for now we will Implement that later okay I would not I will be kind to not assign you that test but please do the Montage and the sphere trades and everything like I said you have the player here with exactly the same notes that you need to use so if you want to do so go ahead and take a look at the player but you know give it a go guys give it a go so uh give it a go um you know pause the video and in some seconds we'll go ahead and cover this okay so let's go ahead and do this so when the AI reaches the player it will go on success because it right at its destination so in here we can go ahead and use the play Montage note again the one at the top because it's more elaborate and we can plug in our mesh because that's the uh you know mesh that we want to play the animation on and assign that push Montage with that said on the NFI begin which is at that point that our arms reaches kind of forwards on our chest we want to create a sphere trace for objects okay now let me just pull this up because we need more space okay and once again uh I don't know oh I didn't mention before but um we need to create another um you know attack BS right with the arrow um so in our player BR print we can do a shortcut and it's just copy this attack Trace spots select the capsule paste it and it will be in the exact same position and there we go now we can get that Trace bus get the world location and then just drag it into the start and then we can also get the forward Vector so we know you know can go forward times it by a float value and this will be I think it was 100 and then just add these two vectors together to get the direction two and Dr it onto two end the radius uh 20 will work and object types make an array and we will search for pawns and now with that for duration you can see see that when it reaches our player it will attack with that uh trace and now we just want to make sure that if we have impacted with something I'm going to break this and access the hi actor and just apply some damage in this case for example also 10 of damage it doesn't really matter but 10 will work and there we go hopefully you ended up with this result I know that I didn't mention the uh that we need to add the attack Trace post but you probably figured that out um so there we go let's go ahead and expand this out select all the nodes move them up expand the comment so it's very uh important to we can also collapse it and just have it there that's a bit neater um and it's very important to always you know have the everything organized and now um after that what I am going to do is basically uh chase the player once again okay um um because this will be a loop so on true right after that we'll chase the player again and on false we'll do it two we can double click to add this route nodes and just add it on here so if we attack at the end we'll chase the player again to continue to go to the player and attack again but if not we'll just directly chase the player if we um you know didn't detect anything uh so now we can press play it will come and it will go ahead and spam why is it spamming well because it is constantly reaching the player um so what we need to do is once again create that can attack variable so let's go create a new variable can attack it will be a Boolean so true or false and on here if can attack is true so let's make a branch we will uh go ahead and attack actually it will be sorry it will be even before before playing the animation okay so on here if we can attack we'll put this on here there we go and we will uh set can I attack to be false and uncompleted to be true and actually instead of dragging the chase player at the end I am going to steal it and put it un completed so once the animation completes set can attack to through and Chase the player once again I think that is a bit more appropriate that on here okay there we go so you can see that you can make logic in a lot of different ways you can maybe add it at the end when you apply damage or once the animation finishes there's a lot of there millions of ways to do each uh mechanic but now with that said make sure to select can attack and set it by default at the start it is very important and now as you can see it will come and only attack once it will not spam and it will go back for me and continue to attack and it it is working perfectly now you can see that when the character mesh is in kind of in front of the camera the camera will zoom in very badly uh so what we need to do is make that the enemies will not interact with the camera uh boom uh so what I need to do is select the enemy select the mesh go down and because we already have it on custom is very easy we can simply go to the camera trace and put it in ignore now that would not happen as you can see when it comes and attacks it will not happen but it still kind of Zooms in why because we also have another collider which is the capsule collider in the enemy which is that sphere and it's also in front of the player even though the mesch isn't so we need to also go to Caan presets search this to custom camera ignore and there we go and now that's it you guys see now it will be perfect and there we go there we go I was quick than you so now we have that done but we need to do one last thing which is to add that damage system to our player we have it on our enemy but not on our player so here comes another challenge I want you to do exactly the the same that what we did in our enemy for for the player okay literally in this time is exactly the same what you're seeing right now on screen do this but for the player now try to not look at the enemy this time um because it's a bit simpler but if you get stuck of course go ahead and look at this blueprint and just you know so will guide you through um so go ahead and pause the video implement this on the player and give it a go we'll cover this in a second okay so let's go to the player blueprint and on here first of all let's add a comment to this which will be basically attack so it's organized and let's go down and add the any damage event so when the player receives damage we will need a new variable which will be basically health and this will be a float so now what we want to do is get the float of health and you subtracted by the incoming damage and then set the health to be this new value so it will go ahead and be updated then we want to check if we have a health equal or less to um sorry get zero okay so if this is less or equal than zero that means that we should be dead so in this case we're going to do something different and it's disable the input first and then we'll just go ahead and make it the delay um and you know one second and destroy the actor for now don't worry we'll add R to two in the future but for now let's just do it like this and then in the actually uh no let's do Ral and because we already copy the challenge so uh the only thing extra is this disable node so you don't have it add it at the start let get the MH and then set simulate physics to be true so RTO and we need some changes on the mesh Collision settings as I mentioned set it to custom and Collis enabled quarian physics so it will all the bones will actually interact with the world okay and then in fals as you can see here we have that uh push launch character let me just copy and paste it okay we'll save a bit of time probably some guys were a bit clever and probably you know cop it and Bast it but it's okay we're basically just launching the character with this force and this Force at together okay nothing crazy so now as you can see when a character comes boom it killed me why well because the health by default is zero make sure to set it to whatever you want in this case maybe 30 to test this and I will receive three hits you can see I go back and boom I die so everything is going ahead and working which is very very cool so that said guys now we have bit of the gameplay Loop going on we have our player character that we can move around with with Locomotion and input we have the damage system so we can attack and kill the enemy and we have some basic enemy AI which will go to the player and attack us and also impact us and kill us so now the thing left will be to do the wave spawner which will spawn enemies around us okay every so often and then we will just need to update the map to you know look a bit cooler with some aets and also the player characters and then on top of that we're going to add some simple and will be good to go so let's go ahead and do all that all right so let's go and create this wave spawner so let's close everything open up the blueprints folder right click new blueprint class and this will be a bit different okay in this case what we want to create is an actor which is basically an object that can be placed or spawned in the W so we have this white Spawner in the W and the enemies will spawn from there as simple as that so let's select actor C this on as bpor wave spaer with the underscore and let's open this up okay so we will not really need any um mesh at all but the only thing that I want to do is add this um build board so we can see it better when we place it in the world okay just as guidance that look here is a wave spawner you know then in the events graft we want to do some things we want to delete everything um in except for the begin play and now what we want to do is when the game starts spawn an actor from class what will this actor be well the enemy blueprint that we created and what transform Well for now let's get the actor transform so whenever right now the white spawner is we will spawn it there now if we split the wave um transform node you can see that we have the location rotation and scale so we have those three things in one uh thing which is basically you know the transform so that's why it's very useful to in many cases use transform and then on collation handling over I going to change it to be um try to adjust location but always spawn so we will make sure that the enemies will always spawn even though they're up you know interacting with something but they will be uh adjusted and then with that said we're good to go so if we now drag this one here and I press play you can see that it spawned this player at the beginning play so when the game started we got this player let me also delete this other one okay but you going see that um let me also rotate it so it's facing the player so 180° so when the game starts we have this um you know player oh let me also set this be here there we go there you go so when I press play you can see that this enemy is spawned but it isn't moving why there's an option that we need to change so in the blueprint enemy in class def search for AI and we need to change one thing which is how to possess AI this is right now only as it is placed in BO but it has to be placed in BO or spawned in this case we are spawning our enemy so that's why the AI wasn't available but now it will be so when to press play I don't know why it doesn't okay we go it is coming to me now because it's working so what I want to do is basically um be creating uh spawning a lot of enemies okay um you know how however many times and they will be coming for me so let's create a new variable and this will basically be the waves and what will this be well this will be a uh an integer because it will be whole numbers I'm going to change this to be a map why a map well this will be able to contain two values we can add all of the different um waves and also how many enemies we want to spawn in here so the first parameter can be a string okay and this will basically be for example wave one and how many enemies for the wave one maybe five then for wave two how many enemies we want to spawn maybe I don't know double 10 then for you know for wave three how many enemies maybe we go to 20 you know and that's how we can do it with a map which is basically very similar to an array which is a list of objects but a map will also contain a second value which is really cool okay so now we have this map variable with all the waste that we're going to have and their you know value so what we want to do now is basically go ahead and spawn in a loop all the enemies that are here right so what we can do is basically get the waves and use this note which is values to get those values okay and what we can do is get a copy of what um current wave we are on in this case this's right click create a variable and this will be current wave okay so let me rename this current wave there we go so if the current wave is zero which is the first one we will basically get five this will basically output five okay and then we can do a for loop on here down here plug the last index here and the first index one because um as you know Maps will go from two to one and then we want to use you know spawn this five times and of course this needs to be first so we'll get the values there we go and boom if we press play five enemies if I now put current wave to one we is tell the next one boom there we go now what I actually prefer to do is to set the current wave to one and on here subtracted by one put it here and then first index um to be zero no uh this needs to be one yeah right and now I can uh get the first wave um by putting one instead of zero you know so this will be inad of zero one which a bit clearer okay so we have accessed this you know map we have gotten the values and we're accessing the first value which is you know one in this case then we're getting that you know index uh integer and repeating this how many times so now what we can do is delete this create a custom event and this will be like spawn wave you know spawn wave and now we can use call this whenever we want right in the begin play we could call spawn wave the first time and each time that we call spawn wave what we can do is get this put it to zero and then just increment by one okay so every time they we call spawn wave it will add one wave and it will do the next one and then when all of the you know enemies are dead we would basically do the next one right uh so this will work so now if I press play we have the first wave which are five enemies and you know this would basically work so what we need to do now is a control to eliminate all the enemies and when we have eliminated all the enemies basically create another uh wave so what we can do is on the wave spawner go and be checking every so often how many um you know players we have left so let's do this in vent TI just for now okay there we go vent TI and what we're going to do is get all actors of class in this case the class would be enemy so we can access all of the actors in the level with that are basically enemies and if this is um basically equal to zero that means that we need to do another um you know another W spawn wave right so we will spawn the wave and there we go and just to test it we can you know Press Play There we go we have this I can oh my God I am dying so much um let's make the attack animation quicker okay so on animations uh Manu we can go to the push montage and put the where is is the rate scale to be 1.5 and now it will be faster as you can see and then this will also apply for enemies okay and then I can slide the enemies go to the health and let change it to them to have just 10 of Health okay so at one hit they will be dead and then the player will have more health so let's increase the health of the player to be 100 you know let's make it real nice don't worry we add a health bar later on and then I can just you know delete of the here we go enemies oh my God okay they're actually very good they are very good um actually going to make the animation okay A bit uh less faster so leave it back to one but the blend in time will be a bit you know faster so 0.1 and it kind of Boom it it's a bit better okay boom boom boom run boom run boom ah I died okay let's for testing let's make it like 200 okay just test don't worry guys um and then boom boom boom boom I'm going to die I think there we go and oh God there we go and nothing happened why okay they also are still attacking why because when they die we haven't set can attack to be false very important so here we can set can attack to be be false and now they will not be able to attack okay because they are dead um another thing they're going to do is disable the input so I can use um disable movement sorry all the character moving component for the enemy AI so they can move and there we go and then um another thing is that nothing happened why well if we go to the weight spawner okay we are taking for the all the actors and you know we didn't code this why look let's make a print here print string okay which will happen and let's make the waves way smaller so two five and seven right so just test there we go we only have two boom boom you can see nothing got printed okay um it didn't detect there were only um you there were zero ones why because they are still in the level they are not not being deleted okay they're just R do but they're not you know deleted so we are going to wait in the enemy maybe like 3 seconds and then destroy the actor and now yes they will not be already in the map and you know this will detect the there we go we got to the next um wave and you can see that we have how many 1 2 3 3 four five and indeed the next one was five so that's working but a very good way that we can do this instead of every frame checking what we can do is that every time that the enemy dies you know check so let's create a new custom event which will be check for enemies do this one here and call check for um enemies on the enemy here when it dies so just before we're going to get Act of class okay and this will basically be the class of um wave spawner and then Cod the check for enemies so we're basically finding that actor in the world and calling that event before the enemy is destroyed and they're going to check now we need to do this um actually this might not work because if the enem is destroy a bit later yeah exactly um this will not work because the enemy is destroyed um after you know so um the cool thing that we can do is just go here and add a bit of a delay so we'll wait you know whatever is the the weight here which is how much uh you know one frame we can actually delay until the next frame to check and at that time the enemy should be you know deleted okay maybe we need to wait a bit more so actually let's add a delay of maybe2 seconds you know which is not really noticeable and we'll pass to the next uh thing boom there we go that is working so there we go that works so every time that an enemy dies we'll go ahead and you know make a check for the next wave um so cool with that said let's add a health bar to the player right because right now we don't know our health so let's go ahead and do so okay so for this what we need to do is create a widget so to have everything once again organized let's close also this tabs let's right click new folder call this UI and on here right click go down into user interface and we can create a new widget blueprint user widget WBS widget blueprint uncore and then this will be the HUD of the player but instead of making it so generic and have a lot of things in One widget we can separate it and just add all those widgets um you know on top of them so this will be for example health bar and we can open this health bar widget and to place things on our screen we need to add this canvas panel and now you can see we have this available space to add things so what we need to do is add this progress bar and we can anchor this at the um for example you know at the bottom of the screen and then just put the position X and Y to be 0 0 so it will be there put an alignment of0 five and 0.5 and you can see now it is perfectly there also I pressed n instead of uh zero there we go and this alignment just makes it uh with a0 five be exactly the center and then the size y uh sorry X we can make like 300 and then on position y increase it a bit and just kind of play around with the sizes and that's a bit better you know maybe a bit thinner there we go I'm going to make the color be of course green okay as you know health and let's also use preview this by putting the percent 2.7 as you may notice the percent is going from zero to one and our health right now is from 0 to 200 something like that on our player so we need to uh be sure to check that out but first let's change bit the color to theit you know darker I think this is pretty good yeah that looks pretty nice and then we need to update this health bar how well what we can do is bind the percent and what we can do is get the player character okay in our level and use cast to the BP player casting is like basically accessing the blueprint so now we have access to all the variables and so on as the health now of course like I mentioned this this health goes from 0 to 200 in our player but in the um percentage it goes from 0 to one so what we need to do is divide this by the max Health which in this case is 200 but if you change the max Health in the player blueprint you would also need to change it on the um widget so what we can do instead is create a new Max Health variable so let's go to BP player add a new variable this will be Max health and we would put our health by default to be zero but Max Health which will be again a float because it's a value with decimals have it as in this case let's put it to 100 and now at the begin play When the game starts we would set the health to be at whatever the max health is and there we go and now here I can just access the max Health okay and plug it here and now we just need to change it from one place which is the max Health variable with that said we also need to create the witchet because right now when I press play nothing happens okay so let's go to the B graph on the begin play we can call this create widget node and it will add a new widget and this will be the health bar and we can just add this um widget to the player Screen through the view boort and boom when I press play it is here and if they attack me as you can see it also decreases which is going ahead and working so that's cool we all died at the same time so now that we have the health bar done let's make the um a damage effect okay so when we damage we'll put a um kind of a damage effect right and how would we do this well in this case yes we are going to be creating a new user interface W will beore which will be the HUD the main interface of the player and on here we will have the canvas panel which we can place stuff and first of all we'll have an image now the anchors we can hold control and press this large screen button to fill the whole screen and then on color and opacity for this to be by default red right and then the alpha will be zero but now we can rename this to be the damage damage screen and with this selected we can create an animation which will be damage with this animation selected we can create key points so the first point will be when the alpha is zero but a bit later when the alpha is maybe at three yes3 and create another one and then but a bit of time it will go back to zero and another key frame so now as you can see boom it will do this health effect but of course it has to be quicker right boom that is pretty good even quicker I think let's zoom in with uh with control like boom that is great okay so now we can go to the graph and on here we can delete everything create a new custom event which will be damage screen and now we can just get the animation which is damage and play animation now whenever we call this we can play the animation which is really cool now another thing that I going to do is exit the animation and add a text at the top with the Anor at the top and the position X and Y and the alignment of 05 and 0.5 to be like this make it bigger drop it a bit and then Center it and also in the font increase the size okay and now this will be the current wave so it'll be like wave one or whatever and this will be updated later on so this will be like the wave text and make sure that it variable is enabled so later on we can update this but we're not interested really in the wave text right now we're interested on playing the damage animation so let's go to player and we're going to create another widget so we can reuse the same node and change it to be the HUD add it to the viewport and also save it as a variable so we can right click save it as a variable HUD which will be C and then we can extract this here so a part of adding it uh to the screen will save it as a variable so later on I can go down when we receive damage and before doing all this calculations I can just get that hot widget and just play the damage screen event that I created and with that you can see that when I press play Boom they are playing that animation when I ra it damage which looks very cool and also I have that wave one and the text um at the top which you know will update as we go so let's go ahead and update that text right okay so now let's update that Wave 1 text so let's go to our UI H interface let's select the wave 1 text and we can create another binding okay and this time it will be a text binding instead of float binding and now what I can do is simply just get um actor of class and I will find that um spawner wave Spawner in our level and then what I can do is get that waves map that I created so this will contain both the wave string and also the the amount of enemies that will spawn in this case we are interested in the string that that we created so what I can do is basically use this uh map value which is keys because that is our key okay the string and then what I can do is get a copy so I can access a specific uh key and this will basically be the current wave and I can just plug that in and then just plug this to here okay and in theory that should work so if I press play you can see the wave two is here but we need to uh decrease by one the current wave um and this is because you know is how the array works now we have wave one I can delete both enemies and then when this will update boom wave two is there if I manage to kill them all which would be bit hard you will see that oh God oh God can I ah come on come on come on one more oh there we go you'll see that it will also update to three so that is going ahead and working now to save some performance what I can do instead of every time that it tries to access this cast to this actor I can do it one time at the begin play so I can do the initialize um event and then what I can do is get this actor of class okay paste it here and save it as a variable which will be basically the wave spawner H I don't know how you know BP right and then I can use here access that wave sper BP with the information and you just you know plug it here and this will do exactly the same thing as you can see if I get them out it will uh update to W2 so cool stuff now we have that there um me you know maybe we need add some sounds later on uh so let's actually improve a bit The Wave spawner because right now they spawn all from one little point you know from this little point it will be cooler to you know set where we want to spawn so we're going to have some random positions that we can set and it will be like around the player where each actor May spawn so let's open up with spawner and on here what I going to do is create a a aray of Spawn positions okay positions in plural this will basically be a location okay where I want my actually this will be a transform because I can also set a u a rotation later and this will be an array so it will basically be a list okay and on this list what I can do is add how many um positions I want so let's click this I icon to make it public and now I can access this array from outside and what I can do also is click on show through the widget expose on spawn and now every time that I add a new position it is on a 3D space and I can move it around um how would I move this around well I need to select this widget and I can now move it so the first point will be basically what it is okay then I can add another Point select the other point and move it to the other side like on my back then I can add another Point select that W widget move it into my side and then add one last one select the um widget once again the Gizmo and move here so now we have four different spawn positions that our enemies can appear and now what I can do is just every time that we spawn an enemy instead of getting the actual transform I can just get a random array item so a random uh position and plug it here and now every time that I play you can see that boom it spawned one enemy there and one enemy there and if I go now and you know kill the tomb and we get the next wave boom we are getting one here one here one here and just random positions and it is looking absolutely great so that's really cool as you can see that is working that it just improved massively our waves spawner so now with that said we are nearly finishing with the tutorial it is time to kind of Polish things up so what we will do is add some sounds so basically some footsteps some attack sounds damage sounds complete level sound and maybe some background music and then what we have to do is import some cool assets so we can decorate create our level and also our players so let's go ahead and do all that okay so let's import our sound so for this let's right click create a new folder let's call this something as audio and now here go ahead and download The Links of sounds that I will leave in the description drag them all and just you know put them on the content browser there we go so we have a grass footstep we have a damage ground attack ground and a wave complete maybe I have the volume of my system a bit lower so maybe you can hear them a bit better but now what I am going to do is basically make the footstep more Dynamic cuz right now you play the same one once you know again again again you're going to be very repetitive so we can right click go and into audio and create a meta Sound Source this name is something as msor firstep let's open this up and now what I can do is just play this wave player uh one mono and we can just put the first step and right now we're just connecting the output to output and finish to finish now we just playing the first step as normal but what I can do is randomly change the pitch from a range of random floats so I can go from minus three to three for example right so now every time that we play it it will be a bit different and it will be more realistic great so now let's go to characters mannequins animations and let's go to Manny and now what I am going to do is go to the Run forward animation and on any uh anytime that the character you know makes a step We'll add that sound as you can see we already have them labeled that's so cool so let's add a notifi track call this something as footsteps and one the left uh Foote heads we're going to add a sound which will basic basically go ahead and be the footstep that we said but remember the MS The Meta sound so will be dynamic each sound each time sorry so now let's go ahead and copy and paste this all around our animation and with that said let's add it also in our walk which is here and let's just do the same add track this will basically be uh footsteps and let's just click paste all around and with that said we're good to go now one thing that I want to make sure because right now you can hear all the footsteps of the enemies as they were in your ear is create a 3D sound so let's go to audio right click go to audio sound anation s aore character and we're going to play a 3D sound so the inner radius will be 200 which is the minimum amount of um distance and then the max distance will be 2,000 and now we can apply that to the meta sound on their Source attenuation there we go and now we can only hear the footsteps are near me if I go nearer I can start to hear them there we go so let's go ahead and duplicate this and do the same for the attack Grunt and one thing I need to do is change this to be the attack grunt as a wave and then we just need to uh play it on the player actually instead of doing it manually on the blueprints we can do it once again in animation so both of them will have them so characters mannequins animations uh Manny push and on here can to be like yeah like here right we in noty section at a play sound you can see the notifi section we can do a whole bunch of different things and this will be attack ground and now that's cool and it will play a different one each time because we randomly change the pitch and then when we receive damage we need to do that in the blueprints yes let's open up the player what we're going to do is basically go ahead and move all this a bit to the right and play a sound at location because it's going to in 3D and this will be the damage now we also need to create the uh meta sound for this so let's duplicate this one and this will be the damage gr and let's replace it here with the damage grun and that's the only thing that we need to do and then here we can select that damage grun Ms for The Meta sound and just add the get actor location on here so we get the location where the player is and when the player receiv receives damage see if we attack then it sounds yeah have that and that looks veryy cool now I actually changed my mind and I am not going to be adding it um actually yes let's add it to the to the enemy Tobe so let's just copy this two notes okay it's going to be quicker and just copy them go to the health damage system and right on here let's just you know kind of place them and there we go um um let's just move everything a bit to the right there we go so Mak some space cool so now with that said we are good to go the only thing that we have left is this um wave like success sound so let's go to the blueprints of the wave spawner and when we complete the spawn wave uh cuz I'm event we're going to add the play sound but this case it will be too deep because it's not really uh um you know a sound that we want to play in 3D so this will be wave um how is it called well we can this just press control space to open up the content drawer and just go to audio and you select um race it wave and just click this Arrow to plug it in and with that said there we go the first time we will also play it because we call it initially but it's okay it's like a starting game and boom there we go and that is so cool Also let's go into the player and in the attack let me put none on The Spar Choice channel so we don't see that ugly lines right we don't want that anymore that was for testing to get the sizes correct and make sure everything is working but now we don't need that ugly lens right also for the um sound of the meta sound for the damage on Source I'm going to make the sound by default the volume uh like half half of its volume so it's more kind of chill you know and with that said we have officially done all these sounds that's cool and don't worry later on we'll probably add a bit of um some you know how do we say uh music if you want at the end but now let's go ahead and decorate the level with a beautiful Forest so let's go ahead and do so okay so we are going to be importing this really cool stylized nature pack into our Pro once again I will be him the um you know Link in the description basically just download it uh well not download it but just add it to your epic games Library so you again see I'm here in my library it is here just add it to your library okay it is free and what you need to do now toload it and import it to the pr is click to add to project and now in here we need to do is search for our project which in this case is the first game tutorial as you can see I have two from last year and this year's you know updated really cool and just in case you don't see it because the pack is not supported for your version click show O price just in case okay but let's select this one which is 5.3 my one add to PR now we just need to wait until it Imports and once you know how do you know it import basically just finishes this progress part so let's wait okay as you can see now we have a new folder so we can open this up and we actually have a little um asset SC and a stylized nature example scene so we open this stylized nature example scene you will see that we already have a um map that we can kind of work on but we will actually not use this we will create our own little level which will be simpler but we can just open this right to take a simple look at how this pack looks right and okay here we have the map open as you can see this as pack looks insane now this is too much for okay we also need a smoother more plain landscape so that's why we're going to make our own but I just want to open this up to you know show you how this looks as you can see the you know it's using the normal real F system and the landscape has this really cool material which is the M Landscape which is the one that we will need to use anyway with that said what going to do is go to levels and let's duplicate our existem testing level and this will be our actual you know waves map we can call it right and this is the one that we will actually use so let's save open this up and let's delete the floor because we will not need it so what we need to do is create a landscape so let's go up to selection mode landscape and now here we have a you know few different options the one that we are interested on is just creating a new landscape and just enable and edit layers this is very important because we can do more things in in the the future like at leges and so on which we will not do in this episode but it's you know nice to have then the material is the mcore landscape that I mentioned this before and then the size is good for now okay just you know by actually 31 by 31 will be a bit better B molder hit crate and boom there we go we have it here so you can see that it is completely blank it's not like it has the grass why well this landscape you is layers so we need to apply those layers if you go to paint you can see the layers and I can you select the grass layer and boom now we have grass let's do the same with the other ones you assign them and go back here selection save it and now we're good to go and you can see that we have this you know oh God and say what just happened well basically our uh landscape is much higher than our actual level okay as you can see it's going to you know all around um and actually our player start this kind of of inside so we can use maybe decrease a bit the you know this to be a zero and you can see now we're actually spawning in the correct way uh which is really cool okay so now with that said we need to do is add some bombs some trees and so on so let's go back to landscape go to sculpt and now we can scul with a very low tool strength and breath size just a bit and to help to see better we can go to unlit and actually I think L will be better yeah I think okay L we can see bit better so we're going to randomly just kind of paint a bit some bumps and so on okay smooth this out and then on smooth going I just smooth everything so it looks a bit more natural and with that we will basically manage to add some really cool bumps if I now press play you can see we have some little Hills which looks very cool with that said now we need to add some vitation so if we open up the folder and go to foliage we can see that we have foliage types and we have what we need so let's go into landscape sorry foliage and now we're going to drag all of this here but let's begin by just the normal trees drag them here select all of them go to true and now if we paint as you can see they already have really cool valys that we can use so let's just start to paint some trees around here right like this nothing crazy some trees like this starts to look pretty cool right and then another thing that we are going to do is disable these trees and add the other type of trees right so drag them in put shift select them and then you know we add some of this other trees which are more like Pines and we can just kind of use both to create a really cool landscape and there we go we are kind of painting here the landscape and this looking pretty cool right very simple but looking nice right and then we're going to disable this and we're going to add some bushes as you can see we have a bush here some cover and some ferns do not select the grass yet because we'll do that in a different way but make sure to select the bush I think it's here and then this one oh this the plant the bush is actually here the thing and here okay so disable everything except this two three things sorry uh let's make the birst size a bit bigger you can see now we can paint a bit more of um of that right all around so we can kind of just scatter all that around now this is kind of expensive when it when we get to uh bushes okay so make sure to not go too crazy with it okay um if I now press play you can see that that looks very cool uh now maybe it's too big okay um I just actually realized so let's kind of get a lot out of the way with holding shift okay and we can remove and then I'm going to uh change the size to be maybe like. 3 to4 and now you can see that the scale is a bit better uh maybe it's even too big I think that 2 and3 will be a bit better let's see actually that's still too big actually uh maybe1 And1 Le make it a point one you know oh yeah that's way better so let's do it with point one and the cool thing is I also I left some bigger ones out I didn't remove them all so we have some variation you know anyway so with this let's go ahead and continue adding more there we go again don't go to crazy because performance will paid off and that looks pretty cool but now that said um it is time to add some grass so let's disable everything I'm going to do it in a different way okay instead of manually painting I'm going to do it with a landscape so let's select the landscape Right double click on it on the material and let's create a grass uh output and now we can create some grass types in this case there's already some created oh no we actually need to create a grass typ so let's click on here and oh this doesn't give me an option actually okay well that's okay let me this uh let me create a grass type okay a new one how uh do we do this well we need to go here I'm going to do it on the foliage um folder go to foliage and then we have this landscape grass type this will be grass oh my God there we go grass oh my my God how many SS did I put there let's get rid of one there you go open this up and now we need to add basically a a a mesh right in this case it will be grass we only have one and now we can add that grass into here and now we need to say what type of um layer we want to appear can do the uh layer sample landscape layer sample we're can assign the name it has to be exactly the same so will we grassor 01 and there we go so now we can apply and if we go to the world there we go oh God there's a lot of grass as you can see it looks very cool but there's too much right so we need to go to the grass asset and limit this for example the density this could maybe be 150 uh this way better and then also we need some cooling uh so you know we will cannot see grass until the end of the world so maybe like uh 300 will work let's see um um okay that's not a lot actually has to be madebe like a that was okay 700 right 700 maybe 700 will be good let's see that's not very good uh okay so I don't know 2,000 so you can play around with the B right what you want how far away the grass will render I think the 2,000 will be good for this yeah oh great see there we go cool now we need to touch a bit the you know kind of the um Lighting on someone and also maybe we can enable Nite on the grass we could try it out uh so let's test we can right click Nite oh actually disable Nite so it had it enabled and I think that yeah having disabled it will go way nicer and I think that also for uh the bushes on some one it would be better if we disable n uh yeah that's a bit better because yeah that's way better um because you know 8 is a bit expensive on Fage uh for now so now that we have that we need to go ahead and touch bit the controls for um lighting right for postprocessing effects so let's add the postprocess volume let's make this infinite so we'll cover the whole world not just inside this box and then in exposure let's limit the Mina Max to be a one okay and then on on let's go to lighting let's increase this to maybe like uh 12 right so we have more lighting and I'm going to go back to the post process go down and on uh where said color grading Global on saturation and contrast let's put this at 0.1 one sorry 1.0 maybe two and on contrasts 1.1 is too much 1.05 and now the colors will be more Vivid and it looks pretty cool honestly and you can see we're already having this really cool game now uh maybe the the the bushes are a bit too plain right this this big ones um so let's see what we can do to improve them a bit so let's go here let's go to volage we can go to the assets and you going see that we have this bush here which is that one if we double click to open this up you can see that we have here and the Ami uh Bush which is like the material right and if we open up the material Master we have all these which are all the values right now we have the wind density we going to do is enable this and pull this to be maybe up one there will be like more wind and I think this will look nicer yeah definitely that looks way nicer if there's like more wind so that's cool we're going to leave like this okay and with that said I think that we're pretty good now let's make sure that the um The Wave spawner has this gizmos a bit more in place so there will be a bit more further away from the player so let's have it maybe like here bring them up may like here bring them up maybe like this is inside of the player so let's put this up here right and this will be a bit better and then last but not least this one bring it up and maybe more to Here and Now we will have the enemies properly spawn you know more around us as you can see and also a thing that we need to mention is that the nap bouns B if I press P it's not big enough so we need to make this bigger how much well maybe 50 and now it will cover more of the map which is very important and now yes you can see that now we can see more and also let me pull the camera a bit back from the player so we can see a bit more weld so maybe like uh 450 will work a bit better right yeah that's pretty cool I like it more like this and then also I think that maybe the trees we can disable Nite of them I don't know um let's test this out right because maybe they're consuming a lot uh so this needs to be on meshes okay so foliage uh aets and then on trees going to disable nide I see that's a bit better you know oh yeah that's way better and let's do the same with the trees so actually for I always say to use nanite but in Fage nanite is still a bit honestly like green right a bit still early um so it's way better if we use you know just the is um no more lods right um that looks so cool I love how this looks so the the next thing is just to go ahead and change the characters right that's pretty much what we need to do so for this again we'll use some aset packs as pack for the characters so let's go ahead and do so and for the characters we will use the stylized character kit which I will link in the description from the real Marketplace totally free so just once again the same that with the nature proct just added to your library click add to project and then search for our project and then just in case you see you just click show price select this one add to price and now we just need to wait a few seconds until it Imports all the characters all right as you can see now we have a new folder which is this c01 and inside we have a lot of different stuff as you know the uh mannequin character right for theine 4 or also the models and so on now there's a pre-made characters that we can use so for example if you want to use I don't know this uh one on here right where it contains his T-shirt we could select it open up the player and do so so let's go to the player blueprint select the mesh go and find one that looks pretty cool for example this one here mesh pc03 and and you can see that it looks like a type of um Goblin right why does it look why does it look like an arc survival evolved character like a goblin well that's because this is using the old and real Engine 4 character I mean if you want to play the game like this go ahead right I mean this kind of looks pry funny um but I'm going to make it a bit more elaborate right so uh we need to again use the R engine 5 skeleton instead of the old one so how would we do this well let's go ahead and and check this out but before we do that as I'm recording the video I open the project and as you can see the blank level will open that why is that well because the there's no level as default so we can go to prate settings go to maps and modes and set the editor start a map to be the one that we created which was a wave map there we go and also for the game defa map already just in case you build the game okay great so anyway now let's actually do that first of all open levels waves map there we go and uh if now we press play we had it like had before with the you know ugly character coming in so we need to basically change this character so now what we're going do is all the animations for the union for um casual kit so let's go to characters go to mannequins animations now on this AP player we can just right click go and say reti animation assets duplicate and retti it and now from uh u5 to u4 and then we can create a new folder on characters which actually on u4 new folder this will be um our animations so we know this one's already on and then on here let's click and now it will export everything okay there we go and now we can use this uh animation blueprint for our character so we can go back to our blueprints uh BB player and on here I can select the AVP player there we go the other one for uh the one that we retarted now everything will be completely fine as you can see but oh yeah there we go everything is great except for the attack animation which did not um you know work correctly so if we go to characters mannequins animations sorry our animations you can see that we don't have the the other one why is that because it isn't on the animation blueprint that's why I didn't uh retart this so we can go to mannequins animations Manny and then the push we can use I think that we can do it even in the Montage yeah uh then from u5 to E4 select our animations on here and then retar it and now we have that and I don't know if it's using yeah so we need to say that we want to use the new one so when we attack we want to use the push Montage 4 and VI Engine 4 and now that should be good there we go so that's working perfectly fine as you can see boom boom boom and now we need to do it also for our uh other character so we need to go to our blue blueprint enemy and then go to mesh and assign other mesh for example I don't know what um this one right for example and then the other plag it's so funny when it's like that and then also in the event graph for the attack it will be the other push montage and with that said we are ready to go as you can see now we have all the enemies like that okay and it looks really cool another thing that we can do is apply a random um you know U mesh right so we can create a variable mesh so it be like meshes and then this will be a uh skeletal mesh object reference we can compile make it an array compile and add all the ones that we want so we can press control space open up the draw go here models pre-made and drag in the first one drag in the second one and the third one and not the the one that player uses right and with that said we can go to begin play and here just get a random array items so we get a random mesh go to mesh and uh set the you know mesh uh asset scale to MH asset there we go and it will be basically this one and with that now every time that we press play we should see that we go random enemies appearing so I don't know why I cannot oh we go okay and I die actually you can see the random um enemies appearing right that's pretty cool now the thing is that we need to make sure that the mesh has the same colletion settings um which it should have for enemy okay but um used to make sure yeah it should be great okay that's cool you know we can go here me the enemies I don't know they have now more health or something I have 10 of Health let's see let's prove this for duration is we should be impacting them yeah okay so it seems like um for some reason now they have more health why well if we go to here we are you know playing the sound and then asking this so let's just print the health after this right and you will encounter with many situations where similar things will happen right suddenly they stop working um you can see uh that's because the health by default is it was um zero for some reason but it should go through here that's the thing right like look if you go through here and we attack zero - 10 throw down now why is not um you know going through here right you may be asking well good question good question need because we have minus or equal to zero right uh so that's the important thing um so let's print here just in case all right let's try this [Music] out yeah so it's it's going through there but it isn't certain the mesh to be simulated why oh I know why because the okay because the models okay do do not have a physics asset we you can go to create physics asset create an assign create asset create asset create asset create asset and now the uh physics assets will be created as you can see I can simulate them they will fall and now that will work so they did not have them um created basically okay if I now press play you can see that now this will be working that looks so cool boom so that is going ahead and working that is very cool you can see I have random players rning around that's cool and maybe what I going to do is increase maybe this to maybe uh 30 right and and then just disable the for duration and now we have everything set all right so last thing if you want you can add music um so I'm not going to cover how to oh let's let's let's cover let's cover you know bonus here okay so let's go to the audio folder and after what I did was leave in description also a Forest Loop now uh this will be the same as if you add music so I will not cover how to add music but uh it's the same thing as adding Forest Loop so double click on this and make sure that looping is enabled and then you drag this Forest Loop to the world and maybe change the volume to maybe. five so it's more subtle and there we go that's great so you want to do uh the same for the music go ahead and do so all right so that's pretty much all covered guys so that's it guys if you found this tutorial helpful I really appreciate it if you can like the video and subscribe to my channel remember that you can get the project files through my patreon and YouTube members join my Discord server to talk with me and other devs check out my new course with game the Tov on how to make a full stealth game in on real Engine 5 follow me on my socials and now yes with all that said bye-bye
Info
Channel: Gorka Games
Views: 285,743
Rating: undefined out of 5
Keywords: games, videojuegos, unreal engine, unreal engine 5, ue5, first game, tutorial, quixel, megascans, unreal engine first game, first game unreal engine 5, ue5 first game, ue5 beginner tutorial, ue5 how to make your first game, unreal engine 5 easy first game, unreal engine 5 beginner game, unreal engine 5 how to make a game on unreal engine 5, unreal engine 4, ue4, unreal engine 5 easy game tutorial, ue5 make your first game tutorial, beginner first game in ue5
Id: zt13VcimeyI
Channel Id: undefined
Length: 130min 46sec (7846 seconds)
Published: Sun Dec 17 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.