Welcome back, My favorite game developers.
In this video, we are actually going to
add a health system to the player.
So now, not only do we kill the enemies,
but also if we get hit too much with the swords, we die.
Obviously there are things that we will
have to fix lecture on, but for now,
all we are doing is setting up
the health system of our player,
making our being just a little bit closer to
reality and feeling much better adding a bit of steak.
So before this video,
we would always run around and have fun
and kill everybody and not
worry about a thing in the world.
But now we are dying.
It's kind of like finishing
college and starting a real job.
You go into the real world.
There are a lot of things at stake.
So let's not waste any more time and let's get started.
Oh, case.
So currently everything is set up properly.
We can shoot, we can get shot,
we can do everything.
We heard the enemy, we can kill him,
but when the enemy shoots us,
it doesn't hurt as much.
So what we're going to do in this section,
and especially in this video,
is to create a health system.
So let's get started by setting everything up.
First thing first, we are going to go into the scripts,
go into the player,
and we'll create in here
a C-sharp script that's going to be
the player health controller,
or should have called Player health
handler because it's not
actually controlling the player health.
It's handling.
You know what? Let's go ahead and
make it the full delete.
This will create a layer health handler
because it handles they have
and it's not that big of a problem,
but I always like to keep things their health handler.
So because this handles the health of the player,
don't actually control it in any way.
So I'm going to add it to the doom layer
and I'm going to apply all the changes.
And I'm going to open up the player health handler.
So what do we need here?
Well, obviously, first thing we need is
a serialized field which
will represent the current health.
And this is just for debugging purposes.
Obviously, we don't want to be
able to always see the current health.
Then we are going to create
a second variable which is the max health.
And then start, we are going to instantiate
the current health as the max health.
So whenever we start a game,
whenever our player papyrus or starts playing,
we will have the current health as the max health.
Now, the next step is to create a method that will
actually handle taking damage by the enemies.
And that's going to be part of your challenge.
So your challenge is to create a method to take damage.
So create a method that will damage the player.
It should take a parameter,
the damage amount determined what type
the parameter should be inside the method.
Remove the damage amount from the current health and
check if the health is less than or equal to 0.
We want to make the player inactive.
So pause the video right now and go do
the challenge. Welcome back.
So I believe this was a pretty easy challenge.
I don't think it was too hard.
So I'm going to remove the update.