Hello guys, Smart Paul here, and welcome
to the Unreal Engine 5 Zombie First Person Shooter Game Beginner Tutorial. In this beginner tutorial, I will teach
you from start to finish how to create this zombie first person shooter game. I will walk you step by step
through this course, and all of the project files are free and
included in the description below. We will start by importing all of
the 3D assets into Unreal Engine 5. We will set up our character class,
animations, and blueprint logic. We will set up the weapon blueprint,
the line trace firing logic, the weapon muzzle flash and sounds. We will then create a zombie AI that
will chase the player around the level. We will go over how to add damage
to the zombie and we'll even cover how to set up things like applying
different damage amounts, such as a headshot versus a body shot. We will then create a high quality map
from scratch using free marketplace assets and free Quixel Megascans assets. Once we've made our map, we will set
up a waves based zombie survival game mode where our player will have to
battle through the various waves of zombies to progress to the next wave. I will even cover how to set up all
of the user interface using widgets, and we will add things like a main
menu, a win widget, a death widget, and even add a damage overlay for
when our player's health gets low. Finally, we will add some sounds to
our game and polish our level by adding some collision boxes so that our player
won't be able to jump out of the level. This is the most comprehensive beginner
tutorial showing you how to create a zombie first person shooter in Unreal
Engine 5 that is here on YouTube. So if you guys enjoy the video,
Please leave a like and subscribe. If you want to see more free content
like this, it takes me a lot of time and effort to make a video like this. And if you guys want to support
the channel, you can check out my patron or gumroad where you can
get access to my completed games, environments, or any of the projects
that I make here on the channel. You can also check out my
premium courses on smartpoly. teachable. com. And hopefully by the time you're
watching this video, those courses are published and available to watch. All right. So before you watch this zombie first
person shooter course, I do recommend you at least have done the following. So I expect that you have. Unreal Engine 5 installed and you
at least have some familiarity with navigating the user interface. And if you don't, that's fine, but I
highly recommend you check out my Unreal Engine 5 beginner tutorial where I show
you how to install Unreal Engine 5 and I explain all of the user interface,
navigation, and controls in depth. The next requirement is that you at
least know the bare basics of Blueprint and you can watch my Unreal Engine
5 Blueprint for Beginners video, as it teaches you what are blueprints,
how to use them, and much more. Now you don't have to know all this
stuff, because you can still follow this tutorial step by step, and I
will explain every part of the way. However, watching those two videos will
help you better understand this tutorial. Now with all that out of the way,
let's go ahead and jump right into it. Alright, so the first thing that we're
going to do is launch Unreal Engine 5. So go ahead and click launch
and click the games tab. We're going to be creating
a first person shooter. So we're going to choose the
first person shooter template. We're going to rename the. Project name to zombie game. You could also name it a
zombie FPS if you wanted to. And then we're going to go ahead and
leave these settings as they are. We're not going to use any starter
content or anything like that. And of course, make sure
you have blueprint selected. Then we can go ahead and click create. All right. So we have a couple of
different pop ups here. We can just click dismiss and
project files out of date. We'll just click update there. But basically we are
inside of the engine here. Um, we can play this little
demo and all this is, is a very simple first person template so
we can shoot some of these boxes. And it has just some minimal logic
for a first person shooter game. What we're going to do is we're
going to completely modify. This first person shooter template and
replace it all with some custom animations and assets from the marketplace. Alright, so right now you want to
go to the description of this video and download the project files. I'll leave a link in
the description below. Once you've downloaded the files, you
just right click and click extract because it will be in a zip file. And then you'll see the following
files here that we'll need to import into our project. So go ahead and get both of
these windows open like so. Open up your content drawer and
just click this dock in layout. I'll make it a lot easier when we
import content into the engine. And then what we're going to do is
we're going to start by importing our character and setting up our character. So right click in the content
browser, we're going to add a new folder and we're going to name this
underscore main, underscore main. And usually we just do this that way. This folder will be at the
far left and it will just keep everything nice and organized. So double click to open that up and
we'll create another folder, add a new folder here and name this character. Double click to open that up and then
inside the character, we can go ahead and open up this folder character arms. We're going to go ahead and select
this arms 3d object and drag and drop it into our content browser. And what we can do is just make
sure that we have selected mesh, checkbox enabled, and import mesh. Okay, and make sure there's
nothing here on the skeleton. All right, and we'll just leave
all the setting as they are. And we can just click import all. Okay, we'll get this message. No smoothing group information was found. And we can go ahead and
ignore that warning. It doesn't really mean anything to us. And here we have our character mesh. Let's go ahead and also
import these textures. So select all four of these textures
and drag and drop them in here. And then you'll see here the
normal map was imported as normal map, we can click OK. Alright, also in the character
folder we want to make, right click and create a new folder. And we'll name this animations. Okay, double click to open that up. And then in our project files
we'll go to the character anims. And go ahead and select
all these character anims. And drag and drop it in
the animations folder. It's going to ask which
skeleton you want to animate. Imports these animations
under in our case. We want to import these animations
under that Arms underscore skeleton that we've just imported. So go ahead and select that and click
import all okay So that's all we need for now so we can go ahead and make this
full screen So currently we have our animations here so we can open these
things up and see we have our animations and these animations are Not the greatest. I got them free on the marketplace So
they aren't the best but they are free and then the character model I also got free
off the marketplace and you can see here. It's just a really simple arms 3d mesh
Let's go ahead and set up the texture. Let's go ahead and set up the
material for our character's arms. And this will be really simple because
we have all these textures here. And then we already have this
material that's been created. So go ahead and double click
to open up that material. And then we can dock this here at the top. And then in the content drawer
here, we can go to main character. And shift to select these textures and
drag and drop it into our material. So we don't need this param here. We can select this and just click delete. And then we're going to go ahead and start
plugging in the textures to our material. So if you're not familiar with materials,
you don't have to worry too much. We're not really going to
cover that in this tutorial. Uh, we're mainly covering. How to set up gameplay and all that stuff. But really quickly, we'll
just set this material up. So this is the albedo or the base color. So go ahead and hook up the
R G B to the base color. Then next up we have the metallic. So hook the R G B to metallic. Then we have the normals. So hook up the R G B to normal, and then
we have the AO or the ambient occlusion. So hook that up like so. And just click save. Okay, we can go ahead and close that. And now if we click on this arms
skeletal mesh, you can see we have the hands textures all set up. Okay, we can go in the
animations and you can see. All the animations, the
textures, and all that stuff. And now we should be able to
start by setting up our character. So for our character, what we're going to
go ahead and do is in our main folder, we can right click and create a new folder. And we'll name this Blueprints. And so here we're going to use this
folder to store all of the blueprints that we're going to create for this project. We're going to start... By using the first person blueprint
that we saw here in this project. So, if you go to the first
person folder here, under the blueprints, you see we have this BP
underscore first person character. You double click to open that up. You can go ahead and dock this at the top. You're going to see all of the blueprints. And if we click the viewport
here, you can see the character with the arms, the camera. Basically... Everything that you see when you
click play, you have the character arms and the weapon, and all that
stuff is being powered through this BP first person character. So you can see we have things
like the movement input, jump, and then primary action input. So this is like when we press the
left mouse button, I call this delicate, which says use item. In our case, it is picking up this first
person weapon and shooting that weapon. So that's essentially all of the
logic here on this blueprint graph. Now what we're interested in
doing is essentially taking this blueprint and making it our own. So we're going to take these
arms and swap it out with our own arms mesh that we just imported. And start. Building upon this
character blueprint class. So first up, what I want to do is I
actually want to go into the first person blueprints folder, and we're just
going to move this to our underscore main blueprints folder and click. Move here and then right click your
content folder and click this fix up redirectors in folder So if you don't
know whenever you move around blueprint classes or Various things that are
referenced in your game You just need to right click and do the fix up redirectors
just so you don't have any errors or Issues in general down the line. Okay. So now we have our BP first person
character blueprint And here in the vport, we have our character. All that it's comprised
of is these components. So we have things like the
capsule, which is the collision. The first person mesh, which
is the character's arms. And then the first person camera. So let's go ahead and start by
switching out the first person arms. So if we go ahead and Select
our SK Mannequin Arms. We want to switch it to this Arms Mesh. And you can see the arms
need to be rotated, so you can click E on the keyboard. And rotate this maybe
about negative 60 degrees. Now we need to go ahead and
set up an animation blueprint. So we'll go ahead and start
by setting that up first. So right now if we were to just hit
play, nothing actually happens because we don't have an animation blueprint set up. So our character's arms aren't going
to move or animate or do anything. So in our content drawer here, I'm going
to just hit this dock and layout for now. In the character animations, we're
going to right click and first start out by creating a animation blend space. So we're going to go ahead and
right click, go to animation, and add this blend space 1D. And it's going to ask
us to pick a skeleton. We want to select our
arms underscore skeleton. And then we can just name this to Idle
Walk BS, so Idle Walk Blend Space. Go ahead, double click to open this up. So, essentially, all that a blend space
is, is it allows us to blend between two or more different animations. So, we're going to, in our case,
blend an idle and a walk animation. Or in this case, a run animation. So, I can show you real quickly. If we take our idle animation asset
and drag it onto our blend space. You can see we have this idle where
our character is holding the pistol. And they're just playing this idle
animation where the character is subtly breathing and holding the weapon. And we're going to drag and drop our
run animation here to the very end. And if you hold CTRL on your keyboard
and use the left mouse button. We can move this little, uh,
cursor all the way to the run. You can see our character is
playing this run animation. Like I said, the animations aren't the
greatest, but if you wanted to, you could use some more premium animations
that you purchased off the marketplace. But since these are free,
they will have to do. As you can see, we can move
it all the way back to zero. And we're playing this idle. We can click control and move
it all the way back to 100. And our character is running. So a blend space essentially
just allows us to blend between two or more animations. If we wanted to we could add
like a walk animation and put it somewhere in the middle. Now what we want to do is we want
to set up this horizontal axis. Because you can see here we have
a value of 0 and a value of 100. And what we want to accomplish is we
want to bind this value to our character. When our character's walk
speed is at zero, it will play this idle animation looping. But when our character's walk speed
is 100 or greater, it will be running. So to modify the horizontal axis
settings, over here on the top left, if you click this drop down,
horizontal axis, we have a name. We're going to change this to speed. So we're going to bind this
value with our character's speed. Then we have a minimum axis value, so
we have 0, and a maximum value of 100. We're going to change that value to 600. And then we're going to have to
take this run animation and move it all the way to the very end. So I have 0 and 600. And that should be all that we
need set up in this blend space. So we can go ahead and
save and close that. Then in our animations folder here. We can go ahead and right click,
go to Animation, and create what's called a Animation Blueprint. So it's going to ask us
to select a skeleton. We're going to choose our Arms
underscore Skeleton and click Create. And we can just name this
First Person FPS Anim BP. And go ahead and double
click to open that up. So the Animation Blueprint allows us to... Take things like our blend space
and pull all those animations together to use it in our blueprint. So, what we want to do right now is
add what's called a new state machine. So, off of this output pose you can
see that we can drag off of this result and it will add a drop down menu here. So, we want to go ahead and
search for new state machine. So, it will say add new state machine. And if you go ahead and double
click to open this up, it will allow us to create a new state. So what I mean by that is, drag
off of the entry here, and you'll see we have a drop down menu. We can add a new conduit, state
out, and we want to add a new state. So the state name, we're going
to name this to idle slash run. And then, we can go ahead and
double click to open this up. And... In the bottom right in the asset browser,
we can take our idle walk blend space and drag and drop that onto the graph. And you see we have this little
person icon animation pose. And we can hook that up to
the output animation pose. And we can compile and save that. So now you can see in our
viewport here, we have our... Idle walk blend space. You see we have the speed variable which
determines Whether or not our character should be playing that idle or that run. So if we change this value here to
600 and then click compile you can see our character is now playing that
run animation We can set this value back to zero hit compile and you
can see we are playing the idle So all that we want to do here is Find
this value to a variable and more specifically our character's walk speed. So drag off of this speed and
drop it on the graph and click here this promote to variable. So it's going to add a new variable
down here at the bottom of the type of float and if we hit compile we
can now use this variable and bind it to our character's walk speed. So over in the event graph, this
is where we can program stuff using blueprint and Set this speed variable. So off this try get pawn owner First
thing we're going to do is drag off here and do a is valid check I want
to see if the pawn owner is valid hook up the execution pin And then we
want to get velocity of our character, and then off the velocity we want to
get, or just type in vector length. And now we can use this green pen. Or the return value of a velocity
to set our speed variable. So select your speed and
drag and drop this and we can go ahead and set the speed. So off the isValid we can hook
this up and the vector length and hook that up to the speed. So now we have a really simple. Animation blueprint set up basically
we're getting the pawn owner in this case our character class We're getting
its velocity and converting that to a float that way we can set our speed and
that will Determine in this state machine whether or not we should blend between
our idle or running animation So if we go back to our first person character and
select your first person mesh Over here in the animation, we can set the animation
blueprint, so we're going to select our FPSAnimBP, and hit compile and save. And right now, it might not look like
anything is happening, and I wonder if that's just a bug right now. But if we go into our first
person map here, and click play. You can see that we have our arms
here, and basically when we move, we are playing that running animation. And when we stop moving, we are
just playing the idle animation. And of course we need to move the
camera around because right now we can see part of the character's shoulder. So let's go ahead and fix that. So in our first person character here,
in the transform of our arms, we'll go ahead and reset this back like so. And what I want to do is
change this to a global. Gizmo and rotate this about 90 degrees
and move this down and we're just going to align this Position this properly. Okay, so we can hit play here and this
might be a little bit too high You can also disable the grid snapping here. That way you get a more finer Placement
now, I'm just gonna go ahead and set the location values I actually went ahead
and found out which values work best for the vport So for the location on the
X, I want to set this to negative 12. 5 for the Y. I want to set this to negative 5. 4 for the Z. I want to set this to negative one 70. 5 pile and save that. And again, all that I've done is I've
tested these values out and I found that this Position looks best so I can
hit play and I have the character's hands You just see the character's hands
and not really full arms and you can mess around with the positioning But
like I said, I found that this was the best but you can see we are using that
blend space And animation blueprint where we're getting our character's
walk speed and using that to blend between our idle And our run animation
So now let's go ahead and actually add a weapon for our character to hold. Uh, right now you can see we pick up
that rifle, but nothing actually happens. And we actually don't want
to use that rifle at all. We want to get a pistol
model for our character. So let's go ahead and do that right now. So if you open up your Epic games launcher
here and head over to the marketplace tab, if you go to the search products here,
we're going to type in military weapons. And then you can sort. Buy free and you can see here. We have the military weapons silver and
we're going to go ahead and add this To our project and this is completely free. So you don't have to spend any sort of
money or buy anything So go ahead and add that to your cart and check out and
once you have it You can click this add to project and we're going to Search
for our zombie game or your zombie fps and just click add to project And
we'll go ahead and download the weapons and add those assets to your project. Okay, once it's finished downloading,
uh, we'll add a new folder here, Military Weapons Silver. And you can see if we open up the
weapons folder, we have a bunch of different assets that we can use. Uh, what we're mainly interested
in is this pistol underscore A. So this is a nice free 3D model
that we can use for our character. So we want to go ahead and attach
This weapon to our characters hands. Now we're going to do that by going
to our underscore main character and in the arms here, you can go ahead and
double click the arms and we actually want to head over to the skeleton. So click this skeleton icon up
here and we're going to attach that pistol model to our characters hands. So, we're going to use
what's called a socket. Now, sockets are what allow you
to attach various items, weapons, swords, shields, helmets, all that
sort of stuff to your character. So sockets allow you to do
that through the skeleton. So we need to go ahead and find our... right hand bone. So in the skeleton hit tree
here, if you find your right hand underscore art, we can right
click that and add here a socket. So click add socket and we can
double click this socket and rename this to pistol socket. So now we can. Right click this socket, and down here
at the bottom we can add a preview asset. So if you scroll down here, you
see we have a bunch of things that we can use to preview. We want to search for our pistol
underscore A, so click that. And now you can see we have this
pistol model that we can now position by using the W key to
get our move gizmo or E to rotate. So we can rotate this about 80
degrees, hit W on our keyboard, and we can start moving. And positioning this pistol
onto our character's hands. Okay, you can also tweak the
camera speed here, that way you don't fly all over the place. And a better way of doing this is to
click this little preview animation. And what we want to do is go to the idle. So if we go to the idle animation,
we can pause this, and now what we can do is we can actually
position this pistol properly. So we can hit E to rotate, I actually want
to change this to the global scale gizmo. So now I can rotate this
about 30 degrees, negative 20. Okay, like 10 and switch to the movement
gizmo And just position this pistol To about what I think Would be a good
spot And if you click out of anywhere, you just reselect the socket And that
will allow you to position that like so Now again, I've experimented with all
of the values here for the location. So I'm just going to go
ahead and type that in. So I'm going to type in
a negative 8 on the X. The Y, 4. 9. And the Z, 0. 8. Negative 0. 82. And save that. So it looks like we had it about right. Now we can go ahead and close that. So, now if we were to hit play,
nothing is actually going to happen, the pistol isn't attached to our hand. So, in our blueprint, first
person character, we want to add a mesh component. So click and add a new skeletal mesh. And we don't want it to be arms, so click
on the skeletal mesh and click clear. And rename this to Pistol Mesh. Okay. And then for the mesh, we can set the
Skeletal Mesh to Pistol Underscore A. Now you see we have this pistol model. And instead of going and placing this
model on the character's arms, What we want to do is, over here on the parent
socket, We want to click this little magnifying glass and search for our pistol
socket, okay, and have that selected. Now for the location, we just
want to click this arrow to reset it to the default location. And you can see it snaps to our
pistol socket and to the hand. So compile and save that. And now we should be able to click play. NEC, we have our pistol
and our character's hands. And when we run the model is basically
just attached to our character's hands. So we're going to have the
pistol equipped by default. Okay, so we've covered
the animation blueprint. We've added the weapon
to our character's hands. And what we want to set up next
is, we want to give our character the ability to shoot the weapon. But before that, We also want to be able
to aim down sights, so we want to be able to click the right mouse button and be
able to aim down the sights of the pistol. That way our character
has a more accurate aim. And then we'll go ahead and
also set up the firing logic on all those blueprint nodes. So if we go in the content
browser here, under the character animations, we have these. Different aim fire and idle fire. You also have this, these aim poses. So you see, we have an aim pose. We're holding the weapon
and our arm is straight. And then we also have an
idle to aim or aim to idle. So let's go ahead and go into
our FPS animation blueprint. And over to our idle slash run
state, and we can click these back arrows to back out of there. So we want to go ahead and add a new
state in here, and one for our aiming. And this will really explain what states
allow you to accomplish within Unreal Engine in the animation blueprint. So if you drag off the idle slash run,
we're going to add another state here. And we're going to name this idleToAim. And then off of that state we're going
to drag and drop at another state. And name this aim. So, basically we're going
to do our idle and run. Our character can then hit
right mouse button, it will play the idle to aim animation, and
then it will play our aim pose. Then off our aim we can drag
off of here, add another state, and name this aim to idle. And then take and drag off of this and
hook it back up to the idle slash run. Hit right mouse button, we're gonna
play the idle to aim animation. Then we're going to lock the aim pose. So as long as our character is holding
the right mouse button down, we're going to be aiming if they let go,
we're going to play the aim to idle and go back to our idle slash run state. If you compile right now, you're going
to see, we have these yellow warnings. That means that we haven't
set up these transitions. So these transitions allow us to
program in logic and basically bind variables to whether or not we
should transition from idle slash run to our idle slash aim state. So before we set up these
transitions, let's actually set up these different states. So open up the idle to aim. All we need to do inside of here is
select our idle to aim animation. Drag and drop and hook that up like so. And then back out for our aim. Double click to open that up. And just select your aim pose
animation and hook that up like so. And then lastly the aim to idle. Select your aim to idle pose
animation and hook that up. So now we can set up our transitions. So for our first transition here, if
we double click to open that up, you see we have this can enter transition
a variable and this is a boolean so we can drag off of this and Promote this
to a variable and we're going to name this variable is aiming question mark
compile and save that and basically this boolean is Either a true or false. So is our character aiming either? Yes or no. So we can bind this to whether
or not we're clicking the right mouse button on our keyboard. Now, if we back out here, we
have this transition, I will to aim into our aim pose. And for this. We're going to do something
a little bit different. We're going to right click and get time
remaining ratio, idle to aim, and then off of the return value, we're going to
do type in less, so this operator less. So we're going to get basically the
previous animation, the idle to aim. Right here, I'm going to check and
see if this animation is less than 0. 7 and hook that up into
this can enter transition. So basically if our animation is pretty
much almost done playing, then we can go ahead and enter the aim state. Okay, next up for our aim to then aim idle
transition, double click to open that up. Here all we have to do is get our
is aiming variable and dry off here and do a not So I want to scroll
up here and do the not boolean. So basically if our character is not
aiming, then we can enter into the aim to idle, and then our idle to run. And the last transition is going to
be the same thing that we did here, where we get the time remaining ratio. Aim to idle and search for less
operators, less, less than 0. 7 and hook that Boolean up. So now we have all of our states
set up and all we have to do now is to bind this is aiming Boolean
variable to our right mouse button. So in our BP underscore first person
character, in our event graph here, we want to go ahead and add a new variable. And the variable will be named aiming
question mark, compile and save that. And then in our first person animation
blueprint, in the event graph, we can get, try get pawn owner off the return value. And we're going to do a cast
to first person character. So if you don't know what a cast node
is, it allows us to access certain variables within this blueprint class. Thanks. By casting to it. So off of this return value here,
we can get aiming so we can get the aiming variable here, which is that
same variable that we created inside of this first person character. So now that we're getting this, we
want to set our is aiming variable inside of our animation blueprint. So select that drag and drop and click. Set is aiming. So we wanted to go ahead and set the
is aiming and plug that up like so, and then hook up the execution pin like that. So we have all of this set up
and our animation blueprint. All we need to do now is go to our
character and actually set up the. Right mouse button that will allow
us to set our is aiming a variable. So in our graph, we can right click
and type in right mouse button. And so here we can use this
event to set this variable. So go ahead and select the aiming
drag and drop and click set. So if we are pressing the right mouse
button we want to click this checkbox that will mean that we are aiming. We want to select this and CTRL
C, CTRL V to duplicate this. So when we release it we want to
uncheck that for is not aiming. So go ahead and compile and save that. And now we should be
able to test this out. So if we go to our first person
map right here and hit play. If we hit our right mouse button, you
can see we are aiming our pistol and we are back to our normal run blend space. But if we right click, see
we are in that aiming pose. And we actually need to go ahead
and fix up the pistol here. We need to rotate it a little bit
so that it's actually straight. Right now it's a little crooked. So let's go ahead and do that real quick. Our content browser, select and
open this arms underscore skeleton. Uh, we're going to set a preview
animation, our aim pose, and we're going to put our camera right about here. Uh, let's pause the pose,
go to our pistol socket. I think we just need to rotate this. I'm going to uncheck the rotation
snapping, so we get a smooth snapping, and I think that
should be a little bit better. Go ahead and save that and hit play. Let's test this out. Okay, so I think that's
a little bit better here. So that looks a lot more lined up. So now we have our aiming. We right click, we are aiming. And when we go back to left click, we
have our running and walking, our idle. What we also want to set up
is when we are aiming, we want to slow down our character. Because right now, if we just
aim, we can still pretty much run. And we don't want that, we want our
character to be slower when they aim. So, one way that we can do that
is in our first person character. And we can go ahead and select
this character movement. And if you drag and drop this onto
the graph, this character movement component allows us to set our walk
speed, drag off of here and we can type set max walk speed and select
that and hook up the execution pin. So when we are aiming, we want to set
our walk speed to 200 and then copy and paste that when we aren't aiming. We want to set our walk speed back
to 600, which is its default value. So compile and save that. Hit play. You can see when we are aiming,
we're really slow, but when we let go of our right mouse button, our
character can run at a normal speed. So we've gone ahead and set up our aiming. Let's go ahead and set up the
actual fire weapon firing blueprint. So we can give our character
the ability to fire the weapon. So in our content browser here, I'm
going to click this dock in the layout. In our character folder, in
the animations, we have two different firing animations. So we have the aim fire, so this is
when we are aiming, firing the weapon. And then we also have this idle fire. So when we are not aiming,
this is the firing animation. So we want to use these two animations. When we fire our weapon, then we also in
our military weapons, silver under the weapons, there's this animations folder. So go ahead and double
click to open that up. And all of these weapons are animated. So you can see here, we have
a fire pistol underscore W. So go ahead and double
click to open that up. And what you see here is
basically we have this animation. And we also have this muzzle
flash, so whenever this animation plays, you have this muzzle
flash and also this firing sound. Now if you were to set this up from
scratch, basically, all that this is, is animation notify, and you can
right click and add a new notify. You see here we have things like
playing sound, play particle effect. That's all that this is,
is a particle effect. That is playing whenever this animation... is playing. Okay. So this is a nice pack that already
comes with all of the muzzle flash and sounds already set up. So we don't have to do any extra work. But like I said, if you wanted to add
this in yourself, all you'd have to do is right click and add that notify
either a particle effect or sound. What we want to do is we want to use this. Firing animation on our pistol, as well
as the firing animations on our character. Let's go ahead and go back to our
character animations and you wanna select the aim, fire and Idle Fire. And we're going to convert
these animations to what's called an animation montage. And montages allow us to call those
animations within our blueprint. So with those selected, right click,
and at the very top we can click the create, and create animation montage. So you can see we've added
these two blue, uh, idle fire montage and aim fire montage. So now we can actually call
these animations from within our character blueprint. So go over to your character
blueprint here and down here, we're going to right click and
search for our left mouse button. So when we click our left mouse button,
we want to play those firing montages. But first we want to go ahead and
check to see if we are aiming. So go ahead and get your aiming variable. And off of this we can
drag and do a branch. So we're going to go ahead and off
of the pressed here, check and see if we are aiming or if we aren't aiming. And this is important because we
have those two different montages. So we have The aiming
firing and the idle firing. So off the true here, we can do
what's called a play and, um, montage play montage for our
in skeletal mesh components. We want to select our mesh, drag and drop
it, and hook that up, because the montage will be playing on our character mesh. And the montage to play will
be our, um, AimFire montage. So if you click this down arrow, it'll
show all of our animation montages. So we have the AimFire, and then
we can compile and save that. Then we just need to select this play
montage, CTRL C, CTRL V to duplicate that, and hook this up to the false,
hook up the mesh to the in skeletal mesh, and if our character is not aiming,
we want to play the idle fire montage. So compile and save that. So if we hit play here. You can see that nothing
is actually happening yet. And that's because whenever
you use animation montages, you actually have to add a node inside
of your animation blueprint. So there's this very specific
thing that you need to do if you want to be able to use montages. So go to your new state machine. And back all the way back
out to your anim graph. So all that we have to do is
select this output pose, move this over and drag off of here. We want to do a default slot. So montage slot, default slot,
so compile and save that. Now all this note is doing is basically. intervening in between our state
machine and our output pose. And all this is doing is listening to see
if we are playing any sort of montage. And what it will do is it will
add that montage to our animation blueprint or to our final output pose. Okay, so whenever you're using montages
and it's not working, you want to double check and make sure that you have this
node included in your animation blueprint. And I think I missed one more
thing, which is, instead of using this mesh, I believe we need to
use the first person mesh instead. So hook that up for the in skeletal
mesh component and now having done that if we hit play you can see We
have a idle fire animation So we click fire also have an aim fire animation
now This animation isn't the greatest you can see the hand they're sliding. So it's not the greatest animation
In fact, we can actually go ahead and shorten this animation Cause you can
see that hand glitches back and forth. Uh, so let's go ahead and fix that. Like I said, if you guys have a better
animations or if you're a animator and you want to donate some animations
to a course video that I make here on the channel, feel free to do so. Um, but in the main character animations,
I believe that is our aim fire. So let's go ahead and
just shorten this up. So right about there we can, Right
click and remove frame 11 to 23. And so now we just have that
very short firing animation. So save that. And then we also want to right
click, create animation montage. And then we can go ahead and
delete this other one that we had. And replace the reference with
our aimfire underscore montage1. So replace references and click OK. Save selected. So that all that should have done is
in our blueprints Swap that animation out with our aim fire one montage
so we can go ahead and test this out by hitting play aim You see our
fire animation looks a lot better okay, our idle one is so a
little bit janky, but We can also fix that one as well. Like I said, if you have better
animations, you can use those instead So, Idle Fire here. Let's go ahead and shorten this up. So here, like that. Maybe frame 7 we can right
click and remove frame 11 to 23. Okay, still a little bit
janky, but we'll have to do. Go ahead and save that. And then, we can right
click our Idle Fire. Create animation montage, and delete
the previous one, right click delete. Replace the reference with
the idle fire underscore one. And replace references, okay. And save selected. Okay, so that's a little bit better. So we have our firing whenever
we click the left mouse button. So the next thing that
we want to do is also... Play the firing animation on the
pistol because that's what actually uses the muzzle flash as well as
it plays the sound whenever we pistol firing animation is called. So, in our character blueprint,
blueprints, open up our BP underscore first person character. We want to get our pistol mesh. Just drag and drop that there. And then, off of this we
want to do a play animation, and the animation that we want to play is
our fire underscore pistol underscore w. Okay, so, off the play montage you
want to hook up this first execution pin up to the play animation,
and we want to hook this one up. Also like so. So if we compile and save that and hit
play, you can see we have the muzzle flash and we also have the sound playing. You can see also the pistol is animated. So the the handle or whatever it's called. I'm not too familiar with firearms. But you can see it slides back and
yeah, that's pretty much our firing set up or at least the visual aspect Okay,
so all the visuals are now set up for our game So we have our aiming pose. Yeah, we're walking idle. We also have our firing animations So
right now nothing is technically happening like for example if I were to shoot this
cube Nothing would happen to the cube. The only thing that we have
really set up is the visual side, which looks pretty good. Before we start setting up things like
a line trace for our weapon, To do weapon damage and things like that. We want to go ahead and start
setting up our zombie blueprint. So this will be our zombie enemy AI
that will chase us around the map. And that we can then damage
and kill with our weapon. So let's go ahead and
start working on that. So we're going to need some project
files to start implementing that. So go ahead and dock and
layout to your content browser. And in our main folder, we're
going to create a new folder and name this a zombie. Okay. And double click to open that up. Then in the project files, we have a
folder here called scary zombie pack. So double click to open that up and this
is a model that I got off of Mixamo So it's not the most high quality model But
it will do for this course and what we want to import first is this zombie girl
3d object So go ahead and select and drag and drop that into the folder for the
skeleton We want to leave this empty and make sure that you click this checkbox
Import Skeletal Mesh and Import Mesh. Um, and leave everything else
as is and just click Import All. And you can see here we have a
lot of these warning messages. You don't have to worry about any of that. Just click the X. And what it did was it
automatically imported the textures. It also set up all the materials. But, if we open up this
zombie girl right here. You can see that our character
is basically this ghost. The materials are... Translucent. Let's go ahead and fix that up real quick. Go ahead and open up these materials here. And we can select this material node,
and in the details panel, we want to set this from translucent to opaque, okay? And save that. And we want to do the same for these other
two materials, so go ahead and open that. Select this material node
and set this to opaque. Click save and the last material here
select that and set this to opaque and save okay Go ahead and close that
so we have our character set up here. Like I said, it isn't the most detailed
next gen character But it will do for this course, you know swap it out
later with a higher quality 3d model that you get off the marketplace,
but right now that will work now. What we want to do is import Our
animations, so make a new folder in here and we can name this animations. Double click to open that up. And you want to select all these
animations other than that zombie girl mesh that we already imported. And drag and drop that into that folder. Now for the skeleton we want to
select our zombie girl underscore skeleton and click the import all. Alright, so that took a little bit, but
now it is imported here into our project. So we have all the animations here. And we can go ahead and just do a file
save all just so everything is saved and let's go back into our zombie folder
here and what we want to do is set up a character a character blueprint so
just like our first person character here we want to do the same thing. And basically set up a character
blueprint for our zombie character. So right click in here and at the very
top, we can click this blueprint class and we want to click the type character and we
can rename this to BP underscore zombie. Okay. So double click to open that
up, dock this here at the top. In fact, if you don't like having to. Dock these things at the top. You can go to edit editor
preferences and Down here on the asset editor open location. You can set this to main window. I usually do that every time I Open up a
new project that way whenever you double click on an asset It will automatically
open it up here in the main window. Also if you ever get This view, when you
open up a blueprint, all you have to do is click this open full blueprint editor. That's, that basically happens
whenever you have a blank blueprint class that has nothing in it. All you have to do is hit that
open up full blueprint editor. But basically here is our zombie
blueprint, it's completely empty, there's nothing in it. But we can go ahead and start by
adding our mesh, our character mesh. So in the viewport here with the
mesh selected, in the skeletal mesh we can search for our zombie girl. And we just need to
click E and rotate this. 90 degrees, and I'm going to turn back
my snapping on so rotate this 90 degrees Hit W and move this down, and I think
we need to scale this character down So I'm going to type in the scale 0. 8, 0. 8, 0. 8 Actually, I think I did 0. 87 and I think that is pretty good
for now Now what we want to set up is our animation blueprint. So right now it's just in the T pose
and we don't have any animation playing. So in our content browser here in the
animations, we can right click and add. First, a Animation Blend Space 1D. Okay, so we can search for our
zombie girl underscore skeleton. And we can name this to ZombieBS
for a zombie blend space. Double click to open that up. And the blend space will be
very similar to what we've had set up for our character. So in the horizontal axis,
we'll name this to Speed. For character speed, the
maximum value here will be 600. As for the grid divisions, uh,
this value tweaks how many grid divisions that we have here. I want to set this value
to 10 and click save there. We're also going to add
a smoothing time here, 0. 5 and the smoothing type will be averaged. So this is going to smooth the animations
that our character will be playing here. And you'll see, this will come into play. Uh, later on when we have our zombie
character moving around the level. So now we can go ahead and drag some
animations into our blend space. So the first thing I
want is our zombie idle. Drag and drop that to zero. Then we want our zombie walk. And drag that to about there. We can set the value here,
the speed value to 60. So, we have idle, and then we have
walk, very slow paced walk, and then what we want is a running, so if you
search for run, so we have this zombie running right here, we can drag and
drop this right about there, and for this value we can select this, and we
want to set the speed to 360, so we have our idle, Walking, and then running. Alright, so that's our blend space set up. And we can go ahead and close that out. Now we want to set up
an animation blueprint. So right click, add a
animation, animation blueprint. Skeleton will be our zombie
girl underscore skeleton. And click create, and we can
rename this to ZombieNMBP, and double click to open that up. And we're going to follow the same sort
of setup that we had in our character. So we're going to drag off of
here and add a new state machine. And in there we're going to drag
off of here and add a new state. And we only need one state
which is the idle slash. And double click to open that up. And we just need to
hook up our blend space. So drag and drop that in there and hook
up that result like so and for the speed We want to drag off of here and promote
that to a variable named speed pile and save that And again, we can bind this
variable to our characters walk speed So let's go ahead and do that by going
to our event graph and very similar to what we did in In our character, off of
the TryGetPawnOwner, we're just going to do the same thing, check and see
if it is valid, question mark, so hook up the execution pin, and then off the
TryGetPawnOwner, we just want to get velocity, and then we just need to convert
the velocity, so we do vector length, and now we can grab that speed
variable, drag and drop it, and click set, and hook up the is valid,
And the return value right there. And compile and save that. So that's all set up. We should be able to
go ahead and use this. So in our zombie blueprint. We can set our animation
blueprint to that zombie anim BP. Compile and save that. Now you can see we have our
character doing that idle. Now, if we go ahead and
drag this into our level. Nothing is actually going to happen yet. So if we go to zombie here. And drag and drop our
BP underscore zombie. Uh, maybe rotate this like so. And then if we hit play
here, nothing's happening. It's just playing that idle animation. You know, we can shoot it, but
obviously nothing's happening. So we want to go ahead and set up the
blueprint logic for the zombie to be able to chase our character around the level. And this is actually really simple. To set up, so on our BP underscore
zombie in the event graph. Go ahead and delete these two events here. We're going to use the event begin play. Is called every time the game starts. Uh, we're going to right
click and add custom event. So click this add custom event. I like to use these custom events to
kind of explain how the logic works. So we're going to name
this to run to player. So basically this event. is a really simple event that will
have logic that will move our character to chase our first person character. Now off of our event begin play we can
go ahead and call our run to player and now we can start programming
and adding all the logic here. So to allow our zombie character to chase
our player, we can do the AI move to node. So this AI move to, and the pawn we
want to drag off of here and type in self, get a reference to self. So the AI that is going to
move to is ourself and the target actor track up for here. We want to get player
controller at index zero. So this is basically getting our player
or our reference to our character here and plugging it in for our target. And for the acceptance radius,
we're going to set this to 40. And before we test this out,
we need to do two more things. First thing being in the class
defaults, we want to do a couple things. We want to tweak two values, and
it's important that you do this, or else you might have different
results towards the end of the video. So the main two things that
we're going to do here is. We're going to uncheck use
controller yaw and this will help the animation look more smoother. Then we're also going to
change the auto possess AI. I'm going to change this
to place in world or spawn. Okay, compile and save that. And then before we hit play, we
want to add a navigation volume. So if we were to hit play right
now, nothing would happen. And that's because we need
some sort of navigation volume. That the AI will use to learn which
objects it can run on and all that stuff. So if you go to this cube plus
icon and go to the volumes, we have this nav mesh bounce volume. And we can go ahead and
drag this into our level. Hit the R key, and we can
go ahead and scale this up. So we just want to scale this up large
enough to encompass our entire level. Okay, and scale this
up a little bit larger. And that should work. And if you hit P on your keyboard,
So if you hit the P key, It will show you basically the navigation bounds
that this zombie character can run on. So it will show you all the areas that
the the zombie character can run around and basically it will generate The paths
that it can run on and hit P to hide that But now if we hit play you can see that
the zombie character actually just chased us and found us So go ahead and move this
a little bit farther here right about there Hit play you see that the character
is now chasing us and actually it is Not even facing us, so we need to fix that. But you can see here, it's chasing us,
it's really fast, it's basically running. And whenever it gets near to us,
within a certain distance, it'll stop. So our AI is pretty dumb right
now, it's not really acting the way that we want it to. So we need to fix quite a few things
to make this actually work better. Now to fix the issue where the
zombie would stop chasing our player. Basically you can see off this
AI move to on the on fail. All we have to do is recall this event. So if it does not. Reach or reach our character the on fail. We just need to call the run to player
So basically this will keep looping until we find our character Okay, so
we had a another bug where when we hit play here the character zombie character
doesn't face the player and what we want to do is so again, make sure that the
You have the Use Control Rotation Yaw unchecked in the Class Defaults, but
if we select the Character Movement in the Details panel, if we scroll down, all the way down here to Character
Movement Rotation Settings. This is about halfway down. We want to change the rotation
rate, the Z value to 180. And then we want to orientate
rotation and movement. So make sure that you make these
changes in the character movement. And in the class defaults, you want
to make sure that you have this Use controller rotation yaw unchecked. So now if we hit play, we get
sort of this smooth movement. So I can show you again here. We need to slow the character
down, but right now the character will rotate smoothly around
corners when chasing the player. So right now our zombie character
just runs absurdly fast, and it's really hard to escape. And what we want to implement
is some sort of way that our... Zombie character can start out walking. We want it to walk slowly. And then when the zombie sees
the player, then it will actually charge and run at the character. Okay, cause right now that 600
walk speed is just way too fast. And the player just can't outrun it. So, by default, if we
go into our BP zombie. And select our character movement. You can search for max walk speed. And you can see we have 600,
uh, centimeters per second. We can change this to, I believe, 60. Compile and save that. If we hit play, you can see
that our zombie character has this really slow walk. And basically it's just gonna try
and walk and chase our character. Okay? And what we want to implement
next is basically when we get to a certain range or... If we get close enough,
it will start charging us. So, so in our event graph,
BPzombie, actually in the viewport, we want to add a new component. This will be called Pawn Sensing. So this adds a bunch of different
spheres around the character. And over AI, We have the hearing
threshold and the sight radius. So this controls how big
these, uh, spheres are. And basically, uh, how far the
zombie can sense our player. I believe I had the hearing
threshold set to 388. And the sight radius to 1440. So that kind of shrinks that down a bit. And then in the event graph,
somewhere down here we can right click and do a onCpawn. So this is an event that gets called
when the PawnSensing, or basically when our character is sensed
through this PawnSensing component. Then what we can do is get
our character movement speed. And set max walk speed. So if we sense a pawn, or in this case our
character, we can speed up our character and set our max walk speed to 360. Alright, and the way we got this
variable, uh, the 360 value, um, is if you go into the zombie blend space,
that is basically our running animation. So that's how we got that number. It's not a random, arbitrary number. Uh, we actually got that
from our blend space. So, uh, let's go ahead and move
our zombie all the way over here. Okay, if we hit play right now the
zombie is slowly walking towards us. If we get within the sensing range You
can see that it starts charging towards us, and it's running at a decent rate now. It's not too fast A player can outrun
it But you know if we were reloading or doing something or whatnot and weren't
paying attention And the zombie could chase up and catch up to us But yeah,
now that we have that set up, you can see when the zombie actually reaches us. It basically stops and that is due
to the fact that basically when this AI move to on success, so when we get
close enough to our player or when we move to our player, the on success
gets called and nothing happens. So that's why the character
basically freezes. So what we want to implement next
is some sort of attack system. So we want the zombie to be able to
run up to our character, and when this on success is called, so basically
when our zombie gets close enough, we want to do an attack sequence and
apply some damage to our character. So, let's go ahead and move
this pawn sensing up here. And we can right click and add custom
event, and we're going to name this event attack player, compile and
save that, and then on the success we can call that attack player event, and so now we can start programming
our attack, and for our attack we want to do an animation montage, so
in our content drawer here we have all these different animations,
And we have this zombie attack. So the zombie attack animation,
basically the zombie just does a swing and we can go ahead and make
a montage so that we can use this. So right click, create,
create, and a montage. And then in our zombie here,
we can go ahead and right. Click do a play montage. Okay. So hook that up for the in skeletal
mesh component We want to get our mesh and hook that up for the montage. You want to do our attack? zombie attack montage Compile and save
that And technically we could go and test this right now, but I already
know that this isn't going to work. Uh, because we need to go ahead and
modify our animation blueprint first. So if we open up our
ZombieAnimBP, we want to add that. Default slot node. So here in the anim graph
all the way back out here. I'm gonna drag off of here and do that
default slot if you remember From earlier. This is what allows us to you play
those animation montages on top of The current animation blueprint. So now we should be able to test
out our attack sequence so if we go ahead and Hit play here. Our zombie is going to run at us and
do an attack and that's basically it. Okay, so just does that one attack
nothing really happens afterwards. All we have to do to continue
chasing our character is after this attack montage on complete we
just have to do a run to player. Okay, so basically this
will loop our zombie. And our zombie will always be chasing and
or attacking our player so you see we do the attack And then it's going to keep
running and if I stop here, it'll attack me again, and then I can keep running And
basically it will just keep looping and doing the same logic over and over, okay? We might want to edit that attack
animation because it's a little bit too long Like I could run out here and it's
still playing that attack animation. It's still frozen right there So we
might want to tweak that a little bit. So in our content drawer here,
zombie attack As you can see, it's a really long animation. So right there, do we do the tack? So we could delete pretty much all
of the frames after right about here. About frame 500, we can right
click, remove frame 588 to 791. Okay, so just a really
quick attack sequence. And then we can go ahead, right
click, create anim montage, and delete the other one that we had here. And we can replace the reference
with that attack anim montage one. Place references. Okay, and save selected. So now it should be a little bit
faster on the attack animation. Yeah, that's a little bit better. So right now we have our attack
animation and our basic zombie chasing. But currently our zombie doesn't
do any sort of damage to our player and our player can't really do
any sort of damage to the zombie. So I could shoot at this zombie
all day and nothing's gonna happen. So we need to go ahead and implement
damage and health for not only our player but also our zombie character. So let's go ahead and start with our... Character blueprint first So on the
content browser, let's go ahead and open up our character or blueprints first
person character and let's start by implementing the weapon damage system So
we can set up our pistol to be able to damage our zombie character Okay, so head
over to the event graph here and let's actually add a comment So over our right
mouse button, we can press C and we can name this aiming logic and then select
the left mouse button logic right here. And we can name this shoot logic. And then over here we're
going to start working on. Doing the actual, uh, weapon firing logic. So, right here is basically
all the visual, um, things. So, for example, the montages. And over here we will actually
want to do a line trace. And apply some damage to whatever we hit. So, very first thing that we want to do. Is we want to go ahead and
select our first person camera. Drag and drop it here. And drag off of the first person
camera, we want to get world location. So we're getting the location
of our camera, and we want to also get world rotation. So what we're going to do is, we're
going to get the center of the camera's position, and basically do
a line trace from that center point. To whatever we hit and see if we hit
any sort of objects so we can go ahead and take this value and promote this to
a variable and we can name this camera location and then the get world rotation
we can drag this off and promote this to a variable as well and name this camera
rotation and we can hook up the execution pins you And hook this up like so. Okay, and now we're going
to do that line trace node. So right click, and it's
called line trace by channel. So line trace by channel right here. And hook up the execution pin. So the start position is going
to be our camera location. So drag and drop that
variable and hook that up. In the end location, we're
going to do some calculations. So what we're going to do is we're
going to get our camera rotation, and we're going to get forward vector. So what we're doing is we're getting
sort of the length, and we're calculating at what point should we And our line
trace at, and we want to do a multiply. So if you type the little asterisk
icon, you can get the multiply node. And now we want to add another variable
down here and name this bullet distance. And we want to change the
variable type to the type float. So the bullet distance, you go
ahead and drag and get this. This will determine how far
our line trace should be. And we're going to set the default value
of this bullet distance to 10, 000. I can show you how to determine
that distance here in a second. We're going to go ahead and multiply
that by our forward vector here. Okay, and then we're going
to do another multiplication. So copy and paste that here
and plug that in like so. And we're going to multiply
that with the camera location. And then we're going to add
that in for our end location. Okay, now for the settings here. We want to change the trace channel
to camera So it's coming from my camera and we want to click the
trace complex now We also want to ignore, use the actors to ignore. So we want to drag off
here and do a make array. And the actor to ignore, if we
drag off here and type in self, we can get a reference to our
Self which is our character. So we just want to ignore our self that
way We don't shoot our own character and then we can draw a debug type We're
gonna do persistent here just so we can see what we're doing So now we should be
able to test this out if we hit play You can see we shoot my left mouse button
and it adds this red line so you can see the hit points We can also aim so you
can see basically what we're doing is we're Doing a raycast, so we're shooting
a line to see if we hit anything. But it's hard to see with no crosshair
or anything like that on the screen. So I think we might add a crosshair first. That way we can get a visual
of where we're aiming at. Uh, go to the main, we're gonna
make a new folder real quick. And name this widgets. And then in here, we're going to import. A crosshair file, so in the project
files under the UMG, we're just going to go ahead and import all of these
textures right now, even though we just need the crosshair for now, but
just go ahead and select all these and import them into your widgets, and
now let's go ahead and right click in the widgets, and we're going to add a
new user interface, Widget Blueprint. Widget Blueprint. And click the user widget. You can rename this to main widget
W and double click to open that up. So if you're not familiar with
widgets, basically this is how you add user interface on your character. So things like a health bar
and all that sort of stuff. So select your main widget. We want to add a canvas panel. So, select the canvas panel and add
it to your main widget, and then all we want to do is search for image
and add it onto the canvas panel. So this will be for our crosshair. Now, for the anchors, so here on the
top right, we want to anchor this to the center, and we can reset the position, X
and Y, and the alignment, we want to do 0. 5 and 0. 5, so that will center it in the center
of our screen, and for the brush here, expand that down, the image we want
to, search for our cross, this cross texture, And we want to change the
size here, size X and Y, to 30 by 30. And compile and save that. So basically it's just this tiny little
crosshair at the center of the screen. Now we can go ahead and close that. And in our event graph, in our player,
we have to add this widget to our... screen. So right click, search for event
begin play, and off the event begin play we're going to create widget. The widget will be our main widget
underscore w, the one we just made. The owning player we can
drag off here and get player. Controller. And then we just need to add to viewport. Okay. And we can add a comment over
this and just name this to widget. And compile save that. Should be able to hit play. You see we have this
little crosshair widget. So now this will show us exactly where
the line trace should be coming from. Okay. So I figured out a Mistake that I
made so currently you see here We set up the crosshair, but we're
still having this issue where when I shoot the gun the line trace isn't
Aiming where the crosshair is aiming. Okay, and to demonstrate
this I can hit f8. I can show you that Basically,
it's not aiming directly down Where we're pointing and the reason why
is 'cause I actually messed up. So instead of multiplying camera
location with the camera rotation, we want to do a plus an add. Okay? So hook that up and add that for the end. Okay, so now that's
working the way it should. So you can see wherever we aim. Or wherever we point our crosshair,
we're basically doing a line trace wherever we're pointing. And all of that is now set up, but one
thing that's been bugging me is that the gun needs to be rotated a little bit. That way it's straight with the crosshair. So I'm gonna just do that real quickly. So on the character arms, I'll do... Aim pose here, and I'm just gonna really
quickly Select that pistol socket Uncheck the rotation snapping and rotate that
over a little bit Okay, so I think that should be a little bit better there. And if you wanted to you could move
the character's arms down That way it doesn't line up with the crosshair. So there's a little bit of an offset It's
totally up to you how you position that. But yeah, we pretty much have the
line trace now So all we have to do is check and see if our line
trace actually hits anything. So you may have noticed that
when we have that red square, it basically means that we've actually
hit something with our line trace. Okay. So in our first person character off of
our line trace, we have this out hit. So we can drag off of here and do a
break hit result and hit this drop down. You can see there's a million things. Basically we can see, uh, if the hit actor
is equal to, uh, To our zombie character blueprint so the very first thing that
we actually want to do is off the return value We want to do a branch So basically
you want to see if we hit anything at all and what we want to do is For this
hit actor if you want to call an event called apply Point damage and hook this
up to the true So what this is doing and I compiled it there you can see we
have an error because I haven't hooked anything up But basically, this is a
built in event that comes in with Unreal Engine, and what this does is it allows
us to apply some damage, uh, to whatever character, in this case a hit actor. So we need to go ahead and start
plugging in some things here. So the hit from direction, let's go ahead
and plug in the camera location for that. The hit info, we can
plug this from out hit. Into the hit info, the events, instigator. If we drag off here, we want
to get instigator controller. And then the damage causer is ourself. So drag off here and do self
get a reference to self. And then the damage type class, we're
going to use this damage type, which is the default class from unreal engine. And now we have our
point of damage set up. Of course, we need to add
some sort of damage here. So we'll. Type in 20, um, so our zombie
character, we have to set up a health variable, and we'll say we have 100 HP. And basically every time we
shoot the zombie with the pistol, it will damage it by 20 HP. So now we have our point damage event. So now we can actually go into our zombie
blueprint and call the event on damage. So what this event is called is
if you right click and type in event point damage, basically,
if we receive any sort of point damage, This event will be called. So these are really handy events that
come built in with Unreal Engine. That you can use in all of the classes. And basically you apply point damage. And then in the class that
you want to receive damage. You just call this event here. And then you can get the damage
and subtract it from the health. So let's go ahead and make
our zombies health variable. So under the variables tab and
click a plus to add a new variable and we can name this health and we
want to change the variable type to a float pilot and save that. And for the default value for
the health, we can set this to a hundred, a hundred HP. And then what we can do is go ahead and
get our health variable and check and see if this is less than or equal to zero. And press hold down B and click
to add a branch and hook that up. So basically we're going to
check and see if our health is less than or equal to zero. Because if so, that means our
character is basically dead. But if not, we want to go ahead and
get our health and set the health variable to our health variable. So get our health, subtract that by
the amount of damage that we take. Okay. And then set our health to that variable. So basically we're going to get
our health and subtract it by the amount of damage, and then set
that to our new health variable. And then to see this in action, we
can do a print string and plug in the health variable to the string. And compile and save that. So let's go ahead and check
and see if this works. We hit play. You can see at the very top left here. You can see the health variable. So 60, 40, 20, 0. And then nothing happens after that. Okay, so you can see there in
the top left that it's working. We, every time we shoot the
zombie, it goes, their health goes down by 20, 40, 20, 0. And so we know that our hit is working,
as well as our vent point damage. So right now we can continue
shooting the zombie, and we want to set up some sort of death vent. So basically when the health goes down
to 0, we want to add a death vent. Maybe the zombie will go ahead
and fall down on the ground. And also whenever we actually land
a hit on the character, we want to play a hit animation montage. So first let's work on the death event. So we're going to add, add custom
event, and this will be named death, compile and save that. And then up here at the top, basically
if our health is less than or equal to zero, we want to call our death event. Then we want to go ahead
and add another variable. So click the plus icon and name this
is dead question mark and change the variable type to the type boolean. And then we want to go ahead
and set our IsDead to true. And then we want to basically
stop our character from moving. So we want to stop our zombie
character from chasing our player because it is dead. So we can go ahead and get our
CharacterMovement component. And we want to do a StopMovement. immediately. And then we want to play
a dying animation montage. So in the content drawer here,
in our zombie animations, we should have a zombie death. Maybe not that one, but I
think we have a zombie dying. So it just falls down like that. So let's go ahead and right click
that and create an animation montage. Okay, and then we're going to right
click and play montage and hook that up. The in skeletal mesh components,
we'll hook up our mesh. Montage to play, we'll get
that zombie dying montage. Compile and save that. And we should be able to test this
out now, so let's go ahead and play. So we can go ahead and shoot. 20, 0. And you see it played there but,
looks like it's still able to move. Okay, there we go, so it jumped down. And you can see there's a bug where
we can basically continue to shoot the zombie and keeps falling down
and playing that death animation. So let's do a couple things here. First thing I want to
get rid of that debug. So we want to change the draw debug
in the first person character to none. That way we can get rid
of that line that we see. And then in our zombie
character, Currently we can continue to shoot the character. And it just keeps chasing us. And it also keeps getting back up
every time it plays a death animation. So the reason why, Um, It keeps chasing
us is because we need to add some sort of check up here and the run to player. So over here, if you click alt and click
that, that will break that connection. So we want to get is dead and do a branch. So I want to check and
see if our zombie is dead. Because if so, we do not want
to move to the character. And then, the animation keeps playing. Uh, because we want to
put another check here. So we want to do the same thing. We want to getIsDead. Do a branch. And then we want to check and see
if our zombie is already dead. Because if it is dead, we
don't want to do anything. Because we don't want to keep
replaying the death uh, function here. Or the, or the death event. We don't want to keep
spamming this death montage. Okay, so if it is dead do nothing, but if
it is not dead do the rest of this logic. So now we can test this out. 60, 40, 20, 0. And, You can see that our character,
there's two bugs right now. The character springs back up
after playing the death animation. And that's because our montage,
we need to go into our montage. So in our zombie animation montage. We want to basically freeze the
character and loop it at this point. So we want to freeze the
animation right here. So we can do this by
adding a montage section. So if we right click here. We can add this new montage section. And we can name this to zombie dead. And basically we just
select this montage section. And click this little check
box in the montage section. And click zombie dead. So what that will do is it will
loop This section So you can see here We play the falling the dying
animation and then it loops Basically right here and it continuously loops
Okay So that should be fixed there and we can go ahead and test that So the zombie falls down and then
it basically just freezes like that Okay, so the other bug that we had is,
our health is 80, 60, 40, 20, and 0. And so, basically we have to shoot
it another time, even though it's health is already 0, for it to die. So we want to change that, and that
has to do with our event point damage. So what we're forgetting to do... Is after here, after we subtract
the health from the damage, we want to do another check to see if our
health is less than or equal to zero. So off of here we can do
a less than or equal to. And then do a branch. Let's hook this up like so. Because basically if our health
is less than or equal to zero, we can call our death, uh, event. And then we'll call everything down here. And then else, if our health is
not less than or equal to zero, we want to play a hit reaction. So basically when our zombie is hit. hit by one of our shots, we actually
want to play a hit reaction animation. So for example, right now we
actually don't have any sort of notification or way of telling
whether or not we hit the zombie. Like, there's no particle effects,
there's no hit reaction, and it's really bland, like we don't have any
sort of indication whether or not we are doing any damage to the zombie. So in our content drawer here, under
the animations, we have a hit reaction. So you see this zombie hit reaction, if
we go ahead and open that up, basically you can see the zombie just getting hit. And this will be a nice
animation to blend in. So whenever the player shoots the zombie,
it will just play this hit reaction. Just so that the player can
get an indication that we're actually doing some damage. And we'll also go ahead and
add in a blood particle effect. That way we can see that
we are hitting the zombie. So first things first, let's
go ahead and implement this. Uh, let's go ahead and right click. And create an animation montage and
then in our zombie here we can go on off the false so if our character
Shoots the zombie and apply some damage, but it isn't quite dead. We're gonna do that play montage
and For the in skeletal mesh will do our mesh and for the montage to
play we'll do that hit reaction So we can go ahead and test this out. We shoot the zombie. It plays that hit reaction. Now, one thing you'll notice is
that whenever we do that, it's basically the legs are floating. Okay. So the legs are sliding on the
ground and they're not walking. So it looks really unnatural. And how we could go about fixing this
is It's a little bit complicated, um, but we'd go ahead and fix this
by basically blending this animation montage, uh, this hit reaction and playing
that hit reaction from the waist up. So what I mean by that is we're going to
play that animation only on the upper body and we're going to leave the lower legs
to continue to play the walking animation. So this might be a little bit more
complicated and it might be more complex of a setup but if you're ever messing
around with animation montages and say you're doing things like Characters
holding a weapon and you want to have a swing animation, but also have your
character running at the same time You're going to commonly run into the
same issue that we're running into. But like I said, we can go
ahead and fix this issue. So I'm going to dock this in
layout and what we need to modify is our zombie and MPP. So what we're going to do is it's going
to be a little bit more complicated of a setup, but if we hold alt to on
hook, that what we're going to do is drag off of the new slate machine. And we're going to do a
save, new save cache pose. So we're going to go ahead and save
the new state machine to a cache. And this allows us to blend and do that
blending where we can blend the walking with the upper body animation montage. And this will all make sense here
in a second, so just bear with me. So we'll do that save, use
cache pose, save pose 745. So this is calling that saved cache
pose and the reason why we're doing this is so that we can ctrl C Ctrl
V and we can copy and paste this multiple times because you can't hook
this up to more than two Outputs so you have to use this save cache pose. I want to move this back a little
bit further What we want to do off of here is do a layer blend per bone. So this is a node that you'll commonly
use in the animation blueprint, where you can blend two different animations,
so upper body animation with the lower body animation, based on a bone name. So in the settings or in the details panel
here, we're going to set that bone name. So under the layer setup, index. We have this branch filters and we're
going to click this plus button. Then we have a index and then
here we have the bone name. So the bone name that we want to set
is called spine and the spine is. Right about here on the character. So basically we want to blend
from the spine up, do spine. And we're going to set
the blend depth to three. Okay. And hit compile and save. Now what we want to do
is offer this cash pose. We want to drag off here
and call a default slot. And we want to actually
go ahead and add another. So instead of using the same default
slot, we want to add our own and to do that, we go into our hit reaction montage. And over here we have on the very
right, this anim slot manager window. I believe if you don't have
this, you can go to window and open up the anim slot manager. But you see, we have the default
group and the default slot. What we want to do is add a new
slot, so click the add slot, and this slot will be named waste up. And now we should be able to use this
in our animation blueprint, so if you have that default slot node selected,
you can in the details panel hit this drop down and select the waste up slot. And now we can hook this
up to our blend pose zero. We want to go ahead and hook this
one up to our default slot like so. And then finally we want to alt
click this and we want to add another layered blend per bone. So go ahead and just ctrl c
and ctrl v that right there. And for the default slot we want to
hook this up into blend pose zero. And for the base pose we want to copy
one of these cache pose and hook this up. Now for this layered blend per bone
we want to set this bone name to hips and set the blend depth to zero
and compile save that and finally hook up the output pose like so. Okay so this might look a little bit
complicated and basically what we did is we're using two different slots. So this allows us to use montages
that play the entire root bone up. So for example, our dying animation,
and then it also allows us to use our hit reaction from the spine up. So that allows us to blend our walk
animation with our hit reaction. So the last thing that we need to
do is in our hit reaction montage, you want to change the default slot. So on the default group, default slot. Slot name, you want to change this
from default slot to waist up. So save that, close
that, and then reopen it. And now you can see it is
set to this waist up slot. So basically that montage will
only play from the spine up. And the rest of our animation,
which is this idle walk and run, will continue to play from the
spine, everything below that. But everything else, like all the other
montages, will play on this default slot and will be unaffected by this blending. So let me show you all of that in action. Okay, let's go ahead and hit play. So if we shoot our zombie... You can see that we're playing that
hit reaction and you can see we have the animation montage where it falls
down and also have that hit reaction montage playing from the waist up. So we don't have those legs
sliding anymore on the surface. Again, this might be a. More complex topic, but I made a whole
separate video kind of showcasing the use case scenario of this setup on my channel. I believe it was for Unreal Engine 4, but
the same sort of principle applies to UE5. So right now we can shoot our zombie. Um, like I said, I wanted to set up. Some hit particle effects because we don't
really have any indication that our weapon is hitting the wall or hitting the zombie. So what I want to add is some hit
particle effects for whenever we hit maybe the wall, the floor, or the zombie. And also, let's say I... Like the head of the zombie. Uh, currently we have, we're doing
basically 20 damage every time we hit the zombie, whether that be on the head
or the leg or whatnot, and that really isn't a realistic or any sort of zombie
games, you'll know that the headshot. Is sort of an insta kill. So currently we don't have any sort
of advanced damage system set up. So for example, if I were to
shoot the zombie's head, it doesn't do any more damage. Then if I were to shoot it in the leg. So we're going to set that up
along with our particle effects. So let's go ahead and set that up. So to implement the different
particle effects, like hitting a different surface as well as a
zombie, and also the different damage, we're going to use what's called. Physical materials and that allows
you to have different hit effects for if you were to shoot a wall like a
concrete wall versus like a wooden wall and All that different sort of stuff. So I'm going to go into edit here and
in our project settings We're going to search here at the top for surface
and here we can add different physical surfaces So what I want to add is
headshot And we can add body shot. And if you wanted to, you could
add like an arms or legs, and that should be good for now. And now what we can do is in our content
drawer and our zombie here, we're going to right click and add a physical material. So under the physics here, we
can add this physical material. And just select the physical
material there and click select. We can name this to head shot. And then for, if we double click to open
this up, for the physical properties we want to set this to head shot. Okay, and then we also Want to
go ahead and add another, uh, physics, physical material here. Click select and name this body shot. Go ahead and double click to
open that up and set the default surface type to body shot. And save that. Okay, so this will allow us to... Um, add that different damage type. And, so to implement that we
can, we're going to use this zombie girl physics asset. So double click and open that up. And a physics asset is
basically a group of these. Different collision capsules. Um, in fact you could hit simulate button. Which is right here, simulate. You see basically this is just a ragdoll. And we could uncheck simulate there. But basically if we select some
of these different capsules. In the top right over here we can
set a physical material override. So for our head, we could set
the headshot physical material. Okay. And before I do that, I actually
want to regenerate this head mesh. So it's like this and you want to
change this capsule to a spear. And then we want to go ahead and right
click and click regenerate bodies. And let's go ahead and move and
click our, to scale this down. So this will be basically the
collision capsule for the head. Okay. So we don't want it to be too big
because that would be a little bit too easy to land a headshot. So that's a little bit better for
the physical material override. We're going to select the
headshot physical material. And then the Spine02, let's actually
right click and click Regenerate Bodies. Okay, that's a little bit better there. And some of these we can scale down. Okay, it doesn't have to be perfect. That should be good for now. So now we can just select
everything other than the head. And for the Physical Material we
can just set this to Body Shot. And so all the rest will be a body shot. Like I said, you could add
like arms or legs and do different damages based on that. Uh, but for the simplicity of this
tutorial, I'm just going to have the head shots and then the body shot. Okay, so we have all of those
physical material overrides set. Now we should be able to use this in the
blueprint graph, uh, when we apply damage. So in our first person character
blueprint, uh, basically we're doing the line trace. Off of this hit result, we
have this physical material. So if you drag off of here,
we can get surface type. And what this returns is our enumeration. So we can do a switch. on E physical surface. And now you can see we have those
physical surfaces that we set up. So we have the default, which
we're going to use for basically all of the world objects. Then we have the headshot
and the body shot. So based on a headshot or the body
shot, we can apply different base damages based on whatever we hit. So let's go ahead and on Pin this, so
click alt to unhook that, and move this over, and hook this up for the true. Then for the headshot, we want to hook
this apply point damage up, and for the base damage we'll do something like 50. So we'll take two shots. To the head to kill the zombie then
we can go ahead and just copy and paste this again And hook this up
for the body shot and hook up the hit info and the damage actor We'll hook
up the hit actor and we'll change this back to 20 for a body shot. Just like so and Then now we
can do some particle effects. Okay, so Let's go ahead and
get ourselves actually a Blood, uh, splat particle effect. So open up the Epic Games Launcher
and head over to the Marketplace tab. And if we search for Starter
FX and filter by free. Actually if we just search for
Starter and search by free. We have this realistic
Starter VFX Pack Volume 2. Which is permanently
free on the marketplace. And this has a bunch of
good particle effects. But more importantly it has that
blood splat particle effect. So, uh, what you could do is we
could just add this to our project. So let's refer to our zombie game. Select that and add that to our project. And once that's finished downloading
we have the realistic starter VFX. Particles, and under blood
here we have this blood splat. So go ahead and open this and it's
going to have to compile shaders. So you can see we have this
nice blood splat effect. So we're going to go ahead and use
that in our BP first person character. So in the head shots we're going to
do over here and do a spawn emitter. At location. So this will spawn a particle effect. And we want to search for
that blood splat cone. Uh, for the location we want to get
the location off of our hit result. Hook that up. And then all we have to do is hook
up this other apply point damage. And compile and save that so we
should be able to test this out So it's kind of working here, so you can see whenever we
hit Any parts of the body? And I believe what our issue is is Off
this default here basically whenever we Shoot the zombie character and
say it lands somewhere around here and it doesn't hit like a capsule. Uh, basically this default physical
surface type is going to be called. So we still want to hook this up
to one of these apply point damages because it will still happen. But before I hook this up into
here, I want to do sort of a branch. So. Off the hit actor, I want to do a, uh,
does actor has, so actor has tag, and the tag type we want to type in zombie, okay? And we'll add a branch. And hook this up for the default. Okay, so we're doing this branch
because I want to basically say if the actor has a tag zombie, then we're
going to go ahead and do this apply point damage, but if not Then we're
going to play a particle effect, just a default generic particle hit effect. For example, if the player was
to shoot like the wall, we want to do like a hit effect for that. Okay? Then we also want to add this
tag to our zombie character. So in the class defaults. In the class defaults, we can search
for tag and we can click this plus button and add the zombie tag. Compile and save that. Okay, so that's set up. Now we want to do a spawn
emitter at location. And we're going to go ahead and
tidy this blueprint up because I know it's quite a mess. We'll do the spawn emitter at location. This will be like a... So I think we have this P asphalt
and then for the location, we just have to hook up the location like so. And we should be able to
go ahead and test this out. So you can see we hit the ground. We have sort of this hit effect. And you could change
out the particle effect. to a different one if you wanted to. And you could also add
different surface types. So like if you had a wood
surface type, or a glass one. But there's that. We can also shoot the zombie. And now we're doing damage. And we're also playing that
blood hit particle effect. So we can do all of that. And of course you can shoot. Zombie still. And get all those particle effects. Okay. So we have all that set up. Um, And I know that might
have been a lot to implement. But, quickly before we move on, let's
go ahead and just tidy up this code. Because it's a big mess. And, let's go ahead
and add a comment here. Go ahead and name this line trace damage. And then over here we can add a comment
for this and do switch on surface type. And you know what we'll do,
we'll just select this and right click, collapses to a macro. Bye So we can rename this to apply damage. And go ahead and double click this. And take the base damage here
and hook it up onto the input. And that will add this base damage input. Compile and save that. And now we can set this base damage to 50. Okay, we can do the same thing. We can delete this. Copy and paste that. And then we can hook this up. Put one up here. And... For our hit actor, you can double click. This will add a reroute node. And we can hook this up to all these. Do the same thing for the hit actor. Double click to add a reroute node. Okay, for this base damage,
this is our body shot. So this will be 20. Same with this one, 20. And we can also add a reroute
node for this location. Okay. And compile, save this, hook
this up to the spawn emitter. And now that should be a
little bit more cleaner. Okay, so we've set up some
zombie damage and death. Uh, there is... One more bug, and that is if you run
around the zombie character There is this collision capsule so if I open up
the console command here and Press the tilde key you can do show Collision And you can see currently that We have
this capsule collision That our player can still collide with And so we want
to disable this when our zombie dies That way our player can run through
this and it won't get caught on it. Okay, so Lastly in our zombie
blueprint Off of the death here off of this play montage. We won't you want to Drag off of
here and do set collision Response to channel and we want to do
it for this capsule component. Okay, so the channel will be the
type pawn and it will be to overlap. Then we want to also set
no collision on our mesh. So get our mesh. And set collision enabled
and set that to no collision. So that will make sure that we
won't collide with the zombie mesh that's on the ground. Okay, and then that should be all set. Uh, let's go ahead and just
comment out all this stuff. So here we're going to
add our event begin play. And comment this out. This will set run if player is near. And this will be run to player, so
this will be our chase player logic. Attack player. Attack player logic. Currently we still need to set up... Uh, the attack logic, so for
example, when our zombie does his hit animation, we still need to apply
some sort of damage to our character. Uh, we'll, and we'll get to that here
in a second, but let's go ahead and just comment the rest of this stuff out. So this will be, apply damage to zombie. And then this will be our... ZombieDeathLogic. Okay. So this is a really good thing
to comment out all your nodes, so that you know exactly what's
going on inside your blueprints. Okay. Lastly, what we want
to go ahead and set up. Uh, before we start messing around with
adding a custom map and game mode as well, is we want to give our zombie
the ability to damage our player. So if you remember, if we run up to the
zombie, it will play this hit attack. And nothing happens to our character. We don't have any health. We don't have a health bar. We can shoot the zombie. But it doesn't do anything yet. So we have to go ahead and
add a player health variable. Maybe we'll add a health bar widget. And then we'll also go ahead
and give our zombie the ability to damage our character. And decrease the health of our player. So in our BP first person
character character. Let's go ahead and first
set up the health bar. So I had a new variable in here
and we'll name this to health and the variable type will be of the
type float, compile and save that. Now health variable will be set
to a hundred or a hundred HP. And then for our health widget, if
we go in our content drawer here, I dock this and layout in the widgets. We have our main widget. So go ahead and double
click to open that up. And we're going to go ahead and add
a health bar at the bottom right. So, to add a health bar, you
search here in the palette. We're going to search for a progress bar. And we can drag and drop
this under our widget. And we can scale this around like that. And we want to anchor
this to the bottom right. And now, in the progress
percentage, you can see that we have this percentage value. That we can use to show our health. Okay, so we have 0 percent and 100%. The fill color, let's just
change this to a red, like that. And then what we want to do is, we
want to bind this percentage, uh, to our player's health variable. So we can do that by clicking
this bind button right here. And you can click this plus
button to create a binding. So what this does is
it adds a new function. Uh, this get percent zero. And it has an output which
is that percentage value. So what we're going to do is we're
going to right click and get owning. Player pawn and we can drag off
here and do a cast to first person character And again casting is how
you retrieve certain variables inside of your character blueprint So off
of here, we can get health and now we can get that health variable. That's inside of our character Now before
we hook this up into the return value, we need to convert this to percentage. So right now our health is, uh, 0 to 100. And this is a percentage
value, it's 0 to 1. So all we have to do is drag
off here and do a multiply. And multiply this by 0. 01 and hook that up into the return
value and hook up the execution pin. So now our health bar should display
at 100 percent on our screen. And now we can go ahead and set
up the actual zombie damage. So let's go to over to
our BP underscore zombie. And we're going to return here
to our attack player logic. We're going to go ahead and move
everything else down, because it's going to take up a little bit of space here. So I'll move the comment over like this. And in this montage... We want to go ahead and actually add
what's called a animation notify. So let's go ahead and browse to this. Okay. This magnifying glass, pull
up the montage, go ahead and double click to open it. And you can see here when our
zombie pulls back its hand and hits. So right about here. We want to right click in this notify
section and add a notify montage notify. So let's just say play montage notify and
actually we want to maybe pull this back a little bit further, like right about here. And basically whenever we
reach this play montage notify. In our zombie, um, play montage,
we can use this on notify begin. So whenever that notify is called,
this execution pin will be executed. So what we can do off of here is we
can do basically like a raycast to see if there's a player in front of us. So on notify begin, we want
to do a spear overlap actors. So what this is going to do is it's
going to create a debug spear in front of the zombie and check and see if
there's any players that it can damage. So let's go ahead and
hook up some values here. Go ahead and interview ports. We want to add a new component
of the type arrow, and I'm going to take this arrow and move it
in front of the zombie, like so. We have an error because we
haven't set any values here. That's fine. So now we have our arrow, we
can go ahead and get that. On the graph, we want to get world
location of that arrow and hook that up for the spear position. The spear radius, we're
going to set this to 80. And for the object types,
we want to make array. And this will basically filter what
type of objects we're looking for. In our case, we're looking for the type
of pawn and the actor class filter. We could filter this to BP
underscore first person character. Okay. And the actors to ignore, we can do
a make array and add a reference to ourself so we don't damage ourself. Okay. Now to see this overlapping spear. We want to do a debug,
show a debug of this. So off of this return value here,
we're going to do a draw debug sphere. And hook this up, the radius will
be 80, we can change the duration to 10 seconds, the line color we
can set this to like a red color. Compile and save that, and let's go
ahead and see what it looks like. So if we run up to our zombie, so
you can see how big, um, the radius of the zombie's damage effect is. You can see how much, um, reach that
the zombie has and basically if it overlaps our character, that's when
we can check and do some damage, okay? So let's go ahead and we can unhook
this draw debug spear for now. And off the return value we can do a
branch, so hook this up and do a branch. Make sure that we actually
hit something first. And out of the out actors
we can do a for each loop, and hook up the true, and then for
each loop we want to drag off the array element and do a ply damage. Okay? and hook up the loop body
to the applied damage. And so the base damage
we'll set this to 20. The event instigator we're
going to get controller. The damage causer we're going
to get a reference to ourself. And the damage type we'll
choose the default damage type. And now we should be able to
apply damage to our character. The only thing we have to set
up now is the actual event on damage inside of our character. So head over to your BP
first person character. And down here we can Go ahead and right
click and add a event, any damage. So just like the point damage,
uh, this is a built in function that comes with the engine. So we have the apply damage and
then basically the receive damage. So, the first thing that we want
to do is we want to add another variable and name this, Is dead? Question mark changes to a Boolean. And we're just going to go
ahead and check and see if the player at a branch here is dead. Okay. If not, we're going to go ahead and get
our health and do a subtract subtract that by the amount of damage that we're taking. Then we can go ahead and set
our health to that value. Okay. And hook up the false pin here. And then off the health we can go
ahead and check and see if this is less than or equal to, to a branch. So we're just checking to see if
it's less than or equal to zero. Uh, because if so, then we
want to call a death event. Okay? So we can add a custom event here. Add custom event and
name this playerDeath. And compile save that. And off the true we can go
ahead and call our playerDeath. Okay. And then in here we can go
ahead and set isDead to true. So now we should be able
to see the health decrease. Uh, because we've set up. The zombie apply damage, we've
set up the player health variable and the player event any damage. We've also set up the
user interface widget. We've binded the percentage of this health
bar to our character's health variable. So we can go ahead and test this out here. We run up close. So it will hit us, and you can
see in the bottom right, our health is decreasing by 20%. And, now we're basically
dead and nothing's happening. But as you can see, we have the health
bar set up, and the damage is now working. And this only works if the
zombie is able to hit us. So I can run away like that,
right before it attacks us. And that's pretty much the damage
function for our character. But yeah, so we have the
basic zombie blueprint set up. We can damage it and the
zombie can also damage us. And let me actually add a comment
here, event damage player. Okay, and for here we can add
Death, logic, and we're going to add some more blueprint nodes here. But for now, we're going to go ahead
and move on to creating our map. for our zombie game. So I know we just went
through a lot of different uh, blueprint logic and programming. And what I want to cover now is I want
to shift gears and work on creating a map that we can use for our zombie game mode. Okay? And then we'll go ahead and set up
things like player death, uh, reloading, ammo, and all that good stuff. So, in our content drawer here, under
the main, we're going to right click, add a new folder, name this maps, and
then we can go ahead and do file, new level, and select this basic here,
and click create, save selected, and then we can go ahead and file, save
current level as, and in our main, Maps, we can name this to bridge map. Click save. Now go ahead and open up
the Epic Games Marketplace. We're going to use some free
assets here for our map. So search for bridge. And filter by free. So we have this automotive bridge scene
and what we're going to set up is a small simple map on this bridge That our player
can run around and it will be a nice enclosed area that we can use so let's
go ahead and click add a project and search for our zombie game And click add. And it might take a
little bit to download. It is about 2 gigs in size. Okay, now let us finish adding. In our content drawer we should have
this automotive bridge scene folder. And in the blueprints here, we
have these two different bridges. And I'm just going to go ahead
and shift select these and drag these into the scene. And that will just basically
compile the shaders. And so we might need to wait
for a second for that to happen. We can shift select both
of these and move these up. I think it's compiling shaders so
it might be a little bit laggy. But yeah, basically we don't need
any of the supports down here. Because a player will never
see anything below this bridge. So what we're going to do is
we're going to modify this. And remove a bunch of stuff
on it, like all the supports, because we don't need any of that. So, let's go ahead and delete
these, and in our content drawer, open up this BP curved bridge. And then, in the viewport here, we
can just select some of these things. So I think if you select bridge lower,
and scroll down, So that selects all of it, but we only want to select everything
in the bridge lower, so go ahead and select all that, and click delete. And then we also have bridge lower,
small slabs, and we also have arch. So if you just select all of the
arches, search for arch, click delete, it will get rid of that. And then we have the rest of
these bridge lower, shift select all that and click delete. And now we just have the upper
part of the bridge, that's the only part that we need since the
player will only see this top part. Of course if you wanted to you don't
have to delete, um, all that stuff, but I just do it that way we get
a little bit better performance. So we'll do the same thing
for the straight bridge. So go ahead and scroll
down here, search for arch. And select all that and delete and slab Delete that And then all these which
under the bridge lower all these supports select that and click delete
Okay, so both of those are done we can go ahead and Drag and drop both of
these in our scene at the same time. And then we can take one of
these and just move it over. Okay. And if we hit shift on the keyboard
we can move around with the camera. So I'm just going to snap
these together like that. And then shift select these
and we'll move this up. And we can just delete this box. Okay, so this is our basic level here. Um, we can add a player start. So click the Q search for all
classes and a player start. Right there. If we hit play, I think we should be good. And now you're going to see
that we fall out of the level. And that has to do with this mesh here. So we need to fix the collision on that. Okay. So if we go and browse to this. Open this up. In the viewport we can select
this straight mesh piece. And if you click the browse. It will show where this
static mesh is located. So double click to open this up and
we want to go to collision here and go and add a box simplified collision. So go ahead and save that. So now if we hit play we should be
able to run on this and not fall. Okay, I think we have to do the
same thing for the curved, yup. So we'll do the same
thing for the curved road. So, select this, go to the vport, browse
to the curved piece here, open that up, and then we can go to collision,
add a box, simplified collision, and this part right here doesn't really
matter, so click save, and that should be good, so I think all of that is good. I think there's a little bit of collision
that we need to fix over here as well. So yeah, you can see that when we try to
move into this area, our player can't. So a little bit of collision
that we need to fix over there. But other than that, the
rest of this road works fine. So for that, if we go into here,
I believe it is this piece. Let's actually go ahead
and go into show collision. So yeah, I think it's that
piece, that corner piece, that is having that collision. So if you click browse, go ahead and
double click this to open this up. It's this straight static
mesh strafe alcove, I think. And at the very bottom here we can
go to the Collision Complexity. And we can just use Complex
Collision as Simple and save that. Okay, I think we have to
do the same for this piece. So, over here. Browse to that one. And I think this is actually the same
piece so maybe we should be good now. Hit play. Okay, yep, so it looks like we fixed
the collision on both of those. Alright, so our collisions are all set up. Now what we want to do is, we want
to go ahead and decorate this scene. So we want to add maybe some
crashed vehicles right over here. And some sandbags and things like that. And maybe a tank here in the center. Basically, we want to block it
off so that the player can't run to the end of the level. And we kind of want to enclose this area. So let's go ahead and, again,
open up your Epic Games Launcher. And if you type in the search projects
for Vigilante, you're going to find all of these, uh, military vehicles
that we can use in our project. And the main ones that I'm going to
use, uh, in this is this Radar Patriot West and then the M923 Truck West. Oh yeah, this M1 Abrams tank. So I'm going to go ahead and click
on the tank here at the project. Search for zombie. So you might not find the
unreal engine projects. You just want to click this show all
projects and search for a zombie game. And you're going to get this little red
error assets, not compatible with 5. 0. That's okay. Just click the most recent
version and click add a project. So we'll add the tank and
then we'll go back to. And give this Patriot Raider West,
go ahead and add that as well. And you don't have to add all
the same things I'm adding. Like you can go in and add
different types of vehicles. Uh, these are basically
just to decorate the scene. So I'm also adding this M923 truck West. Show all projects. So I'm the game. Add a project. It says overwrite files,
you can just click yes. I believe that should be it. Like I said, you could add more different
stuff if you want it on the road. And we're just adding it to block
off certain sections of the road. That way a player can just
play in this one enclosed area. Okay, so Believe all my stuff
is finished downloading. So in our content browser, uh,
we should be able to see that new folder that we've added. So we have this vigilante
content and the vehicles. We have the three different
vehicles that we've added. And so we have our West radar Patriot
and we have this skeletal mesh here. We can go ahead and drag and drop this. Into our scene, I'm just gonna put this
off into the distance like that Okay, then we also have West truck and drag this
out like so There's also a destroyed one. So if you go into damage we have this
damage version And I'm not sure what happened to the one that I just had They
go back here Add that back in Okay, so the shaders are compiling so it might make
your computer really slow And then I'm gonna add also the tank so West Abrams and
add in the skeletal mesh here Now as for the layout It's totally up to you What I'm
going to do is take this vehicle here and move this over, rotate this 90 degrees. So we're kind of blocking off
parts of the road like that. And then this tank will be
sort of in the center here. I'm going to select my player's chart
and move it out so it's not in the tank. And then this will be destroyed
off in the distance, like this. We're going to take this
vehicle and duplicate this. And rotate this right
over here, like that. So like I said, it's
totally up to you how you... Uh, move stuff around and
decorate the level, but I think this is a decent block out. Now what we want to also do is add
in some sandbags and other props. So we can go ahead and add
some props using Quixel Bridge. So if you're not familiar with
Quixel Bridge, to access it you just click this cube plus icon
and click the Quixel Bridge here. And you want to go ahead and make sure
you're signed in, so click this profile icon, and click the sign in button. You want to sign in with your
Epic Games account, okay? That way you can get access
to all the free assets here. Then we can go ahead and look
at 3D assets, and what we want to find are sandbags. And we have all of these sandbag items. So you can select all of these
and download all of them. I've downloaded them at medium quality. You can go all the way
up to nanite if you want. But in this case I'm just going
to stick with medium quality. I need to just go ahead
and download all of these. We can just go ahead and actually
drag and drop these into our scene. So let's go ahead and just
drag all these, like so. And we want to go ahead
and scale all these up. So let's select all these and
scale these up a little bit larger. Okay, and you can get super creative
on where you place the sandbags. Like I said, this isn't like a level
design tutorial or anything like that. So you can click Alt to drag
and duplicate these things out. And just move them around. And what I'm basically doing is
I'm leaving a little gap here for the zombies to get through. So we're going to make it so that the
zombies can get through this area. But the player won't be able
to pass, if that makes sense. Okay, so we'll go ahead and duplicate
this part, move this up, and rotate this. And we're going to fix the lighting
here in a second as well, so you don't have to worry about that. Let's go ahead and drag this over here. And rotate this like so. Okay, and maybe we'll make
some little cover over here. And we can also add like
some concrete barriers. Um, just to add some break up. But yeah, that should be good for now. We can go ahead and save that. And open up bridge. Lookup. Concrete. So if you search for concrete barrier. Uh, we have this model right here. You can just drag and drop this. Okay, and we'll go ahead and
use part of this over here. Move this right here
and just rotate around. Okay, so something like that. It doesn't have to be fancy. Okay, so we added that in. I'm just gonna add some
more sandbags over here. So you could add a lot more
stuff in the scene here. We're just going to keep things simple. So if you hit play here,
we can test out the scale. And you can see how everything looks. Now one thing you're going to notice
right off the bat is that the sandbags don't have any collision on them. So we'll need to go ahead
and fix the collision. And also the vehicles do have
collisions, so that works fine. Basically, we'll just need to fix
the collision on all the sandbags. So, really quickly, if you, uh,
browse the asset, um, in the sandbags, you just open the model up. All you have to do to fix the collision,
Is go to Collision Complexity and use Complex Collision as Simple. And we'll go ahead and
do that for all of them. So scroll down, use Complex
Collision as Simple. Okay, so all that is saved. Let's test it out. Alright, so we have all that set up. So we have our basic map set up. Let's actually fix the
lighting real quick. I want to add in a volume
post process volume. And in the details panel here, I want
to search for infinite extends unbound. Make sure you click checkbox there. I will apply it to the entire scene. And then in the search for exposure. And check this mint and max brightness
and set this to one and one. Okay. So that will fix the auto exposure. And we can also set the top, uh,
the lighting by pressing control L and you could set this to. Maybe a sunset, time of day. Okay. Well it's totally up to you. Uh, what to set the time of day to. Also another thing that we can do. Is we can change the texture
on, uh, these vehicles. So currently they have this green
color and they actually come with two different variants. The desert color and the green color. So if you right click, browse
to assets, open this up. And in the materials here
if you browse to them. Uh, the skin type you just set this to 1. And it will set it. To a different skin type. Okay, so we can do the same thing
for, uh, this one right here. Browse to asset. Open that up. Find the material. Open that one up and
change the skin type to 1. And there we go. Okay, and you can obviously change
this if you don't like that color. But, that will work for me. So we have our basic level set up, um,
we can go ahead and decorate things later and add, you know, trash and
debris and all that stuff around the map. But right now we have the basic block
out of our level, in which case we have sort of the center area and then we
have the sort of openings over here. Okay. So this opening over here is
where the zombies will spawn. So they'll spawn over here and run through
that opening and this opening And then on the other side they'll run through
this opening right here and this opening over here Okay And so what we're gonna
create is a game mode that will spawn the zombies in waves And then we'll spawn
them at these two different locations. Basically, the player will have to
survive the different waves and kill all the zombies to go to the next wave. And we can add in like maybe
three or four different waves. And obviously the difficulty will
increase, like say we'll spawn in. 3 on the first round, 10 on the
second round, maybe like 25 on the third round, and what not. And then if the player survives,
you know, a certain amount of rounds, then the player wins. So that's what we want to go ahead and do. And we can go ahead and
test out our zombie. So if you remember, we can
go to our zombie, BP zombie. And maybe drag a couple
of these things out here. Rotate it, and select Alt to
duplicate a couple of these. And we need to add that navigation mesh. So if we click the Q plus icon
on the volumes, we want to select this nav mesh bounds. And we can go ahead and scale this up. Like so, and scale all that
up, and that should be good. We're not going to pass basically this
point or this point, so we're going to add actually blocking volume so that
the player can't get past these certain points, but for now this should work. So if we hit play, zombies should
be able to navigate around these different objects and chase the player. Okay, so maybe they're
stuck on these vehicles. And I believe we just need to fix the
collision on the vehicles as well. But as you can see, they're
chasing us around the map. Yep, see they're getting stuck on
those, so we'll need to fix that. Alright, so we've made our
simple map for our game. What we want to go ahead and do now
is start working on the game mode. So what we want to implement is basically
some sort of waves based system. And the class that we're going
to use is A gamemode class. So if you're not familiar with,
uh, the various classes in Unreal Engine, you don't have to worry,
I'll go ahead and explain everything. But first of all let's go ahead
and go to our content browser. And in the blueprints here,
we're going to right click and create a new blueprint class. And we're going to choose from the
templates here this gamemode base. So you can see here a gamemode
base defines the game being played. It's rules, scoring, and
other facets of the game type. So that's really all we need to do. Uh, we just need to basically create
the rules, the scoring, and also handle the spawning of the zombies. So we're going to use this
game mode base, and then we can name this to zombie game mode. And we can go ahead and double
click to open this up, and we can go over to the event graph. So here is where we're going to
start building our game mode. And this is where we're going to store all
the things pertaining to our game mode. You know, things like handling, how,
handling how many zombies we should spawn. Uh, handling which current wave we're on. Uh, setting the difficulty. Scoring all of that logic you want to
use inside of this game mode class. It's just a really handy Class that
you can use to store all of that logic So the very first thing that we're
going to do inside of here is we're going to start working on creating our
basic zombie game game a loop So let's go ahead and first delete this event
tick and then at the very top here. We're going to add a new event So right
click, add custom event, and we're going to name this to start game, and compile,
save that, and off of our event begin play we can go ahead and call our start game. So when the Uh, when the event
begin play gets fired off, so when we open this map, we're going to go
ahead and start the game right away. And then we're going to
add another custom event. Add custom event. We're going to name this spawn zombies. Okay, so compile and save that. So when the game starts, we want to
call that function spawn zombies. I like to use. Uh, you could use, you know, functions. I feel like it's just a lot
more easier to read here having it all on your event graph. And also, you know, naming the different
events so that you know what exactly is happening when the game is starting
and what logic your events are doing. So we can go ahead and add a comment
for these and name this StartGame. And now we're going to work on our... Spawning zombies custom event here. So what we want to do is we want to Spawn
some zombies on this side of the map and on the other side over here So off of
this event, we're going to go ahead and make a couple of new variables first. Uh, so we're going to make a couple of
variables that will handle and determine how many zombies we want to spawn
based on what current wave we are on. So let's go ahead and
add a new variable here. So you click the plus
icon, add a new variable. We'll name this current wave, and
this will be of the type integer. Okay, and we want to set a default value
to 1, because when we start the game, we're going to be on the current wave, our
current wave will be wave 1, basically. And so we want to get our current wave,
and we're going to use this to figure out how many zombies we want to spawn. So we're going to do a multiply, and we're
going to multiply our current wave by 4. The number four, and this will determine
how many zombies we want to spawn. So let's go ahead and drag off here. Promote this to a variable, and we're
going to name this to zombie Total this. So this will be how many
zombies we want to spawn. So currently wave one will
spawn four zombies, wave two, we'll spawn eight, and so on. So the amount of zombies will increase. Each wave. We also wanna take the zombie total
and promote this again to a variable. And we want to rename
this to zombies left. This will come in handy later on when
we, or when our player kills the zombie. We're going to compare these two values
to see how many zombies are actually left and over here we want to do a for loop. For loop, right here with break. And basically we're
gonna do a loop to spawn. The amount of zombies that we want. So the first index will be zero. And the last index will be zombie total. And then in this loop, we just want to... Get the index. And what I want to do is I want to
basically spawn zombies at this spawn location and this spawn location. So I want to take the amount of
zombies to spawn and divide that number by two and basically. I'm going to spawn them at
the two different locations. So for example, wave one
will be four zombies. So I'll spawn two on this
side, two on that side. So we're going to take this
index and do an equals. So we're going to check and
see if this index is equal. To our zombie total
and divide that by two. So basically what we're doing is we're
splitting the amount of zombies to spawn on those two different locations. Then off of here, we're
going to do a branch. Okay. So this will be our loop
in the, for each loop. If it is equal to two, we
want to go ahead and break. So hook that up into the break and
double click to add these reroute nodes. That way you can clean this up. But if it isn't true, so if we are,
if we haven't reached half of the amount of zombies, we want to go
ahead and spawn actor from class. And the actor that we want to
spawn is our zombie character. So search for zombie,
BP underscore zombie. We want to have a spawn transform,
so go ahead and drag off of here and promote this to a variable. And we can name this spawn location 1
So this will be our first spawn location Okay, and then off of this completed here. We want to do another for each
loop with break Actually, my bad. We want to do a for loop with break and For our last index we want to Get
our zombie total, and divide that by 2, and put that in for our last index. So what we're doing is, again, we're
splitting the amount of zombies and spawning half of them at spawn
location 1, and we're going to do the same thing for spawn location 2. So, off of the loop body, we want to do... The same thing, spawn actor from class,
and the class to spawn will be our zombie, bp underscore zombie, and our
spawn transform, we'll drag off here, promote this to a variable, and we
want to name this to spawn location 2, compile and save that, and we want to
set the first index here to 1, okay? And the reason why we're doing that
is because arrays actually start at 0. And if we were to leave this at 0, it
would spawn actually a third zombie. Rather than the total divided by 2. Because an array starts at 0 instead of 1. Anyways, we should be able to test. This out the only thing we need to set
up is our actual spawn locations So in our map here We're going to spawn some
zombies over here so maybe This location or maybe this location right here will
be good So we can get the location Maybe actually I might move this up in the air
a little bit So you get the location you just right click and copy The location
right here, of the zombie, and for spawn location one, we'll go ahead and expand
the default value, and for the location, right click and paste that, okay, and
then we can go ahead and alt drag and duplicate this, and we'll go ahead and
spawn the zombies over on this side, we want to rotate this 180 degrees. And we're just going to spawn
it over here behind the truck. So go ahead and copy the location
and spawn location to the default value, paste location. And we're also going to
get this rotation here. Copy that and paste that. Okay. Now we can go ahead and delete these. We don't need these spawned in
here because our game mode will go ahead and spawn that in. So the last thing that we want to do
is we want to assign our game mode. Because if we were to hit
play, nothing will happen. So in our level here, you want
to go to the world settings tab. And if you don't have this tab, you
want to go to window, world settings. And over here we have this game mode. Game mode override. So we want to click this down arrow
and choose our zombie game mode. Go ahead and click save. Let's go ahead and test it out. Okay, so we need to set our pawn. So in our game mode we want
to hit this expanded arrow. And we want to choose
a default pawn class. Right now we don't have
our character assigned. So hit the default pawn. We want to choose our BP
underscore first person character. So now we should be able to
spawn with our character. Okay, so there we go. So now let's go ahead and check and
see if our zombies have spawned. Okay, so we have two zombies
that spawned on this side. And we should have two zombies that
also have spawned on that side. Now it looks like we're having
some sort of bug where... The zombies actually aren't
chasing our character. We have to run and come into view
of the zombie for it to chase us. So I think it has to do with
the fact that this vehicle collision isn't set up properly. So, if I were to hide behind this vehicle
here, you can see the zombie stays on that side until I go over there. So let's go ahead and fix up a couple
of collision bugs that we have. So select this vehicle, click the browse
to asset, and we're going to go ahead and double click to open this truck up. And what we're going to do instead
of using, uh, the static mesh, or the skeletal mesh, is we're going
to click this make static mesh. So we're going to leave it in the
meshes folder and name this to truck. Click save. And basically we converted
that to a static mesh. We can go to open truck. And we can click to browse to
find it in our content drawer. And we're just going to
go ahead and delete this. And replace it with that static mesh. Okay. And you can see here the
LOD settings are messed up. So like it looks like a
cyberpunk asset right there if you fly way too far from it. So we need to go ahead and
open this up and fix that. So over here in the LOD settings
we want to go ahead and change the LOD group to a large prop. It will ask us to regenerate
it, we'll just click yes. So if we save this, we can test it
out and you can see that it no longer looks super low resolution from afar. Okay. So I fixed the LOD, let's go
ahead and set up our collision. So if you scroll down to the
very bottom here under collision complexity, we're just going to use,
use complex collision as simple. And we also want to duplicate,
so we want to delete, this is a skeletal mesh, delete that. And take this static mesh
and move this over here. Okay. So we want to use static meshes
instead of skeletal meshes. Um, and I'll show you why we
want to do that here in a second. But let's go ahead and convert
the same thing for this tank. So right click, browse to asset. And what I want to do before I
convert this to a static mesh. Is if I go over to the skeleton here. I want to do a nice little pose. So I'm going to go ahead
and select the turret. And just rotate this. Like that. And then take the gun and rotate this up. Like so. And then what you want to do to keep this
pose is If you go to Retargeting Sources. Link Window. Retargeting Sources. Modify Pose. And Use Current Pose. Okay. Then we can go ahead and
click this Make Static Mesh. And save this mesh to under the
meshes, name this tank and click save. So now we can go ahead and delete this
and replace this with our mesh tank. Okay. So the main reason why we're
converting these to static meshes is if you hit P on your keyboard,
you can see the, um, Navigation. Okay. And actually we might need to
fix the collision on this one. So if we go ahead and browse to
that and open it up, we want to go over to the collision complexity. We're going to set this to use
complex collision as simple. And now we're going to see here is
we actually have this navigation. built around this tank. Okay. So this is a really important for
the zombies, because if we don't have a navigation that's been
built, we're going to have bugs where the zombies will stop moving. There'll be frozen in place. Okay. So we can look at certain areas
where they aren't able to walk. Like for example, on the sidewalk part,
we need to go ahead and fix the collision. On this sidewalk, because right now,
if our player were to run onto this location, the zombie would have to go
all the way around to reach the player. So it's kind of, uh,
not the ideal situation. And also over here we want to add a
pathway for the zombie to get through. And then maybe over here we want to tweak
this a little bit, delete that area. So that the zombie can,
um, walk past this path. Okay. So that all looks good. The only thing we need to
tweak here is the sidewalk. Let's go ahead and un hit P. If we select this BP straight
bridge, right click, browse to asset. In our content browser, go ahead
and double click to open that up. We can go ahead and find that piece,
I believe it's this gutter piece. Uh, click this little browse icon. And that will pull it up
in the content browser. Let's go ahead and double
click to open that up. And, here it is. Let's go ahead and do a collision. Add box simplified
collision, and save that. So now if we hit P, you can see that
we just fixed those collision issues. Okay, and I'm going to take these
sandbags and move them back so the zombies can walk freely in that area. And now I think we have
a really good path. Okay. So let's un hit P, and now we
can go ahead and test this out. So if we hit play here, I'm
going to stand in the center. So the zombies are gonna have
to Walk over to me slowly And you see as they get closer
they start to run and charge at us so we can run away And it looks
like the navigation is all working And pretty much everything is working
as it should okay, so that was just a really quick side tangent you just
had to fix all those bugs with the collisions but Let's go ahead and
go back to our game mode blueprint. So what we just implemented
a couple minutes ago was our spawn zombies custom event. So what we're doing is we're checking
and see our current wave which is wave one and we're multiplying that by four. So this is how we determine how
many zombies we want to spawn. And then we're doing a
for each loop break twice. That way we can spawn zombies. We can spawn half of the amount
of zombies on one side of the map. And spawn the other half on
the other side of the map. Okay, so let's go ahead
and comment this out. And just name this spawn zombies. Alright, so now what we want to do. Is we want to be able to, every
time we kill a zombie, we want to update our game mode and basically
determine how many zombies are left. Now, our player needs to eliminate
before moving on to the next wave. So, over here we're going
to add a new custom event. So right click and add custom event. And this will be called zombie killed. And basically we're going
to get the zombies left. So this will be the
amount of zombies that... We have spawned in. So we're going to get this number and
do a d increment or a minus minus. So d increment integer. What this basically does
is it just subtracts one. So we'll subtract one
from our zombies left. Okay, then we have to go ahead
and drag off here and do a equals. So I'm gonna check and see if the
amount of zombies left is equal to zero and off of this we could do a branch
So when I check and see if Our player has killed all the zombies if so,
we're gonna call another custom event. So down here add custom event We're
gonna name this wave increment Compile and save that and now off the true we
can call that wave WaveIncrementEvent, and then we can comment this out
and call this zombieKilled, and now we have our WaveIncrementEvent. So basically, we're going to have
to call this custom event inside of our zombie whenever it dies. We're going to call this event
and basically subtract one zombie from the zombie's left. And I want to check and
see if it is equal to zero. Because if it is, that means that we
can do our wave increment, which means that we can move on to the next wave. So let's go ahead and
set this next thing up. So we want to get our current wave. And we're going to create another
variable real quick MaxWaves. So compile and save that. And we want to set a
default value of max waves. So for now we're going to do 3 waves. Um, just so that we have something
super simple we can test. If you wanted to, you know, you
could add like 100 waves or whatever. Like, it's totally up to you. But we're just going to do 3. So go ahead and drag and get that. So we're going to go ahead and
check and see if our current wave is equal to our max waves. Go and do a branch, and hook this up. Because if our current wave equals
our max waves, that basically means that the player has reached the
maximum wave, and they won the game. Okay? If they haven't reached the max wave,
We're just going to CTRL C and CTRL V our current wave, we're going to
copy that and do a increment integer. What that will do is it will
add 1 to our current wave. So our current wave will
increase to wave number 2. And then all we have to do is drag
off here and do spawn zombies, okay? Right now, off of our true, let's
just go ahead and add a print string, so we can see this working. So this is if our current wave
equals our max waves, that means our player wins the game. So let's go ahead and type a message here
and say, player wins, player has won game. Let's go ahead and copy
and paste this over here. Name this to next wave starting soon. Okay. So just some print strings
to see what's going on. And before we test this out, we need
to call this zombie killed event. Because right now if we kill a zombie,
this is not going to get called. And we want it to get called. So that we can track how many
zombies are left in our game. So, in our content drawer here,
in our underscore main, zombie, BP underscore zombie, if we scroll down
to the zombie death logic, off of this set collision enabled, we want to go
ahead and expand this here, and we want to right click and get game mode,
so we're going to get our game mode. Which is our zombie game mode. So go ahead and cast to zombie game mode. And hook this up. And then what we want to
do is call that event. So, zombie killed. So we're calling that event
inside of our game mode. And then, what we can do
after this, is do a delay. So we want to do a delay of say 10
seconds and then basically delete the zombie or remove it from the game. So go ahead and do a destroy actor. So basically after 10 seconds of
this zombie laying on the ground it will just delete itself. So now we should be
able to test things out. If we hit play, we can run around here. Let's go ahead and wait for the
zombies to start chasing us. And we can go ahead and
shoot and kill the zombies. Okay, so we have two more. And now you see next wave is starting
soon up the top left and now we have four zombies spawning on the
right side We should have four zombies Spawning on the left side. So now we have to kill all four of these
you see the zombies frozen So that's actually a bug that we need to fix. Let's go ahead and just kill it real
quick You see next wave is starting soon. So we're on the third wave now, and we
should have C 1 Five zombies on this side, and we have a bunch of zombies
on this other side, and I wonder if there's some more left If that was
it So that could have been it there. I might have missed the message Let
me go ahead and stop this and check my Console, so if you click this output log
you can see your print strings So let's go ahead and So it doesn't look like... So I think what would happen was
we spawn 5 zombies on each side. And what I think is happening
is when we spawn our zombie, Um, they're spawning into each other. And basically we're losing one of them. On like the third wave. So go into the BP underscore zombie. I must have missed this setting, but. If you click on the class defaults. You scroll down to the very bottom. We have this actor spawn
collision handling method. So you can see the current setting
right now is try to adjust location. Don't spawn if basically like if
you can't find a spawn location. Okay, so what's happening
is we're trying to spawn. Six zombies on one location. And so one of the zombies is not
getting spawned because of this setting. Instead of this setting, when it do. Always spawn ignore collisions. Okay, so we're going to always spawn and
just ignore the collision of the other zombies that get spawned right next to it. So compile and save that and we
shouldn't have that issue anymore. Let's go ahead and play real quick and
just get rid of the zombies in this wave. Okay, so wave number two,
we have four zombies. Let's go ahead and eliminate them. So now we should have six zombies. You can see they're kind of glitching
out here, but that should be fine. We should have six zombies. It looks like we have all them over here. So let's go ahead and just
eliminate all these real quick. Okay, and I believe
that was pretty much it. So I think our win message
just played there at the top. We can check the output log. Player has won game. So basically that little print string
that we put in here, um, If our current wave equals the max wave,
so basically if we eliminated all the zombies, we call this event. If our current wave equals our max
wave, that means we've won the game. If not, we will continue. We will add 1 to the current wave,
so we'll change this to wave 2. We'll go ahead and loop back
over here to spawn more zombies. So this is our basic game loop. Okay. So this is how you'd set up some
sort of game mode where you have some sort of loop, uh, where, you know,
you have zombies that are spawning, you have different waves that will
continue for as long as you set it. Now, what we want to add. Some actual visual representation of
this because right now this print string isn't really the best Way of showing
the player which current wave that they are on and also showing the player how
many zombies that we have left That we need to kill to get to the next wave. So let's go ahead and work on Setting
up the user interface for that So in our content browser, under the
underscore main, in our widgets, we're going to go into our main widget. And up here at the top, we want to add
like a wave 1 of 1, or 1 of 5, whatever. And then underneath it we want
to add sort of like a text that shows how many zombies are left. Let's go ahead and search here in
our palette for a vertical box. And drag and drop this up here. And let's go ahead and
anchor this to the top. We're going to reset the
position X, position Y. Set the alignment to 0. 5. And for the position Y, let's go ahead
and just move this down a little bit. 28 should be good. 30. And then in here, what we want
to add is a horizontal box. Okay. And in that horizontal
box, we can add a text. And for the text, just hit this fill. And... Snare that in the middle. And the text, we can rename
the text here to Wave 1 of 1. Okay, and for the font here, we can
maybe increase this to 26, maybe like 30. Okay, and then we can go ahead and
add a border in our vertical box. So this will add like a
white line, basically. So horizontal box, we have the border. And then we want another horizontal box. On our vertical box, so right here. And in there we can add a border. So add a border inside
of that horizontal box. And select that border and click fill. And for the brush color we want
to change this to like a black color and set the alpha here to 0. 5. Okay. And then finally add a
text onto that border. Okay. So something like this. And for the text we want to
center that in the middle here. And we can rename the
text to Zombies Left 18. Okay, something like that. Alright, so this is just going
to show us what wave we're on. And this will show us how many zombies
we have left that we need to eliminate before moving on to our next wave. Okay, and one more thing
that we want to add. Is we want to add a horizontal box. We can drag this onto our canvas panel. So this will just be out
on our canvas panel here. And let's scale this up. Like so. And we can anchor this to the center. And in here we can add a text. And fill the text. And center it into the middle. And we can rename the text here to,
Wave 1 starting exclamation mark. And let's scale this up to, like, 56. Okay. So this will basically hide and show this. Whenever the wave starts. And then we'll modify
this, uh, number here. To show which wave is starting. Okay. So select this text here. We're going to rename this text block. To wave text. And make sure that is a variable. Uh, because we're going
to change the number here. Every time a wave starts. Then select the horizontal box. And we want to rename this to wavebox. And also make that a variable because we
want to toggle the visibility of this. And that should be all good to go. We want to select our wavebox here. So the horizontal box. And we want to go to visibility
over here in the details. And make this hidden by default. Okay. That way it's not on our screen and
you can play test this and see what it looks like So you see we have the wave
at the top there And the zombies left. So let's go ahead and work on binding
That text to the amount of zombies that we have left and also to our current wave
So select the wave one of one text What we want to do is under the text here, we
have this ability to create a binding. And we've done a binding here for this
percentage bar, for the health bar. If you remember correctly. And we want to do the exact
same thing with this text. So go ahead and click this create binding. Okay. So what this does is it creates
again a function right here. Uh, to set. The text of this wave one of
one so you can see the return value is of the type text, okay? so all that we want to do inside of
here is get game mode and Cast to zombie game mode So we want to cast through
our game mode so that we can retrieve the current wave and the maximum wave
So, over here we can get, go ahead and drag off here and do getCurrentWave,
and drag off here and getMaxWaves, okay? And now hook up the execution pin,
and for the return value you want to drag off of here and do a format text. So, for this format text, we're going
to put our cursor in here, and type in, wave, space, and do these curly braces,
so these are the curly braces, the curly brackets, we want to type in here,
current, wave, and space, do another curly braces, and in there do, total, waves,
and And actually in between those you want to delete that space and add a slash. Okay, and click enter. And what that format text does
is it allows us to specify basically these values. Which we can then plug in these
integers into those values. And what that does is it will
say wave space current wave, one. Out of Max Waves, which is Wave 3. And it will set the text to that. So, we can go ahead and test that out. It should say 1 of 3. And you can see 1 of 3. Next, let's go ahead and
set up our Zombies Left. So we want to do the same
thing and go over to the text. And create a binding. And we're going to do the same
thing where we get Game Mode. cast to zombie game mode and then
we're going to get zombies left so we have that variable inside of our game
mode that tells us how many zombies are left And so, off of the return
value, we want to do a format text, and for this, we'll type in zombies left
colon space, do our curly brackets, and in here we'll do zombie variable. Okay? Hook this up, and for zombies left we
can hook that into our zombie variable. And now this will update the zombies
left text to however many zombies left we have inside of our game mode. So hit play. You can see on the very first
wave we have four zombies left. And you can see this update in real
time, so if I were to eliminate one of the zombies, you see we have three
zombies left, two zombies left, so we have these two over here, we have one
left, and now we have eight, because we moved on to wave number two. So you can see wave number two out of
three, and now we have eight zombies. That have spawned. So now we know our user interface
widgets are working properly. The last thing that we want to
set up is this wave starting. And for that, we want to actually
go back into our game mode. So over here we want to add a new event. We're going to put it up here. So move this start game. Right over here we want
to add custom event. And we're going to name this wave start. And what we'll do is get player character. And we can go ahead and cast
to first person character. Okay, so we're getting a
reference to our character. And now what we want to do is
we want to access this widget and basically show this widget. Because right now it's visibility
is set to hidden by default. And one way we could do that is
by adding a event inside of our character that calls an event inside
of our widget to show this widget. So let's go ahead and open up
our first person character. So blueprints BP first person character. And in our widget over here we want
to, off of our creation we want to get this return value and drag off
here and promote this to a variable. We'll name this main widget ref. And hook this up like so. And basically now we can
add a custom event here. So right click, add custom event. And we're going to name this show wave UI. And we can get our main widget reference. And we want to add a event
inside our main menu widget. So go over to the graph. And to the event graph. And we're going to add
a custom event here. So, down here we can right
click, add custom event. We want to show wave start. Okay. So let's go back here. So our show wave UI, we want to get
that show wave start event that we made. And then in our game mode, we
can then call that show wave UI. So I know this is kind of
like going back and forth. Basically, we're getting our
character and we're calling this event inside of our character. Which then calls the show wave
start inside of our widget. Which we can then use to toggle the
visibility of this wave 1 starting. So in our graph here, we
can get that wave box. So get it, and do a set
visibility to visible. Now, in our game mode
here, we do our wave start. Show Wave UI, and what we want to
do is do a delay of say about 5 seconds, and then call this Spawn
Zombies Event, so Spawn Zombies. And we can add a comment here and
just name this, Start Next Wave. Okay, and now we can call this Wave Start
Event down here off of this Spawn Zombies. We can go ahead and delete
this and call that Wave Start. Okay, so basically what we're doing
is we're starting the next wave, uh, when we are moving on to the next wave
and we're showing that user interface and we're also spawning the zombies. So we're doing the same sort of game loop,
but we've incorporated this new event. Okay, let's add a comment over this. Just name this update wave. Okay. So we should be able to see
this pop up on our screen now. So I think we need to... So you see wave one starting. So technically it should be wave two. And also we didn't see that
when we started the game. So we need to go ahead
and fix those two things. So the first thing will be the text. So if you go in the main
widget, Underscore W. We want to set our text. So we have this wave text variable. If we go ahead and drag this onto
a graph we can go ahead and get it. And then we want to do a set text. And we want to do this set
text, the very bottom option. And hook this up. And then what we can
do is do a format text. So off of the text here we
want to do a format text. And in the format, we want to do wave,
and do our curly braces, current wave, space, starting, exclamation mark. And for our current wave, we want to click
on this custom event, and down here in the inputs, we want to click this plus
button, and add a new input of the type. of an integer, but we're going
to name this CurrentWave. Change the variable type to Integer. Then we can hook this up to the
current wave in the format text. So now we should see the text update. And we want to go into
our FirstPersonCharacter. Take this CurrentWave and
drag it on the ShowWave UI. And now we'll add that input. And then our game mode, we can
scroll up here, and we'll have that current wave variable. And all we have to do is plug
in our current wave variable into that current wave input. Okay. So that will show us the... Wave text. So right now it won't show
us on the first round. Which should be fine. Let's go ahead and
eliminate these zombies. So you can see wave 2 starting. And right now it won't actually disappear. So we need to make this
text basically disappear. After the wave, the next wave starts. Okay. In our main widget here, we're
going to add an animation. Uh, so go into designer, and with
this text selected, we're going to add an animation that basically
makes this fade in and fade out. So, if you're not familiar with
widgets and animation and things like that, there's actually quite a bit of
stuff that you can do with widgets. I can make the text bounce and
slide in and transition out and all that sort of stuff. And under here, under the animations, uh,
we can click this animation button, plus button, and we can add a new animation. We're going to name this wave animation. And so with that selected,
you can click this plus. And we'll add a track. So in our case we want to add
a track for our wave text. And for our wave text, we basically
want to modify the opacity. So we want to modify
the opacity of the text. So let's go ahead and
click this plus track. And you're going to see here we have
all the variables that we can change. In our case we want to
change the render opacity. So, currently we have
the opacity set to 1. Let's set this to 0. So you can see 0, there's no text. And if we drag this to about 1 second,
we can set the render opacity to 1. And basically what we just did is
we add, we added sort of this fade. So you can see it fades from 0 to 1. And then what we want to do is... Put this at about 2
minutes and 50 seconds. And add another keyframe, so you
can click this little circle icon here and it adds another keyframe. You can also select keyframes
and CTRL Z, CTRL V to copy them. And then what we want to do
is move this to 3 minutes, 3. 5 seconds. And set the render opacity to 0. So what this does is it shows wave
starting and then it fades out. Okay, so that's all this animation is. It's a really simple wave
starting, fade in, and fade out. Okay, so now in our graph we
can just use that animation. So off of this set visibility we
want to just do play animation. So this will play that
user widget animation. And the in animation, if you
look over here on the animations, you just click this down arrow. We have this wave animation. So drag and drop that into
the graph and just hook it up. And number of loops to play, one. I believe that should all be set properly. Go pilot and save and let's
go ahead and test this out. Let's go ahead and get to wave two
so we can see that happen Okay, so we're two zombies left So this is
wave two starting fades in and it fades out and then we can go ahead
and test our Next or a third wave. Let's go ahead and just eliminate
these zombies real quick so wave three starting And now all of that is working. So we have our wave Text,
zombies left, and then we also have our wave starting text. So this gives the player a good indication
as to what exactly they should be doing. As well as what, um, the game
mode class is basically doing. Now what we want to add next, is we want
to add a way that the player can win. Because right now they can. Get to wave three and after that nothing
happens because currently our max wave is three or when we reach the maximum
wave We want our player to be able to win the game And we also want to be
able to have our player also lose the game by dying because right now Our
zombies can attack our player and when our health hits zero nothing happens
So basically we want to set up The win logic and the player death logic. So let's first start out with
the win logic since it will be inside of our zombie game mode. And all we have to do for that is right
click and add another custom event. And we want to name this to player wins. Okay. Compile and save that. And now we can call this event. So right here, so player has won the game. Go ahead and delete that. And basically we can call
our player wins event. Okay. So if our current wave equals our
maximum wave, then our player has one. And then here, what we want to do is just. Get player character and cast
to player, character, cast to bp, first person character. And we wanna do the same
thing that we did with this. Start, Show Wave UI. We basically just want to show
some text on the player's screen. To show that they've won the game. So we'll make it really simple. Uh, so we want to create another
event inside our character. So, Add Custom Event. And we just want to do Show Win UI. And, then Compile Save that. And in our widget we want to do... Go in the graph, and right click and add
custom event, show win text, and then in our character we can then get, copy
and paste our main widget ref, and call that show win text, hook that up, and
now we can go back to our game mode. And off of that first person
character do that show win UI. Okay. So that's all we're doing. We can go ahead and comment this out. Basically say win logic. Okay. So when our player wins the
game, we're going to call this event inside the player. Which then calls this
event inside the widget. To show some text on the screen
that says you've won the game. So let's go ahead and
add that win, uh, text. And what I'm going to do instead of
just adding a text is in the palette here I'm going to add a vertical box. And drag that onto the canvas panel. And we're going to anchor
this to the full screen. And you want to reset the
offset right and bottom. And actually reset this to 0 and 0. That way the vertical box is
the full length of the screen. Then we want to add, or
search for a background blur. And drag and drop that
onto our vertical box. Select the background
blur and set that to fill. And under the blur strength
here, we can set this to 60. And basically that just blurs the
background and now we can add some text that says you've won the game. And then maybe we can add some
buttons that will allow us to replay or exit the game or what not. So in here we can add another vertical
box on top of our background blur. And then we can add a horizontal
box inside of that vertical box. Actually, you want to select the
vertical box and set this to center. Okay, and then our horizontal box,
which is inside that vertical box. We can add a text onto that. Okay, and the text will be named, you win! Or, you won! We can set this to, like, 80. And you can set the color. To maybe blue and then
select the vertical box here. We're going to add Another horizontal
box and in that box, we'll add a button And set the button to fill and on
the button we'll add some text And we can name this exit to main menu
And copy and paste the horizontal box onto the vertical box again. And select the text on that one
and just name this to Quit Game. And then select this horizontal
box, add a padding of like 10. And select the second horizontal
box, add a padding of 10. Okay, so compile and save that. And now we have a U1 and we also
have two buttons here exit to main menu and quit the game. Okay So we want to get this vertical box
Uh, the very top vertical box, we want to select this and rename this to WinWindow. Compile and save that. And up here in the top right, we want
to make sure we set this to a variable. And we also want to set the
visibility here to hidden. So, by default we want this to be hidden,
that way our player doesn't see it. And also, over here you can toggle the
visibility, that way you don't have to see it in the widget editor here. So now that we've made that, uh,
we can go back to the graph and in the show win text, we can go ahead
and get to that win window, and just set visibility to visible. And maybe we'll add also
an animation, that way... Uh, the win window will fade in
rather than just pop in like this. Okay. So if you click the animations over
here, we can add a plus animation and name this to win window animation. With that selected, we can add a track and
we're going to add it for our win window. And then here we can select that and
add a track for our render opacity. And we're going to set the
render opacity to 0, at frame 0. And then move this to frame 1,
or at the 1 second mark, and set the render opacity to 1. Okay, so all this does is it fades in. Okay? So, you've won. So now in the graph, off of
this set visibility, we can just do that play animation. And in the in animation we just drag this
win window animation and plug that in. So now we can go ahead and
test out our win logic. So if we hit play here. So one zombie left, let's
go ahead and eliminate. And you can see we won. Okay, so technically we can still
run around and do all that stuff, so what we might want to do is, and
also we haven't set up the buttons as well, so we need to go ahead and
maybe do like, stop the character from moving, and then also program in
those buttons so that we can exit to the main menu and also quit the game. So, in our main menu, or our main... In our main widget, in the designer
here, uh, we can click on these buttons here, and let's go ahead and
rename these buttons, so with the button selected we can rename this
to exit to main menu button, and we can rename this other button to
quit game, and in our graph we can. Select the exit to main menu
button and add a on clicked. And also select our quick
game and add a on clicked. So, when we exit to our main menu
we want to do a open level by name. And the level that we want to
open is called our main menu, even though we haven't created it yet. Uh, but we'll go ahead
and create this later on. So, we'll open up the main menu. And then when we click quit game,
all you have to do is do quit game. Okay, so we'll just quit
the game for that player. So those buttons should work. Now for our character, when we do
that show win UI, let's just get our character movement component. So drag and drop that on the graph
and just do stop movement immediately. And, and that should freeze
the character from moving. And that should be all good to go. Alright, so we've managed to set
up a big chunk of our game mode. Um, basically the main loop of our game. Uh, the different waves. As well as the actual, uh, user
interface that will show on our screen. When we've won the game. But, currently. There is no way for our
player to lose the game. So for example, when our character
runs up to the zombies, they can damage us, but they can't kill us. So you see our health goes down
to zero, and nothing happens. So what we want to do here is just... Add some user interface, so some UI
that shows that our player is dead. And then maybe we'll put some buttons on
it that say, uh, exit to main menu, or retry, or respawn, something like that. And we also want to add, um,
some sort of, like, hit effect. So for example, when our character gets
to lower than half health, we want to have, like, some blood overlay on our
screen to signify that our character is at low health and they need to go
and run away to regenerate health. So we'll go ahead and start
by adding our player death. So in our first person character,
um, we want to go ahead and define our death logic. Okay. So down here, this is where we
were setting up our player death. Currently nothing really happens here. But what we want to set up is we just
want to show some UI, some user interface that shows that our player is dead. Basically the same thing that we did
with the, uh, win UI, but in this case we want to show that user interface. So, in our widget here,
let's go ahead and... Create another window. In our case we can just
duplicate this win window. So right click and duplicate that. And hide the original one. So we have this win window one. We can select that and
rename it to death window. And then select the text here. We can change this to you died. And we can change the color to like a red. reddish color. And for the buttons here
we want to rename this. So we want to rename
the text here to retry. And we want to rename the
button to retry button. Okay this next text here we want
to changes to exit to Main Menu. And select the button, we can
name this, Exit to Main Menu. Okay. Compile, save that. We want to duplicate this horizontal box. Copy. And... Paste that onto this vertical box. And select the text here, we
want to name this to, Quit Game. Okay? And then select the button, and we
want to name this to, Quit Game Button. Compile and save that. So now in our graph, let's go ahead
and program those buttons real quick. So we have the Quit Game
button, add a On Clicked. And we can move this next to our other
Quit Game button, and hook that up. Then we have our exit to main
menu button, or exit to main menu, click the on clicked, and hook that
up to the open level main menu. And we have the retry button,
just add a on clicked for that. And for that we're just
going to reopen this level. So do a. Open level by name and the level
to open is this bridge map. So it needs to be typed in bridge
map with the proper capitalization Because it is case sensitive. Okay, so we have our button set up We want
to select our death window here And make sure the visibility is set to hidden then
we can just toggle the visibility like that Okay, so that should all be set up. In our graph we want to add
another custom event to show that UI, or to show that death window. So right click, add custom event,
and name this to showDeathWindow and then we just get the death window
here and set visibility to visible. And in our first person character
we can go ahead and call that off this player death event. So get our main menu widget
ref and call that death, show death window custom event. Okay, so let's go ahead and hook that up. Um, what we want to do is
get our character movement component and disable movement. So that way our character can't
run around when they have died. And then we also want to get
player controller at index 0 and set show mouse cursor. Click the checkbox. So we want them to see their mouse cursor
and then we also want to set input mode. UI only. So this will allow us to use our mouse
cursor and instead of controlling our character, we can click the
buttons on our user interface. And we might want to do the same thing
up here, uh, when we do our show win UI. So what I'm gonna do is select all
this and copy And paste it up here. And delete this stop movement immediately. And just hook all of this up here. Okay. Let's go ahead and add comment over this. And just name this, Show Widgets. So compile and save that. And we should be able
to test this out now. So if we go near one of the
zombies, we can let it kill us. And we should see the death window pop up. Okay, so you see we died. We can't move our
character around anymore. And now we have our mouse cursor. So we can click retry,
which will reopen the level. Exit to main menu doesn't do anything
because we haven't made the menu yet. And we can quit game, which
will quit out of there. Okay. So, we've set up the death window, what I
also want to set up is that blood overlay. So basically, we're going to overlay an
image on our screen to signify that we are taking damage and we're losing health. So in our widgets folder, we have
this overlay texture that comes with the project files And if you don't
have this, uh, you can download the project files and in the UMG,
we have this overlay image here. So just drag and drop it into the project. And also, we also want to set up... some sort of health regeneration system
Because right now we can take a bunch of damage to our health and we can't
regenerate any sort of health So a player if they, you know get damaged
down to half health they basically have to run around and There's no
way for them to regenerate health. So we want to add the ability to Slowly
heal over time that way our player has to you know, run around And wait for the
health bar to regenerate, uh, before going and, uh, eliminating all the zombies. So we'll work on both of
those two things up next. So here in our event damage
player, I'm gonna put some more, uh, logic inside of here. So let's go ahead and move
this death logic comment down. And we can expand this over like so. And we're going to do
a lot of work in here. But basically... Uh, we're going to check and
see if our health is less than or equal to a certain value. And then if it's half health, we
can start playing that blood effect. If it's say less than, less than
a hundred percent health, we can start doing our slow regeneration. Okay. So off of this false here, we do
another branch and we want to. Get our health and check and see if it's
less than or equal to a certain value. Okay. And the value that we
want to type in is 90. So our health is less than or equal to 90. We want to hook this up and we
want to start regenerating health. Okay. So we're not waiting till like we
get 10 percent health before we. Before we regenerate, we want to
just start regenerating instantly. So we want to add another event here. Over here we can right
click, add custom event. And we want to name
this, health regen timer. So we're going to use what's called
a timer, to every 5 seconds or so regenerate a certain amount of health. So off of this true we
can call that, health. Regen timer and let's move
this over a little bit and then down here off of the false. We want to do another branch and
we want to check and see if our health, so copy and paste this. So we want to check and see if our
health is less than or equal to 50. So if we are at half health and if so
we want to do another custom event. Which will be in our user interface. Uh, to show that blood overlay. So let's go ahead and just make those
events real quick in our main menu widget. So down here, let's go
ahead and add custom event. And this will be called ShowBloodOverlay. And then right click and
add another custom event. And this will be called
Stop, hide, blood, effect. Compile and save that. And now if we go back to
our first person character. We can get a reference to our widget. And call that showBloodOverlay. So hook that up to the true. So if we are at half health. Show that blood overlay, um, but if
we aren't at half health, if like we are greater than half health, we can
go ahead and get our MainMenuWidgetRef and do a HideBloodEffect. Okay. So now let's go ahead and actually, uh,
implement or finish these custom events. So for our health regen timer, we
want to Do a set timer by event. So this node allows us to loop an
event every however many seconds. that we want. So in our case we want
to do every 5 seconds. We want to click looping. Then off of this event we want
to drag and add custom event. So we're binding this timer to an event. We're going to name this regenerate, regenerate health. Okay. So every 5 seconds we're
going to loop this event. And what we're going to do is
we're going to get our health. And we're going to check and
see if it's equal to 100%. Okay, and then do a branch. So we're going to check and see
if we are healed up to 100%. And if we are, Heal up then we're
going to stop the timer, but if not, we want to go ahead and add some
health To our player to heal it up. Okay? so let's go ahead and Get our
players health and add this let's do a add We're going to add 5 HP, and then we're going to go ahead and
clamp the value, so do a clamp float, and the maximum we will clamp it to is 100. So we don't want our player
to regenerate more than 100. HP, uh, because if they do, then
obviously, you know, they could have like 200 HP, a thousand HP. And, uh, if there's, you know,
some sort of bug and basically they could become invincible. So we're going to clamp that value
by a hundred, but just to make sure that that doesn't happen, we want
to take our health here and get it and set it and up for the false. We want to hook up the
clamp to set our health. Okay, so we're regenerating 5 HP,
uh, about every 5 seconds, okay? And then, off of our health, we want
to do a greater than or equal to. So we want to check and see if our
health is greater than or equal to 50. And do a branch. Uh, because if so, we want to, um,
hide, do this hide blood effect. Okay, so get our main menu widget
reference and do hide blood effect Because if our health is lower than 50 percent
we are we have this blood effect that will set up and if it is Regenerated
past 50 percent we want to hide that. Okay. The last thing that we want to
do is If our health is finished regenerating, we want to stop this timer. That way it will stop looping. So all we have to do to stop this
timer, is take this return value, promote this to a variable, and name
this TimerRef, for Timer Reference. And then you just want to get this
Timer Reference, and drag up from here, and do a clear, and invalid,
Invalidate timer by handle. So if you hook this up to the true,
this will basically, this will basically just stop this timer and delete it. So that is our health regeneration logic. Go ahead and select all
this and add a comment. Just name this health regeneration. And now the last thing that we want
to set up is this blood overlay. The show and hide blood overlay, so
that's in our main widget, uh, graph. So for our show blood overlay,
we want to get, we actually want to set up the widget. So go to your, uh, designer here. And on the canvas panel, we want
to add an image, so drag and drop this image onto the canvas panel. And, anchor this to full screen. And also reset the offset to 0 and 0. So that it is full screen. And for the brush, for the image
here, we want to set this to R. I think the image name, if we go to
content browser, it's named overlay. So search for overlay and you can see
here we have sort of like this, uh, blood effect on the corners of our screen. So we're going to, uh,
rename this image here. To blood overlay and make
sure it is a variable. Uh, then for the visibility, uh,
right here we want to make sure this is set to hidden by default. Okay, because we don't want that to be
shown when we start playing the game. So now in our graph we can get our blood
overlay and set visibility to visible. And then when we hide it we want to... Set visibility to hidden. Now the last thing that we want to do,
is we want to add a simple animation. Because right now all that's
going to do is do this. So every time that is shown, it's
just going to look like this. What we want to add is an animation
that will fade this in and out smoothly. Much like what we did
for our other widgets. So in the animations here. Click a plus to add a new animation,
and we're going to name this blood animation, and select that, add a track,
add it for our blood overlay, and select that and add the plus on the track. We're going to choose
a render opacity, okay? So, the very first render opacity,
uh, let me actually make this visible so we can see what we're doing. So, very first render
opacity will be set to zero. And then move this over to about 1
second and set the render opacity to 1. And then move this to 2 and
set the render opacity to 0. Okay, so basically this will
just do a quick fade in and out. And then what we'll do is we'll
just play that animation looping. So in our graph here, we'll
go ahead and play animation. And the animation to play
will be our blood animation. So get that. Plug that in. And for our number of loops to
play, if you hover over this pin, it actually says, the number of times
to loop this animation, and then in parentheses, 0 to loop indefinitely. So if we set this to 0, it will
basically loop indefinitely. Okay? And then... If you want to stop that animation,
just copy this, paste this down here, and do stop animation. And then hook that up. Okay. So now we should be able to test this out. So if our player's health is... Less than 90%, we're going to start
regenerating 5 HP every 5 seconds. And if our health drops down below
50%, so half our health, we're going to show that blood overlay widget, which
will play that nice smooth animation. Okay, so let's go ahead and test this out. Let's get our health below 50%. So now, we should have that overlay. And I think we're not seeing that here, so
let's go ahead and see what we did wrong. Oh, I believe the thing that we did
wrong is, off of this health regen timer, we want to drag this execution
pin and hook it up to this branch. So that's exactly what we did wrong here. So, because... If our health is greater than,
or if it is less than or equal to 90, so if it is less than 90%, it
will do this health regen timer. Then we also want to go ahead and do this
other check to see if it is less than 50. Okay, so let's go ahead and test
that out, that should work now. So if we get our health below
50%, so you can see we have that. Overlay the blood overlay It's fading in
and out because of that opacity and we're slowly healing our health back up to 5 HP
every 5 seconds So now that overlay went away because we are More than half of our
health has been regenerated We can bring that back down So you can see we have
that overlay again That shows our players wounded And yeah, that's pretty much the
overlay, as well as the regeneration. And of course you could tweak the settings
if you wanted to regen more than 5 HP. Or if you wanted to do it like every,
uh, 1 second or 2 seconds or whatever. Uh, you can go ahead and
tweak that in the settings. So we are almost done with this course. Uh, the only thing that is left
to do, is we want to go ahead and set up a reloading system. Cause right now we have
basically infinite ammo. Our player can never run out of
ammo, and they can't actually reload. So we want to, uh, give our
player a limited amount of ammo that they start off with. Also, we want to add a ammo pickup crate. That will replenish our ammo
at the start of every round. Okay? So let's go ahead and
start working on that. So the first thing that we want
to do is we want to go ahead and add in two new variables. So in our... BP first person character. I'm going to add a plus button here. Add a new variable. We're going to name this current Ammo,
and we'll change this to the type integer. And we'll add another variable. We'll name this total Ammo, and it
will also be of the type integer. And let's also give these, uh,
variables some default values. So our current ammo, let's say we
have nine Bullets and we'll actually have to make a third variable. And this will just be
named our max clip size. Okay, so this is basically how many
bullets can we hold in a clip? So in our case, we just
wanna set this to nine. So let's say like nine bullets in a clip. So our current ammo is currently
set to nine and our total ammo this will be like the Total ammo
that we have overall be set to ten. Okay, so we're just adding some
default values in here and now Let's go to our shoot logic. What we want to do here is before we do
anything We want to check and see if we actually have ammo to shoot our weapon. Because right now we can spam the
left mouse button and basically infinitely shoot our weapon without even
checking to see if we have any ammo. So we want to get our current
ammo and check and see if this is greater than zero. Because if it is greater than zero
that means we can fire our weapon. We do a branch and then we want to do a branch. So let's go ahead and copy this branch
over and hook this up for the true. The next thing that we want to
check to see is if we are reloading. So let's add another variable and name
this is reloading question mark and we want to change this to a boolean. So go ahead and drag and drop that
boolean and plug it up into that branch. So basically we're going to check
and see if we have at least more than zero bullets and then we want
to check and see if we are currently reloading because if we are reloading
we don't want to fire our weapon. And if we aren't reloading, we
want to get our current ammo, minus minus, or de increment. So hook that up into the false. And then basically continue on. The shoot weapon logic. So basically if we have more than
at least one bullet, we want to check and see, are we reloading? Nope, we aren't reloading. So then subtract our current ammo by
one and then do that firing montage, line trace, and all that stuff. Okay. So now that should all be set up. Now what we want to set
up is simple widget. In the bottom right of our screen. To show how much ammo that we have left. So we want to show our current
ammo and our total ammo. Okay, so head over to your main widget
underscore W and we're going to go ahead and add one more widget and this will
be the last widget that we'll be doing. So go ahead and search in your
palette for a horizontal box and drag that onto the canvas panel. And this we can select. And move this over here. And kind of just scale this up like so. And you want to anchor this
to the bottom right corner. And now in this horizontal box,
you want to add a vertical box. Okay. And set that to fill. And then add a border
in the horizontal box. And then copy the vertical box and
paste it again on the horizontal box. And then in here we want to add a text. So add a text inside the vertical box. Select the text. We want to set this to,
um, center on this side. And then add fill. And set it like that. And we want to set the
text to 9, like a number. And the size, we can set this to 80. Compile and save that. And we might want to take this
horizontal box and scale this up a little bit like that. Okay, then we want to add another
text into this other vertical box. Set that to fill, and left
horizontally line and center that. And for the text we can do
like 30 or something like that. And for this size, we'll go
ahead and set the size to 40. Let's add a padding, so up here
at the top, add a padding of 10. And do the same thing for this
9 text, add a padding of 10. Actually undo that. We'll just add a padding for the right. So add, maybe like 5. Okay. And then we also want to
add an image of our weapon. So, search for image. And we can just add this
to the canvas panel. It doesn't need to be added
to the horizontal box. So size this like this. And make sure we anchor
this to the bottom. Uh, actually bottom right
corner of the screen. And for the image we can
set this pistol image. So set the image to pistol. This pistol image right here. And we can just scale this up like so. Okay, and that looks good. So now we can go ahead and hit play. And that should look pretty good there. The only thing that we want to do
now is we need to bind these numbers. to these current ammo and total ammo
variables inside of our character. So, let's go ahead and select this 9 text. And over in the text here we can
click this bind and create a binding. So I click get player character. And off of this value we can just
cast to first person character. And now we can get the variable, or
the variables inside of our character. So we want to get current ammo. And we can do to text, integer, and hook
up that to the return value, hook up the execution pin and compile save that. Then go back to the designer here,
select this other text, the 30 text, and go ahead and create another binding. And we're basically doing the same thing. git player character Cast to
FirstPersonCharacter, and then we want to get TotalAmmo to TextInteger, and hook that up to the return value. Compile and save that. And now we should have those
values bound to those variables inside of our character. So let's go ahead and test
this out by hitting play. So you can see if we fire our
weapon the amount of ammo decreases. And we hit zero and we
can't shoot anymore. So now all we have to do is hit play. Give ourselves the ability to reload. So when we press R, we want to give our
player the ability to reload our weapon. So let's go ahead and exit and In our BP
first person character, uh, maybe down here we can right click and add a R key. So when we press the R key on our
keyboard, we want to reload our weapon. And now the reload, um,
is actually going to be... It's quite complex because, uh, basically
how it works is, you know, if this value is, like, say, 10, uh, you want to
basically subtract The Max Clip Mount and carry that ammo over to your current ammo. And also you want to take into account if
you have, like say if the player reloads, and you have, um, maybe three more bullets
in the clip, you want to carry that ammo over so that you don't just delete it. If that makes sense. So reloading is actually quite a
bit of math that you have to do. But, you don't have to worry,
I'll walk you through all of it. Off the press here, we
want to do a branch. So we want to check a couple
things before we reload, okay? The first thing we want to check
is we want to get our current ammo. Check and see if it is equal
to our max clip size, okay? And then we want to do a OR,
and hook that up to the branch. So we're checking to see if our current
ammo is equal to our max clip size. Or, we want to get our total ammo. And check to see if this is
less than or equal to zero. If we don't have any ammo, any
total ammo left, that means that we just can't reload. Okay, so we're not going to do anything
off of the true, but off of the false. We can then go ahead and
add our reloading logic. So we want to do is get our
reloading Boolean that we set up and set this to true. And it's important that we do that
so that when we are reloading our player can't, uh, shoot the weapon. And then we want to get our
current ammo, get current ammo. And we want to promote this to a variable. So rename this to temp ammo and save that. And it has to be of the type integer. and hook this up. So I'm going to use this for
when we do our ammo math. So now let's do the math section of this. So we want to get our current ammo
and add this to our total ammo. So we want to add our current
ammo and our total ammo. And then we want to get our max
clip size and do a select integer. So based on a condition,
true or false statement, we want to select either A or B. Okay, so for the B we can hook up
this current ammo plus the total ammo. Okay, and so the condition we want
to drag off here and check and see if this is greater than or equal to. And we want to get our max
clip size and plug that in. And then hook this up for the condition. And if our max clip size is greater
than or equal to our current ammo plus our total ammo, then we want
to set our return value to B. Our return value will be our current ammo. So go ahead and drag your current ammo
and set that and hook this up like so. And then the next thing that we
want to set is our total ammo. So get your total ammo, and set that. And we want to do sort of the same thing. So down here we want to
get our max clip size. And we want to subtract
this by our total ammo. And then we want to get our total ammo. And subtract that by our max
clip size minus our total ammo. And then we want to clamp this
end value here by our total ammo. We'll plug that into the max. And then we're going
to do a select integer. And the A will be plugged
into the return value here. The B, we'll leave this at zero. And for the boolean, we'll plug in this
return value here, or this condition. And then we'll plug this in
for the total ammo, okay? And so that's all the math that we're
doing, and basically, what we're doing is we're checking to see if we have,
uh, ammo currently in our clip, and if so, we're adding that ammo to the
total amount of ammo that we have, and we're also adding Subtracting the total
amount of ammo from our max clip size. So for example, our max
clip size is 9 bullets. So we're subtracting that
amount from our total ammo. And we're doing this check to
see if, basically, do we have enough ammo to add a full clip. Or if we have less than a full
clip size, just add the remaining. So, for example, if I had total ammo,
if I had like 5 bullets left and my clip was empty, I would add the 5
remaining bullets to my current ammo, and then my total ammo would be 0. So, there's quite a bit of
things that you need to do. Uh, when calculating ammo. Like I said, it's just a lot of math. If you want to do it in a way that,
you know, the ammo can be carried over. I mean, some games make it so that
when you reload, Um, if you have like leftover bullets in the clip, it just,
you just throw it away, basically. But I don't want to do that, um, because
I want the player to be able to, uh, still use the bullets in the current clip
that they have, even if they reloaded. Now what we want to do is we want
to play an animation off of here. Uh, so, in our content drawer,
character, animations, Uh, we have this reload animation in here. So a really simple reload. And we want to right click
and create a, an anim montage. Compile and save that. And off of here we can
do our play montage. The inSkeletalMesh
component we just plug in. Our first person mesh, the in
montage, we'll do our reload. And then there's also another
animation that we want to do. So if you go to our military
weapon silver, weapons, animations. We have this reload pistol. So you can see it has this. Reloading of the clip and it also has
these sounds so you can hear these two different sounds So we're just going
to play this animation as well So off of this we can do Actually, we'll get
our pistol mesh and do a play animation The animation we want to play is that
pistol Reload pistol, okay and then when This reloading montage is completed. We want to get our is reloading
and set that to false. Okay? 'cause we've completed reloading. So now let's go ahead and
comment this entire thing out and just type reloading logic. Okay? So let's go ahead and test this out. So if we hit play now, we can
fire a weapon once and reload. And it looks like we have a bug here,
where we have basically infinite ammo. So I think I might have
messed up somewhere. Okay, so I messed up. So down here, instead of using this total
ammo, we want to use this temporary ammo. Okay. So the reason why we want to do
that is because we are setting our current ammo to our temporary ammo. And then over here we're
modifying the current ammo value. So that's why we're using this temp ammo. So we actually store the
value of our current ammo. Because we're actually
modifying it right here. And that will basically give
us, like, infinite ammo. So now with that fixed, let's
go ahead and test this out. So now you can see we reload. Shoot one bullet, we reload. We have nine. Bullets and seven left Okay,
you can see us reload And now we have no Total ammo left. Let's see if we can reload So if I hit
the R button nothing happens because I don't have any total ammo left so
these are my last shots and Then I can't fire because I'm out of ammo. Okay, so All of the reloading
is now set up properly So we're playing the animation. And we have the sounds. The last thing we want to set
up is we want to set up a ammo crate that the player can pick up. So at the start of every round
we want to give our player an ammo crate that we can pick up. That way we can resupply the
amount of ammo we have and be able to defeat the wave of zombies. So first of all let's go ahead and get... A 3d model for our ammo pickup. Uh, we're going to go to Quixel Bridge. So go to the Q plus icon, open up
Quixel Bridge, and we're going to go ahead and search for a military trunk. And it's this military trunk right here. Uh, you can just download it
and add it in your project. So once you've downloaded and
added it, you should have it. Here under your Megascans,
3D Assets, Military Trunk. And so in our main, underscore main
blueprints, we're going to add a new blueprint class of the type Actor. And we're going to name this
BP underscore Ammo Pickup. Okay, so double click to open this up. Um, and inside here we're going to add
a, Static Mesh, and then we're going to add a, select the default scene root
and add a collision, sphere collision. So this will be a sphere that
we will use to overlap with our character to pick it up. And for the static mesh, we can set
it to that military trunk, okay. And let's go ahead and scale
up this sphere to 5 by 5 by 5. And then let's go ahead
and add another component. And this will be called rotating movement. We can just compile and save that. Now in the event graph, we only
have to do one thing in here. And we can go ahead and delete all this. Select your sphere collision. Scroll down, we want to
add a event begin overlap. So when we overlap with this
sphere, basically we're going to add some ammo to our character. So off of the other actor, we want
to use the other actor because this is the only one that will work. With the cast, so if we do our cast
to first person character, we can now call a function or an event inside
of our character to add some ammo. So in our first person character,
we can add a event down here. Add custom event. We can name this add ammo crate. And all we'll do here is get
our max clip size and set our current ammo to our max clip size. So what we're doing is we're kind of
replenishing our ammo in our clip. Kind of like the um, max
ammo in Call of Duty Zombies. So it like fills up your current clip. All the way up as well
as like your total ammo. Okay, so we'll get our total
ammo and we're going to add like a hundred bullets to our total
ammo, and then we can set or total ammo to our total ammo plus a hundred. Okay? And then we can do like a
play sound, so play sound 2D. And the sound that I used is... Rocket... Launcher... Actually, Rocket Launcher Reload Queue. Okay. And now we can comment this out. Just say, pick up ammo. And then in our BP ammo pickup
we can now call that event. But before that we want to do a do once. So basically we're only going
to pick up this ammo once. So we just want to do an extra check
to make sure that we don't pick up this ammo multiple times and like
our player gets like a thousand ammo. So off of here we can
do that add ammo crate. And hook this up, and
then we can delay for 0. 2 seconds and destroy actor. So the reason why we do that is just
so that we give it, give the game time to call this function inside our
character before we delete ourselves. Because sometimes it will just run
through this really quickly and it will destroy itself or delete the actor. Without having a chance to, like,
finish this function or whatever. So we'll just do that. So now this should be all set. I can go ahead and test this out. So if we drag one of these ammo
crates inside of the level. If I hit play. You can see we have this ammo
crate and it's spinning around. It's pretty cool, and when we pick it up,
or when we overlap with it, you can see it gives us 100 ammo, it plays a sound. I actually want to scale
this up a little bit. So in the viewport, let's
scale this up to 2x2x2. See how that looks. Alright, so that looks a lot better. So when we overlap, we reload
all of our ammo, and we have 100 rounds added to our max ammo. Okay, so now what we want to do is
instead of just spawning this at the same location every game, what we want
to do is we want to spawn this at random locations and we want to spawn this
at the beginning of each round, okay? So we can go ahead and do
that through our game mode. Uh, so our game mode already
has a round based system setup. So, down here at the bottom we
can just add a custom event, and we can name this to SpawnAmmo, and then we can do a SpawnActorFromClass, and we just want to spawn
that BP underscore AmmoPickup. Okay? And, for our SpawnTransform,
We're going to randomize this. So we're going to add maybe like 1, 2, 3,
4 different spawn locations, and it will just randomly pick one of these locations. So in our game mode here, we're
going to right click the transform and click split pin structure. And we're going to take our
spawn transform location And we're going to add a new
variable in here and name this AmmoCrateLocations. And change the type to a vector. And we want to change this
from a single to an array. Okay, so compile and save that. And now we can add. different locations here. So if we add a plus button, you can see
we can add multiple different locations. So I'm going to add a
four total locations. And for the location, what we can
do is copy this location right here. So copy the location and go in
our game mode and paste that. And then we can move this over here. And so you want to spawn
an ammo crate over here. Copy that location and
paste that into here. And we want to spawn another
one over on this side. Copy the location and paste it over here. And one last location. Just put it right here. Copy that. And paste that. So you could add a lot more randomized
locations, but four should do for now. Then off of our, um, spawn
transform, what we want to do is get our ammo crate locations. You want to get a copy and for the
index, we'll do a random integer. Okay. And the maximum will be, uh, 3, because
the maximum array index is from 0 to 3. So technically there's 4, but like
I said, arrays start at index 0. So 0, 1, 2, 3. So the random integer, the
maximum value will be 3. Okay. So, let's go ahead and plug
this into the spawn transform. And then let's comment this out. Spawn ammo crate. And then we just need to call this event. So over here when we spawn zombies,
let's go ahead and do that. Spawn ammo event. So let me move this over here. And hook this up, compile and save
that, and let's just delete this ammo so we don't start with any. Now if we hit play, we should
have an ammo box randomly spawn, so it's right over there. So go pick this up, so
regenerate all of our ammo. We can go ahead and shoot, reload, reload. So now we have wave number two, we
should have another box that has spawned. So, actually I think it just spawned
right behind us, so we just picked it up. Okay, so wave 3 is starting, let's go
ahead and see where the ammo box spawns. So it spawned over here. So as you can see, the ammo
crate basically randomly spawns at a different location. It gives us ammo. And we can reload our weapon,
and all that is set up. So now we have basically our game
loop, as well as our win and die logic. And actually I think we
just found a bug here. When you die, you actually
can't click any of the buttons. And that has to do with the blood overlay. So let's go ahead and go into our
main widget and our death window. Select that. I want to set the Z order to 1. And we'll do the same
for our, uh, win window. Set the Z order 1. Okay. So that will make sure that
it's always on the top. So let's go ahead and test that. I can die. Real quick. And now you see that
blood overlay is below. Our death widget. Okay. Now we're basically
finished with the game. There's a couple more things, some
more fixes I want to do, uh, like adding sounds and things like that. But before we do that, I want to
work on creating the main menu. Uh, just add a really simple menu
that way when you launch the game or when you, you know, quit the
game, you can quit to the main menu. Uh, let's go ahead and just create
a file, new level, and we can just create an empty level and
then file, save current level as. And in our maps folder, we can save
this just as a menu and make sure you get the spelling and capitalization
the same as it is and then, We want to go ahead and in the world settings,
just add a game mode real quick. So click this plus button
and in our blueprints we can add a main menu game mode. Click save. For the pawn class just click none. And now let's create a main menu widget. So, In our Widgets folder, let's right
click and add a new User Interface Widget Blueprint of the type User Widget. We can name this MainMenu underscore W. So double click to open that up. And this will be really simple,
we just add a Canvas Panel. And a Canvas Panel will have an image. And set the image, anchor
that to full screen. And reset, set the offset
right and bottom to zero. We're going to look for the image. So it's this main menu image. So go ahead and set that like so. And so we have this really
simple, um, infected game. I like logo and main menu and you could
take a better screenshot if you wanted to or make a better main menu logo. This will do for now. We're going to add, I'm going to add
a vertical box down here and then just anchor this to the bottom left and in
here we're just going to add two buttons. And add some text onto the button. And just copy and paste this twice. And then select the button here. Let's add some padding. 10 and 10. And then the text box you can select
the text and name this to play game. And you can name this other
text here to quit game. Okay. So just a really simple
two button main menu. Not, doesn't have to be fancy. So now let's actually
rename our buttons here. So this will be our play game button. And then this will be
our quit game button. And in our graph here, we can delete this. And select our play game
button, add it on clicked. And select our quit game
button, and add it on clicked. And then for our play game button, all
we have to do is to open level by name. And we open our map. Our bridge map. So type in bridge map. And then the on clicked quit button. We just do quit game. Okay. So now all we have to do is add
this main menu to our screen when we play this main menu level. So to do that we can click on
this little button right here and we can open the level blueprint. And so this is the blueprint
that is the level blueprint. So this will be called every time
how we play inside of our level. So off this event begin play
we can just do a create widget. And the class we will create
is our main menu widget. The owning player just drag off
here and get player controller. And the return value we
can just add to viewport. And we just want to get our player
controller and set show mouse cursor. Set that to true. So I believe we should be able
to test this out if we hit play. We have our main menu. We can click play game. And that will spawn us here in the level. Okay. And we can also hit play here and quit
game, and that will exit that out. So, let's go ahead and launch
this in a new editor window. Click play. So here we are. Let's go ahead and just die real quick
to see if we can exit to the main menu. Now if we exit to main menu, it'll take
us back to this main menu, uh, level. So now we just hit quick game
and that's pretty much all set. So that's pretty much the entire
game setup from start to finish. I do want to fix a couple of bugs, just
do a couple of minor tweaks to the game. So if I open up my recent level
bridge map, I want to add a couple of tweaks to this game. And just some polish. Basically, we just want
to add some extra sounds. So for example, let's add
some sounds for our zombies. So when they do like an attack on
the player, we can do like a play sound, attack, sound, uh, we can
also do like a zombie horde sound. So when there's a bunch of
zombies, we can play like a zombie horde moaning or whatever. We can also add some
sounds for our character. So when we go to like reload, and
if we don't have any ammo, we can do like a empty, uh, empty gun sound. Let's go ahead and add all those sounds
in, in the project files under the sounds. I have a couple of different
sounds that I've downloaded here. Uh, so we have some attack
sounds and then this horde sound. So in our content browser here, we're
going to go ahead and dock this in layout. And then in our zombie here,
we can right click, add a new folder, just call this sounds. And just select all these sound files
and drag and drop them in there. And make this full screen. Now for our attack sounds,
we want to add a sound cue. And what a sound cue allows us
to do is it basically randomizes these attack sounds because we
have four different attack sounds. And so we right click under the
sounds we can add this sound cue. And we can just name this attack cue. Double click to open that up. And drag off of the
output we can do a random. And then go to our content drawer here. Zombie, sounds, shift select all these
attack sounds and just drag and drop them. So now we can add some more inputs. We just hook up these inputs like so. So now if we click this play cue. You can see that it randomly
selects a sound to play. Okay. So now what we can do
is we can use this cue. Inside of our BP zombie So in the event
graph here, we're going to Off this on and notify begin We're just gonna move
everything over a little bit So move this over like that And select all this
move this over Off the notify begin. We're going to do a play sound
at location And for the location, we just get the actor location,
see the location of the zombie. And we're going to play this attack queue. And if you expand this window down,
we have more settings down here. And basically we have
this attenuation settings. And what that does is it's basically
like a sphere around the character. So if you're within that radius, or within
a certain distance to the character, you can hear this attack sound, okay? So like if we're across the map, we don't
want to hear that attack sound because we're not anywhere near the zombie. So if we click this attenuation
settings, we already have some attenuation assets created. So what we want to use is we can
use one of these premated ones. Uh, probably like this weapon shot
one, and we can test this out. So if we hit play, um, we can let
our zombie attack us, hear the sound, and we let it attack. So you can see it gets quieter if
we move away from the attenuation. Let's go ahead and add some ambient noise. Zombie Horde sounds. So if we go to the viewport over here. We can add a component. And add an audio here. So I'm going to add an audio. And I want to rename this. To. Horde sound. And for the sound here. I'm just going to. Select. This. Horde sound wave. And then I'm going to scroll down
until I get this attenuation settings and for the attenuation, I'm going to
use this Projectile impact attenuation so you can see here the size of the
attenuation Okay, and now if I hit play We can hear like the zombie horde sounds
off in the distance Another thing I want to add to our character Is on the
shoot logic, uh, if we, if our ammo, current ammo is less than zero, so
that means if we don't have any ammo in our clip, I want to play a sound here. So, play sound 2d, and the sound
that I want to play is pistol. Mag Insert 0 1 So basically this will
make it sound like we don't have any ammo. It'll be like a click sound You can see we
have this click sound when we don't have any ammo in our in our clip or in our gun. Okay So it's like if we were to pull
the trigger it just makes a click sound. So just little additions there. Now that's pretty much all of the
sounds I wanted to add to this game. There's a couple other polishes
and fixes that we can do. Things like our first person
character if we go in the viewport. Currently our pistol
mesh is casting a shadow. So we hit play here you can see. You see our pistol mesh right
there casting a shadow, and I don't really like that. So in our first person character
the pistol mesh selected we can search for cast shadow And
then just uncheck that okay? It's just a little fix there But it
adds that nice detail Okay, okay. Now. There is one final thing That I want to do
before I wrap this video up, and that is add some collision boxes around this map. Because currently, I can spawn in
here, my player can just jump on this bench, and then just jump off the map. Okay? And we don't want that. Also, our player can run into this
area, and just run past the zombies, and basically exit the level. So what we want to do is we
want to enclose this area off. And add some like collision boxes so the
player can't escape out of this play area. So to do that we can go
to this cube plus icon. And under the volumes we
can add a blocking volume. So this will block. Basically, our player, as well
as the zombies, zombies actually won't be able to get through this. And what we're going to do is we're
just going to scale this up and put this on the rails so that our
players won't be able to jump out. Okay. So just like that, and they
can move this over here. And then we just need to
duplicate this, rotate this 90 degrees, and scale this down, and move this over like so. We're just making sure that we cover
every corner here, that way our player can't just jump off the edge. And we can just... Rotate this. Turn off the grid snapping here. And rotate it like so. And then we want to take one of
these boxes here and duplicate this and rotate it right here. And what we're going to do is we're going
to let the zombie pass through this. Particular box, but we're going
to disable it for the player. So what that means is These zombies
will be able to spawn over here and pass through this blocking volume But the
player won't be able to Walk past it. Okay So we're going to set that up here
in a second, but right now we'll just leave this as A blocking volume and then
we can take This part and Duplicate this over take all this and duplicate this
over and Just make sure everything is Lined up the way you want it and then
take this blocking volume and duplicate it over here And that should be about good
right there and you could add one to the top, but our player There's no way for
our player to jump out of the level or like fly up here, so it should be fine. So now we're going to add some
sort of custom collision, that way our player can't pass through this
box, this blocking volume, but the zombies can spawn and pass to them. So we're going to go into our edit
project settings and we're going to add what's called a Custom Collision Channel. So in our project settings under the
collision we have this object channels and we can add a new object channel. I'm going to name this zombie. And just set default response to block. So you can actually have 18 custom
collision channels, but you don't want to go further than that because you
It will lag your game out So just note that you can have you know these custom
collision channels But you want to use it with caution because you don't
want to have like a bunch of checks Collision checks, okay so now that we
have that Collision channel set we can select this box In the details panel,
we can scroll down to our collision. So our collision presets right
here Want to set this to custom? And now we want to set our object type to
the type to the zombie one that we made. I think we either need to refresh our
project or reopen our project real quick. So I'm going to go ahead and
save selected and reopen it. So we just really quickly
had to reopen our project and open up our bridge map level. So now if we select this collision box. And go to the object type, we should
be able to set that zombie object type. And now let's scroll down here. We want to overlap,
uh, ignore camera here. If we scroll down, all the way down the
bottom we want to set for the zombie, we want to set this to overlap, okay? Save that. So this is our settings
for this collision box. And we can do the same
thing for over here. Uh, set this to custom. Object type to zombie. Uh, trace response. We want to let the, we
want to ignore the camera. And then for zombie we want
to set this to overlap. Okay. So the reason why we're doing
this is, again, we want the zombie to be able to pass through. And not the character. And the reason why we're also setting
the camera to ignore, for our trace responses, is because our character
shoots a line trace from our camera, and because it shoots a line trace from our
camera, uh, this wall actually blocks that trace, if we have it set to block. So that's why we set it to ignore. That way our player can shoot through
this wall, and it won't get blocked. Okay? So that's set. Let's go ahead and open up our zombie. So zombie, zombie BP. Viewport, select the capsule component. We want to go to the collision settings. So here in the collision settings
we want to change the presets from pawn here to custom. The only thing we want to
change here is for zombie we want to click this to overlap. Okay, so basically this capsule component
will be able to overlap with this blocking volume that has been set to
overlap with the collision response or the collision object of a zombie. Okay. All right. So it looks like I forgot to
set one more setting here. So, you want to select the navigation
box, the blocking volume, and, uh, What you want to do is search
for navigation, and you want to uncheck can ever affect navigation. Okay, so if I hit P, you
can see the navigation. So with that unchecked, it
will not affect the navigation. So right now, this blocking
volume is affecting the zombie's ability to navigate. Okay, so if I uncheck that. Now this blocking volume will actually
let the zombie navigate through it. And because of our custom
collision settings, it will let our zombie actually pass through it. So basically it's kind of a two part
thing where you need the zombie to not collide with it, and you also need the
navigation to not be blocked by it, okay? So now we should be able to test this out. So our player can't move through this,
but the zombies can move right through. Okay, test it out on this side. We can't run over here. And we also can't jump
off the edge anymore. And you can see here we have that
blocking volume that makes it so that our player can't escape out of the level. Alright. So that is how you'd go about setting
up, you know, the player bounds and setting up that custom collision
that only affects the zombies. So anyways, that's pretty much
it for this tutorial course. I know it's quite a long course,
but hopefully you learned something from this course. We covered a lot of topics ranging
from, you know, creating a character, first person character, importing
all the animations, and setting up, you know, our animation blueprint. We went through programming and all
the weapon firing logic, and setting up our enemy AI that will chase us. We've created our own map. And of course all the user
interface that shows the different waves and all that stuff. So anyways, if you enjoyed this video,
make sure you leave a like and subscribe. I put a lot of effort into... researching and developing this course as
well as recording editing all that stuff and if you want to support the channel you
can either head over to patreon I'll leave a link in the description below where
you can get access to completed projects environments all that sort of stuff on
there or you can check out my premium courses On my teachable, uh, smartpoly. teachable. com. I'm currently working on creating some
courses such as like a multiplayer survival game, multiplayer, first
person shooter, all that sort of stuff. So hopefully by the time you're watching
this video, those courses are finished and uploaded on my teachable, but yeah,
that's pretty much it for this video. I hope you guys enjoyed, and I'll
see you guys in the next one.