1
00:00:00,000 --> 00:00:03,080
Welcome back, My favorite game developers.

2
00:00:03,075 --> 00:00:05,475
In this video, we are actually going to

3
00:00:05,475 --> 00:00:08,405
add a health system to the player.

4
00:00:08,400 --> 00:00:11,580
So now, not only do we kill the enemies,

5
00:00:11,580 --> 00:00:15,440
but also if we get hit too much with the swords, we die.

6
00:00:15,435 --> 00:00:17,405
Obviously there are things that we will

7
00:00:17,400 --> 00:00:19,860
have to fix lecture on, but for now,

8
00:00:19,860 --> 00:00:21,600
all we are doing is setting up

9
00:00:21,600 --> 00:00:24,000
the health system of our player,

10
00:00:24,000 --> 00:00:27,240
making our being just a little bit closer to

11
00:00:27,240 --> 00:00:30,540
reality and feeling much better adding a bit of steak.

12
00:00:30,540 --> 00:00:32,310
So before this video,

13
00:00:32,310 --> 00:00:34,740
we would always run around and have fun

14
00:00:34,740 --> 00:00:35,880
and kill everybody and not

15
00:00:35,880 --> 00:00:37,260
worry about a thing in the world.

16
00:00:37,260 --> 00:00:39,120
But now we are dying.

17
00:00:39,120 --> 00:00:40,640
It's kind of like finishing

18
00:00:40,640 --> 00:00:42,320
college and starting a real job.

19
00:00:42,320 --> 00:00:43,940
You go into the real world.

20
00:00:43,940 --> 00:00:46,240
There are a lot of things at stake.

21
00:00:46,235 --> 00:00:50,575
So let's not waste any more time and let's get started.

22
00:00:50,570 --> 00:00:52,570
Oh, case.

23
00:00:52,570 --> 00:00:56,110
So currently everything is set up properly.

24
00:00:56,105 --> 00:00:58,325
We can shoot, we can get shot,

25
00:00:58,325 --> 00:00:59,575
we can do everything.

26
00:00:59,570 --> 00:01:01,550
We heard the enemy, we can kill him,

27
00:01:01,550 --> 00:01:03,490
but when the enemy shoots us,

28
00:01:03,485 --> 00:01:05,525
it doesn't hurt as much.

29
00:01:05,525 --> 00:01:08,105
So what we're going to do in this section,

30
00:01:08,105 --> 00:01:09,595
and especially in this video,

31
00:01:09,590 --> 00:01:12,760
is to create a health system.

32
00:01:12,755 --> 00:01:15,925
So let's get started by setting everything up.

33
00:01:15,920 --> 00:01:19,150
First thing first, we are going to go into the scripts,

34
00:01:19,145 --> 00:01:20,705
go into the player,

35
00:01:20,705 --> 00:01:22,315
and we'll create in here

36
00:01:22,310 --> 00:01:24,860
a C-sharp script that's going to be

37
00:01:24,860 --> 00:01:30,870
the player health controller,

38
00:01:31,030 --> 00:01:34,610
or should have called Player health

39
00:01:34,610 --> 00:01:36,370
handler because it's not

40
00:01:36,365 --> 00:01:38,465
actually controlling the player health.

41
00:01:38,465 --> 00:01:40,015
It's handling.

42
00:01:40,010 --> 00:01:42,020
You know what? Let's go ahead and

43
00:01:42,020 --> 00:01:43,610
make it the full delete.

44
00:01:43,610 --> 00:01:47,510
This will create a layer health handler

45
00:01:47,510 --> 00:01:49,490
because it handles they have

46
00:01:49,490 --> 00:01:51,590
and it's not that big of a problem,

47
00:01:51,590 --> 00:01:57,110
but I always like to keep things their health handler.

48
00:01:57,110 --> 00:02:00,350
So because this handles the health of the player,

49
00:02:00,350 --> 00:02:02,710
don't actually control it in any way.

50
00:02:02,705 --> 00:02:05,995
So I'm going to add it to the doom layer

51
00:02:05,990 --> 00:02:09,490
and I'm going to apply all the changes.

52
00:02:09,485 --> 00:02:13,115
And I'm going to open up the player health handler.

53
00:02:13,115 --> 00:02:14,965
So what do we need here?

54
00:02:14,960 --> 00:02:17,210
Well, obviously, first thing we need is

55
00:02:17,210 --> 00:02:18,920
a serialized field which

56
00:02:18,920 --> 00:02:21,480
will represent the current health.

57
00:02:22,000 --> 00:02:25,240
And this is just for debugging purposes.

58
00:02:25,235 --> 00:02:26,615
Obviously, we don't want to be

59
00:02:26,615 --> 00:02:28,765
able to always see the current health.

60
00:02:28,760 --> 00:02:30,640
Then we are going to create

61
00:02:30,635 --> 00:02:33,625
a second variable which is the max health.

62
00:02:33,620 --> 00:02:36,140
And then start, we are going to instantiate

63
00:02:36,140 --> 00:02:39,290
the current health as the max health.

64
00:02:39,290 --> 00:02:41,350
So whenever we start a game,

65
00:02:41,345 --> 00:02:44,065
whenever our player papyrus or starts playing,

66
00:02:44,060 --> 00:02:47,110
we will have the current health as the max health.

67
00:02:47,105 --> 00:02:50,365
Now, the next step is to create a method that will

68
00:02:50,360 --> 00:02:53,810
actually handle taking damage by the enemies.

69
00:02:53,810 --> 00:02:56,240
And that's going to be part of your challenge.

70
00:02:56,235 --> 00:03:00,355
So your challenge is to create a method to take damage.

71
00:03:00,350 --> 00:03:03,530
So create a method that will damage the player.

72
00:03:03,530 --> 00:03:05,150
It should take a parameter,

73
00:03:05,149 --> 00:03:07,489
the damage amount determined what type

74
00:03:07,490 --> 00:03:10,850
the parameter should be inside the method.

75
00:03:10,850 --> 00:03:13,640
Remove the damage amount from the current health and

76
00:03:13,640 --> 00:03:17,420
check if the health is less than or equal to 0.

77
00:03:17,420 --> 00:03:19,670
We want to make the player inactive.

78
00:03:19,670 --> 00:03:22,640
So pause the video right now and go do

79
00:03:22,640 --> 00:03:26,300
the challenge. Welcome back.

80
00:03:26,300 --> 00:03:29,870
So I believe this was a pretty easy challenge.

81
00:03:29,870 --> 00:03:31,570
I don't think it was too hard.

82
00:03:31,565 --> 00:03:34,565
So I'm going to remove the update.

