Welcome back, My favorite game developers.
And this video, as you can see,
the UI canvas has an extra element,
which is the death screen.
So now when we run the game,
we can see that we have a health.
So we get shot once,
we got shot twice, and there you go.
You can see that you will die just like in Dark Souls.
And we have this effect appearing.
How cool is that? And not only that,
you'll notice that we no longer have sorts
instantiated by the enemy after the player dies,
which is a really nice mechanic that we've
added at the last second because I just remember that.
So let's not waste any more time and
let's get to creating the screen.
Oh, okay, so time to make the death
of our player just a little bit more exciting.
And I've changed the pixels per unit to 15 of the tiles.
So now we don't have these annoying blue lines.
So I'm going to go ahead in the UI canvas and I'm going
to create a new image.
And this image is going to be the death screen.
There we go. And let's just make the scene a
little bit bigger and we are going to
fit it into the entire screen.
And just like we always do,
we are going to go ahead and make it completely black.
And then what I'm going to do is I want to get
these so we haven't used these block trills yet.
So I'm just going to get the 123 and the last one,
select all of them.
And I'm going to drag it into four.
We do that, that's in the sprites.
Create a folder for the blood death screen.
How a nice course,
a very lovely project all about blood deaf and whatnot.
So let's see how that looks.
And now before we do that,
actually I believe we need to create a,
some kind of image in here.
So there we go, the image and I'm going
to change this right here,
and I'm going to set it to the native size.
So it's kind of big.
I'm just going to make this one setup
donated size and maybe just increase the size of it.
So there we go around.
I'm going to keep preserve the aspect ratio.
So now we can make it a bit bigger.
So there we go. So this will splash over our screen.
I'm going to create an animation in here.
So I'm going to go to the animations, create and assets,
animations, death screen, the screen, blood.
And let's see, splash, lot on screen.
Save that. And I'm going to add all of
these images in here.
And let's see how that looks.
Let's do first, Let's make it around 1 second.
See how that looks. Okay, that looks good enough for me.
Save that.
Let's call this the blood.
And let's change all the images and
make them no point filter apply.
So the images should be sharper right now.
And let's watch that again.
Not too sharp.
I would have rather making it a bit more sharpen that
maybe we can change the one to 50 apply.
Now they shouldn't be become much bigger.
The extrude with width.
Okay, so let's see what's the problem in here.
Clear that, okay, so now we have the blood
splashing all over soon as we start.
And what I'm going to do is I'm going
to add also a canvas and here.
So what's the campus group that was called
Canvas groups or now we can
adjust the Alpha and we can block the re-cast.
That's not a bad idea.
We won't make it interactable.
And now I also want to go ahead and maybe
move the blood a little bit down,
maybe rotate it a little bit.
So now there we go.
This is the blood that will appear.
And honestly I feel that this is not really looking
good because it's kind of
grainy because we made it bigger.
I think we might remove it later on,
but for now let's just add a text Mesh problem here.
Text Mesh probe and
you die or capital.
And make it bold.
Let's see how that looks.
Let's make it a bit bigger and auto size.
And let's set it in the middle.
And we can see that the max size in here,
we can make it even bigger.
So there we go, You died.
Let's choose a different font,
which is the one about the robot.
Let's change the color of it to make it red.
Let's move it up.
Let's see how that looks.
It doesn't look too good because
of the outline that we have.
So we are going to change the outline to
be maybe also read or
maybe just remove the outline completely.
So there we go without any outline.
Okay, that looks good.
So you died.
Okay, so if you've ever played Dark Souls,
you know the reference and the, Let's continue on.
So I think this is big enough.
So now when the Lord lays, there we go.
We can see we get the blood
and we get the you died on the screen.
So this tells us that the player just dive.
Anyways, let's continue on now we
need to actually turn this on and off.
So what we're going to do is we're always
going to keep the death screen off.
So as long as the player is alive that
that screen is off and when he dies,
then we turn the screen on.
So let's go into the UI Manager.
And obviously we'll be changing the alpha on here also.
We don't want it to just appear.
We will make it slow will appear.
And for that, we are going to also create
an animation in here and screen blood.
Let's call this the screen.
Appear.
Save that.
And let's change this to take
around 0.3 seconds and put it to one.
So this is sort of the, you need to turn it on.
And so this is sort of what happens.
So we turn on the screen, it's starts playing.
And there we go. And I'm going to just move
the blood animation to
when the death screen is completely dark.
So we start the animation,
there is nothing and then
the block should appear later on.
And actually we can go ahead and select this in
here and just have an empty sprite.
So we start off empty.
Let's just see how that looks.
And I'm going to turn this on completely. So there we go.
Nope.
The blood run this.
There we go. And then we get the blood appearing.
Okay, Excellent.
I think this is going to look really nice.
So save all of that back to the desk screen,
set it to 0, turn the screen off, save all of that.
And now let's go into our scripts.
And in the UI Manager,
I'm going to go ahead and get
a reference to this, that screen.
So serialized field, it's a game object
and it's going to be the death screen.
And now we are going to go ahead and create
a method that will allow us to turn it on.
So it's going to be a challenge.
And your challenge is to activate the depth screen.
Well, when we die.
So you'll need to create a method that
sets the death screen to active.
And then you'll need to call the methods,
method when the player dies.
So to create that method and do I manager and then call
it from the player health handled with that said,
pause the video right now and go do the challenge.
Okay, welcome back.
So in here in the UI Manager,
I'm going to create a public void.
Turn death screen on.
And all that it will do is just get
the death screen and set active to true.
And that's all.
And then we'll go back and do the player handler and
end here after we turn off the game object of the player,
we are going to access the UI Manager.
Or before we do that in here,
the UI Manager Instance,
deaf, turn death screen on. And there we go.
So now we're going to start our game.
Let's go to the game, make this bigger.
Let's go to the DOM player will set his health
to be 100. Run the game.
So now when we get hit once,
there we go, nothing happened,
obviously because every single time I have to forget to,
you know, where this is going.
We forgot to add a reference.
Excellent.
Now we save, now we run.
Now we should have everything working. There we go.
We get shot once, twice, you died.
And obviously we also
forget the thing that we always forget.
So animations, where is it?
The blood?
The blood or death?
The death.
Okay, remove the animation. Remove the animation.
Save that from the game for the third time, please.
No more errors.
And now we get shot once, twice, we die.
Nice. How cool is that?
But obviously there is the one problem that
still prevailing and that is the flying saucer.
So what we're going to do is
we're going to make sure that the enemy can
only should sort or should whatever projectile he has.
Only when we are visible or when we are in the game.
So I'm going to go into the NMI controller and here,
and I'm going to scroll down and find where we are
instantiating the bullet or the projectile.
So there we go in here.
And the enemy fire
and the Colton here we are instantiating this.
So what I'm going to do is I'm going
to create a condition in here that checks if the player
to chase dot is dot game object out.
So this is player chase range.
So the player to chase dot is okay.
So game object dot is,
dot is active or active and hierarchy.
Then we are going to shoot.
If not, then we are not.
So this active and hierarchy
defines whether the game object is active in the scene.
So what we're doing is we're turning
off the player when we die.
That means that he is no longer active.
And the hierarchy, that means that we no longer
instantiate the projectile of the enemy
and we shouldn't get any errors.
So let's try this one more time. Run the game.
And let's see, we get sharp once,
twice. Okay, You died.
There we go.
We can see that we no longer have
any errors and the enemies don't instantiate anything.
And if I zoom in to where is it?
The doom, right here, okay,
So we can't see anything,
but you can see that we are
no longer instantiating anything.
Let's run this again because I believed that I
saw something right here when we got shot.
Oh, okay. Okay.
No, everything is good.
So there we go. We have our death screen.
We no longer have
the projectiles and instantiating
whenever our player dies,
let's make sure we apply the changes.
We make sure that we commit our changes,
and we make sure that we leave a review for
Michael because it helps him out a lot.
In the next video, we are of course,
if you are enjoying the video,
obviously, anyways, in the next video,
we are going to create the mechanic of making the player
a bit invincible whenever he gets
it for just a temporary time.
So that said, I hope you enjoy
and I'll see you in the next one.