1
00:00:00,000 --> 00:00:00,000
Hello, guys.

2
00:00:00,000 --> 00:00:03,000
In this section, we're going to bring our game to a playable state.

3
00:00:03,000 --> 00:00:06,000
And first task would be to restart game on death.

4
00:00:06,000 --> 00:00:08,000
Luckily, that will be very easy to do.

5
00:00:08,000 --> 00:00:14,000
We just need to go to game manager and over here in the top we need to type using Unity engine dot scene

6
00:00:14,000 --> 00:00:15,000
management.

7
00:00:15,000 --> 00:00:20,000
This will allow us to load or reload scenes and that's what we're going to do here.

8
00:00:20,000 --> 00:00:28,000
I'm going to create new function public void, restart level return scene manager load scene and we

9
00:00:28,000 --> 00:00:35,000
can just put build the index here and we have only one scene in the unity if I will go to project settings.

10
00:00:35,000 --> 00:00:36,000
So here.

11
00:00:37,000 --> 00:00:39,000
File build settings.

12
00:00:39,000 --> 00:00:43,000
We can see this is my scene that is in the build and it has index zero.

13
00:00:43,000 --> 00:00:45,000
So that is good.

14
00:00:45,000 --> 00:00:48,000
Now what we need to do is go to player.

15
00:00:51,000 --> 00:00:57,000
Let's find our dysfunction and just add another delay, let's say for a second, and then I'm going

16
00:00:57,000 --> 00:01:00,000
to do game manager dot instance dot.

17
00:01:01,000 --> 00:01:02,000
Restart level.

18
00:01:04,000 --> 00:01:06,000
Now let's go back to unity and create a dead zone.

19
00:01:06,000 --> 00:01:11,000
So scene will be restarted not only when you die, but also when you fall.

20
00:01:11,000 --> 00:01:13,000
That is also easy to do.

21
00:01:13,000 --> 00:01:17,000
Let's create empty object and I'm going to call dead zone.

22
00:01:18,000 --> 00:01:20,000
I will add the box collider to DX.

23
00:01:21,000 --> 00:01:24,000
Let's change sides to make it long and.

24
00:01:25,000 --> 00:01:33,000
We're going to check e trigger and add new script that I'm going to name as dead zone and trigger or

25
00:01:33,000 --> 00:01:37,000
better trigger dead zone inside.

26
00:01:37,000 --> 00:01:43,000
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

27
00:01:43,000 --> 00:01:45,000
just copy code from my trap.

28
00:01:46,000 --> 00:01:47,000
Let me find it.

29
00:01:47,000 --> 00:01:47,000
Trap.

30
00:01:51,000 --> 00:01:58,000
Here if component of the player not equals to no, then we're going to call game manager dot instance

31
00:01:58,000 --> 00:01:59,000
dot restart level.

32
00:02:03,000 --> 00:02:08,000
Now let's move it somewhere below and there will be only one task to do here.

33
00:02:08,000 --> 00:02:10,000
First, I want to check and make sure it's working.

34
00:02:10,000 --> 00:02:12,000
I'm going to go to my level part and.

35
00:02:15,000 --> 00:02:16,000
To get a platform they need Trump.

36
00:02:16,000 --> 00:02:19,000
Trump takes the platform.

37
00:02:21,000 --> 00:02:21,000
Place.

38
00:02:21,000 --> 00:02:22,000
The Trump.

39
00:02:23,000 --> 00:02:27,000
And End Point can be placed somewhere here.

40
00:02:28,000 --> 00:02:29,000
Let's go.

41
00:02:31,000 --> 00:02:36,000
So look, this is my dead zone, and it's only this long, and I need to find a way to move it together

42
00:02:36,000 --> 00:02:38,000
with the character first.

43
00:02:38,000 --> 00:02:41,000
When I make sure it's working, then we're going to move it together with a character.

44
00:02:41,000 --> 00:02:42,000
Let's try.

45
00:02:44,000 --> 00:02:46,000
So I fell and seen it restarted.

46
00:02:46,000 --> 00:02:50,000
If I hit the trap, boom.

47
00:02:50,000 --> 00:02:52,000
I died and seen it restarted.

48
00:02:52,000 --> 00:02:53,000
Cool.

49
00:02:53,000 --> 00:02:55,000
Now, how could we move the dead zone?

50
00:02:55,000 --> 00:02:56,000
Very simple.

51
00:02:56,000 --> 00:03:02,000
We know that camera moves together with the player, so what we can do is go to main camera and just

52
00:03:02,000 --> 00:03:07,000
make that zone child our main camera over here and place it somewhere below.

53
00:03:08,000 --> 00:03:09,000
And now.

54
00:03:13,000 --> 00:03:15,000
Maybe we can place it a bit lower.

55
00:03:15,000 --> 00:03:20,000
So Player actually has time to understand that he fell to the gap and that's why level is restarted.

56
00:03:21,000 --> 00:03:22,000
Now we done here.

57
00:03:22,000 --> 00:03:23,000
Let's go the next video.

