Hello, guys.
In this section, we're going to bring our game to a playable state.
And first task would be to restart game on death.
Luckily, that will be very easy to do.
We just need to go to game manager and over here in the top we need to type using Unity engine dot scene
management.
This will allow us to load or reload scenes and that's what we're going to do here.
I'm going to create new function public void, restart level return scene manager load scene and we
can just put build the index here and we have only one scene in the unity if I will go to project settings.
So here.
File build settings.
We can see this is my scene that is in the build and it has index zero.
So that is good.
Now what we need to do is go to player.
Let's find our dysfunction and just add another delay, let's say for a second, and then I'm going
to do game manager dot instance dot.
Restart level.
Now let's go back to unity and create a dead zone.
So scene will be restarted not only when you die, but also when you fall.
That is also easy to do.
Let's create empty object and I'm going to call dead zone.
I will add the box collider to DX.
Let's change sides to make it long and.
We're going to check e trigger and add new script that I'm going to name as dead zone and trigger or
better trigger dead zone inside.
We're just going to delete all of this undo on trigger enter to D and I'm a bit lazy today, so I will
just copy code from my trap.
Let me find it.
Trap.
Here if component of the player not equals to no, then we're going to call game manager dot instance
dot restart level.
Now let's move it somewhere below and there will be only one task to do here.
First, I want to check and make sure it's working.
I'm going to go to my level part and.
To get a platform they need Trump.
Trump takes the platform.
Place.
The Trump.
And End Point can be placed somewhere here.
Let's go.
So look, this is my dead zone, and it's only this long, and I need to find a way to move it together
with the character first.
When I make sure it's working, then we're going to move it together with a character.
Let's try.
So I fell and seen it restarted.
If I hit the trap, boom.
I died and seen it restarted.
Cool.
Now, how could we move the dead zone?
Very simple.
We know that camera moves together with the player, so what we can do is go to main camera and just
make that zone child our main camera over here and place it somewhere below.
And now.
Maybe we can place it a bit lower.
So Player actually has time to understand that he fell to the gap and that's why level is restarted.
Now we done here.
Let's go the next video.