1
00:00:00,110 --> 00:00:04,240
Welcome back, My favorite game developers.

2
00:00:04,244 --> 00:00:07,634
In this video, we are going to be making the layer,

3
00:00:07,635 --> 00:00:09,615
I mean the boss take damage.

4
00:00:09,615 --> 00:00:13,475
So when we run the game that's put on Skelly scroll down.

5
00:00:13,470 --> 00:00:15,590
You can see right now that he has

6
00:00:15,585 --> 00:00:19,115
a max boss health and a bus current health.

7
00:00:19,110 --> 00:00:21,830
So I should him once you'll notice he becomes four.

8
00:00:21,825 --> 00:00:23,255
Why does he become four?

9
00:00:23,250 --> 00:00:25,620
I mean, why does he become angry?

10
00:00:25,620 --> 00:00:27,560
Because halfway through his help,

11
00:00:27,555 --> 00:00:29,285
we are going to make him angry.

12
00:00:29,280 --> 00:00:30,630
So when his health as

13
00:00:30,630 --> 00:00:33,290
halfway he gets angry. We shoot him again.

14
00:00:33,285 --> 00:00:35,075
We should infer the last time.

15
00:00:35,070 --> 00:00:38,660
As you can see, he dies and he disappears and the end.

16
00:00:38,655 --> 00:00:44,025
So let's not waste any more time and Let's get started.

17
00:00:44,029 --> 00:00:45,979
Oh, case.

18
00:00:45,980 --> 00:00:49,640
So time to add a BRAF health to our boss.

19
00:00:49,640 --> 00:00:52,310
So let's go ahead and get started.

20
00:00:52,310 --> 00:00:55,000
The first thing that we are going to do

21
00:00:54,995 --> 00:00:58,645
is go from angry walking to dying.

22
00:00:58,640 --> 00:01:01,040
And we are going to go ahead and

23
00:01:01,040 --> 00:01:04,090
create a trigger in here called a die,

24
00:01:04,085 --> 00:01:07,715
and set the conditions in here to die.

25
00:01:07,715 --> 00:01:10,235
And then we are going to scroll down.

26
00:01:10,235 --> 00:01:13,895
And in here where we are walking to get angry,

27
00:01:13,895 --> 00:01:17,185
we're going to add a condition and set it as

28
00:01:17,180 --> 00:01:20,630
the get angry trigger 0 case.

29
00:01:20,630 --> 00:01:22,330
So with that out of the way,

30
00:01:22,325 --> 00:01:24,115
I think that's all that we had

31
00:01:24,110 --> 00:01:26,240
to set up before we get started.

32
00:01:26,240 --> 00:01:32,900
So I'm going to go inside of the boss script folder and

33
00:01:32,900 --> 00:01:36,160
right-click and create a new C Sharp script

34
00:01:36,155 --> 00:01:40,295
called the boss health handler.

35
00:01:40,295 --> 00:01:43,825
Hit Enter, wait for it to compile.

36
00:01:43,820 --> 00:01:47,210
And we'll drag it into these Kelly boss.

37
00:01:47,210 --> 00:01:48,800
Why are we doing it in here?

38
00:01:48,800 --> 00:01:52,070
Well, because dying is or the boss

39
00:01:52,070 --> 00:01:54,260
health handler or the entire health

40
00:01:54,260 --> 00:01:56,120
is part of the whole boss.

41
00:01:56,120 --> 00:01:59,320
It's not specified to a single state, just like we said,

42
00:01:59,315 --> 00:02:01,195
it's for the whole boss

43
00:02:01,190 --> 00:02:03,020
and it's going to be pretty simple.

44
00:02:03,020 --> 00:02:04,160
First of all, in here,

45
00:02:04,160 --> 00:02:06,560
I'm going to create a serialized field,

46
00:02:06,560 --> 00:02:09,640
which is going to be an integer and the boss,

47
00:02:09,635 --> 00:02:14,725
max health, and it's going to be equal to 500.

48
00:02:14,720 --> 00:02:18,760
And then we are going to create a public current health.

49
00:02:18,755 --> 00:02:21,235
And obviously we will change that later on.

50
00:02:21,230 --> 00:02:27,140
So boss, current health, save that.

51
00:02:27,140 --> 00:02:28,460
And then, and start.

52
00:02:28,460 --> 00:02:31,520
We're just going to say that the bosses current health is

53
00:02:31,520 --> 00:02:35,600
equal to the bosses max health.

54
00:02:35,600 --> 00:02:37,240
Correct?

55
00:02:37,235 --> 00:02:41,215
So now we need to create a method to allow

56
00:02:41,210 --> 00:02:45,110
us to give damage to our boss.

57
00:02:45,110 --> 00:02:47,440
So for that, I'm going to show it to you as

58
00:02:47,435 --> 00:02:49,885
a challenge because we've already done this.

59
00:02:49,880 --> 00:02:51,710
So make the boss take damage.

60
00:02:51,710 --> 00:02:53,120
First of all, you need to create

61
00:02:53,120 --> 00:02:56,050
the variable quality max health and the current health.

62
00:02:56,045 --> 00:02:59,155
Obviously, I did not prepare properly because

63
00:02:59,150 --> 00:03:02,410
I thought that you should have done this on your own.

64
00:03:02,405 --> 00:03:03,775
But there you go.

65
00:03:03,770 --> 00:03:07,640
An extra step from me either for you.

66
00:03:07,640 --> 00:03:09,650
Let's continue on and starts at

67
00:03:09,650 --> 00:03:12,770
the current health extra smart move by me,

68
00:03:12,770 --> 00:03:14,840
then create a method that allows

69
00:03:14,840 --> 00:03:17,980
the boss take damage based on a parameter.

70
00:03:17,975 --> 00:03:20,605
Finally, something new for you to do.

71
00:03:20,600 --> 00:03:24,050
When health is half the max health,

72
00:03:24,050 --> 00:03:27,620
we need to transition into the dying animation.

73
00:03:27,620 --> 00:03:29,360
Oops, I say dying.

74
00:03:29,360 --> 00:03:30,760
I meant to say,

75
00:03:30,755 --> 00:03:33,005
wait for the magic of editing.

76
00:03:33,005 --> 00:03:34,735
Hey, you Welcome back.

77
00:03:34,730 --> 00:03:36,470
So create a method that

78
00:03:36,470 --> 00:03:38,480
allows the boss to take damage when

79
00:03:38,480 --> 00:03:41,090
health is have the max health transition

80
00:03:41,090 --> 00:03:42,800
into the angry animation.

81
00:03:42,800 --> 00:03:46,970
So you know what to do when the heart is at 0,

82
00:03:46,970 --> 00:03:49,970
transition to the dying animation and finally

83
00:03:49,970 --> 00:03:53,230
destroy them both using an event system.

84
00:03:53,225 --> 00:03:55,615
So with all of that information,

85
00:03:55,610 --> 00:03:57,010
pause the video right now.

86
00:03:57,005 --> 00:03:59,615
Don't make any mistakes like me.

87
00:03:59,615 --> 00:04:03,165
And go ahead and do the challenge.

88
00:04:03,165 --> 00:04:05,355
Okay, welcome back.

89
00:04:05,350 --> 00:04:07,420
How did you get on with that?

90
00:04:07,420 --> 00:04:11,210
So in here I'm going to create a public void.

91
00:04:11,214 --> 00:04:14,804
The damage was an integer,

92
00:04:14,800 --> 00:04:19,630
the amount of damage.

93
00:04:19,630 --> 00:04:21,610
This is all pretty basic.

94
00:04:21,610 --> 00:04:24,310
I believe you already know how to do everything.

95
00:04:24,310 --> 00:04:26,530
So in here I'm going to say,

96
00:04:26,530 --> 00:04:30,100
I'm going to say that the bosses current health is

97
00:04:30,100 --> 00:04:34,380
minus equal the amount of damage.

98
00:04:34,375 --> 00:04:37,425
Then I'm going to say if the bosses current

99
00:04:37,420 --> 00:04:41,340
health as less than or equal to,

100
00:04:41,335 --> 00:04:45,755
less than or equal to the max boss health,

101
00:04:45,750 --> 00:04:49,190
bus, max health divided by two.

102
00:04:49,190 --> 00:04:52,240
So this means we are halfway into his health.

103
00:04:52,235 --> 00:04:57,455
Then we are going to get component, the animator.

104
00:04:57,455 --> 00:04:59,915
And he may talk.

105
00:04:59,915 --> 00:05:04,255
Thank you. And we are going to set the trigger.

106
00:05:04,250 --> 00:05:07,970
And we are going to get angry.

107
00:05:07,970 --> 00:05:11,690
So let's go into our animator and let's

108
00:05:11,690 --> 00:05:15,430
copy the get angry back in here.

109
00:05:15,425 --> 00:05:17,095
Paste it right here.

110
00:05:17,090 --> 00:05:19,570
There we go. So now we get angry.

111
00:05:19,565 --> 00:05:22,765
And then we are going to go ahead and say,

112
00:05:22,760 --> 00:05:30,220
if the boss current health is less than or equal to 0,

113
00:05:30,215 --> 00:05:34,555
then we are going to go ahead and do the same in here,

114
00:05:34,550 --> 00:05:36,050
but instead of getting angry,

115
00:05:36,050 --> 00:05:39,340
we are going to die.

116
00:05:39,335 --> 00:05:41,315
Excellent.

117
00:05:41,315 --> 00:05:48,935
So dy, so now we are going to create a method to die.

118
00:05:48,935 --> 00:05:52,775
So in here I'm going to say void,

119
00:05:52,775 --> 00:06:00,085
destroy, destroy the boss.

120
00:06:00,080 --> 00:06:03,320
And we are simply going to go ahead and

121
00:06:03,320 --> 00:06:06,850
destroy the game object.

122
00:06:06,845 --> 00:06:08,695
And where should we be calling this?

123
00:06:08,690 --> 00:06:11,250
Let's make this one public,

124
00:06:11,620 --> 00:06:16,360
just in case so we can access it from the event system.

125
00:06:16,355 --> 00:06:17,885
Whereas the event system,

126
00:06:17,885 --> 00:06:19,075
if I click on these,

127
00:06:19,070 --> 00:06:22,520
Kelly, we go to the animations, we die.

128
00:06:22,520 --> 00:06:24,140
What do we have in here?

129
00:06:24,140 --> 00:06:26,330
Let's see, in the scenes, there we go.

130
00:06:26,330 --> 00:06:30,830
So we, we have this puddle of ABA,

131
00:06:30,830 --> 00:06:32,560
no bone blood or something.

132
00:06:32,555 --> 00:06:35,985
And we should make this one a bit red obviously.

133
00:06:35,989 --> 00:06:37,669
And maybe at this point,

134
00:06:37,670 --> 00:06:39,290
just keep it a couple of seconds.

135
00:06:39,290 --> 00:06:42,140
And then we are going to add an event system.

136
00:06:42,140 --> 00:06:46,190
Or maybe we know what. Let's Move it to second two.

137
00:06:46,190 --> 00:06:50,140
And in here, we destroy the boss.

138
00:06:50,135 --> 00:06:52,375
So in the animation,

139
00:06:52,370 --> 00:06:56,500
we die and then we destroy the boss.

140
00:06:56,495 --> 00:06:58,445
Excellent, save all of that.

141
00:06:58,445 --> 00:07:00,305
Let's see what else do we have?

142
00:07:00,305 --> 00:07:02,005
Oh, so obviously we need to

143
00:07:02,000 --> 00:07:04,160
also trigger that take damage.

144
00:07:04,160 --> 00:07:06,080
Where do we call the trip take damage?

145
00:07:06,080 --> 00:07:11,240
Well, if we go into the layer, have bullet.

146
00:07:11,240 --> 00:07:15,920
If I open this up and find the player,

147
00:07:15,920 --> 00:07:17,920
then I say Player health bullet.

148
00:07:17,915 --> 00:07:20,965
I meant the player bullet controller. In here.

149
00:07:20,960 --> 00:07:24,440
We are going to check if we have the enemy,

150
00:07:24,440 --> 00:07:26,740
then we are going to damage the enemy.

151
00:07:26,735 --> 00:07:29,765
Let's see, do we have a layer for the boss?

152
00:07:29,764 --> 00:07:32,724
We don't have a lawyer for the boss,

153
00:07:32,720 --> 00:07:34,840
so let's go ahead and edit the layers.

154
00:07:34,835 --> 00:07:37,565
Create a boss layer,

155
00:07:37,565 --> 00:07:39,355
or you can create a boss tag.

156
00:07:39,350 --> 00:07:41,200
That's also something we can do.

157
00:07:41,195 --> 00:07:43,405
Or maybe we do have a boss tag note

158
00:07:43,400 --> 00:07:44,540
we don't have Abel's dark,

159
00:07:44,540 --> 00:07:46,270
so let's go ahead and edit.

160
00:07:46,265 --> 00:07:50,035
Create a tags.

161
00:07:50,030 --> 00:07:52,720
Boss DAG.

162
00:07:52,715 --> 00:07:57,905
There we go. So now if we go in here, so now,

163
00:07:57,904 --> 00:08:00,834
now this is the perfect example for you to

164
00:08:00,830 --> 00:08:04,330
understand the difference between a tag and a layer.

165
00:08:04,325 --> 00:08:06,365
So remember where.

166
00:08:06,364 --> 00:08:08,304
Okay, So I don't even remember

167
00:08:08,300 --> 00:08:10,040
maybe in the spikes in here,

168
00:08:10,040 --> 00:08:12,170
I told you that we can avoid

169
00:08:12,170 --> 00:08:14,570
using the compare tag player.

170
00:08:14,570 --> 00:08:17,060
We can immediately say that spikes

171
00:08:17,060 --> 00:08:19,940
are some kind of damage layer,

172
00:08:19,940 --> 00:08:23,020
so they are on the Do we have anything,

173
00:08:23,015 --> 00:08:25,345
the pickups or anythings,

174
00:08:25,340 --> 00:08:26,620
for example, the backups.

175
00:08:26,615 --> 00:08:29,225
So we can avoid using

176
00:08:29,225 --> 00:08:34,165
the a tag to compare it to the player,

177
00:08:34,160 --> 00:08:37,190
for example, to make sure that only the layer carries it.

178
00:08:37,190 --> 00:08:38,690
So only the player can

179
00:08:38,690 --> 00:08:40,760
interact with the pickups through layers.

180
00:08:40,760 --> 00:08:42,160
We don't need to check for

181
00:08:42,155 --> 00:08:44,585
a compared tag on the entrepreneur.

182
00:08:44,585 --> 00:08:46,645
Enter. Remember I talked about this,

183
00:08:46,640 --> 00:08:50,410
but now in the a bullet controller,

184
00:08:50,405 --> 00:08:53,705
we can say that the bullet only interact with the boss,

185
00:08:53,705 --> 00:08:55,165
but that is not enough

186
00:08:55,160 --> 00:08:58,340
because we want to also check else.

187
00:08:58,340 --> 00:09:04,690
If there is a collision.com tag with a boss,

188
00:09:04,685 --> 00:09:05,965
then we need to call

189
00:09:05,960 --> 00:09:08,140
a totally different component

190
00:09:08,135 --> 00:09:10,375
or totally different yes, component.

191
00:09:10,370 --> 00:09:11,620
So back in here,

192
00:09:11,615 --> 00:09:13,615
let's see, is the syllabus.

193
00:09:13,610 --> 00:09:17,450
Oh, we didn't create the tag sorting layer.

194
00:09:17,450 --> 00:09:20,540
No, no. Why do we have to sorting layers for the boss?

195
00:09:20,540 --> 00:09:24,970
The tag is so boss. Copy that.

196
00:09:24,965 --> 00:09:26,815
So now we have no sorry,

197
00:09:26,810 --> 00:09:29,110
we need to set the boss tag.

198
00:09:29,105 --> 00:09:30,445
There we go. We save that.

199
00:09:30,440 --> 00:09:32,090
Now back in our game,

200
00:09:32,090 --> 00:09:34,120
we check for the boss.

201
00:09:34,115 --> 00:09:35,375
And if it is the boss,

202
00:09:35,375 --> 00:09:38,155
then we are going to go ahead and get

203
00:09:38,150 --> 00:09:41,450
the collision that get component,

204
00:09:41,450 --> 00:09:45,200
the boss health handler.

205
00:09:45,200 --> 00:09:48,680
And from here we are going to take damage and

206
00:09:48,680 --> 00:09:52,160
it's going to be the bullet speed.

207
00:09:52,160 --> 00:09:53,830
Nope, the damage amount.

208
00:09:53,825 --> 00:09:57,745
So damage amount, save that.

209
00:09:57,740 --> 00:09:59,570
Now we have everything set up,

210
00:09:59,570 --> 00:10:01,970
so I'm really happy that this came up.

211
00:10:01,970 --> 00:10:04,250
This is a way for you to demonstrate.

212
00:10:04,250 --> 00:10:08,360
We could have said that the we have a bullet layer,

213
00:10:08,360 --> 00:10:09,740
a player bullet layer,

214
00:10:09,740 --> 00:10:13,600
and it only interacts with the boss and the enemy.

215
00:10:13,595 --> 00:10:15,775
But if we hit an enemy,

216
00:10:15,770 --> 00:10:18,130
the boss isn't just any enemy.

217
00:10:18,125 --> 00:10:21,185
He is also a boss health handler.

218
00:10:21,185 --> 00:10:24,605
So we'll need to access the health and the boss.

219
00:10:24,605 --> 00:10:27,445
If we tried to use this one, it will not work.

220
00:10:27,440 --> 00:10:29,210
It will cause an error so well

221
00:10:29,210 --> 00:10:31,100
that although the way save that,

222
00:10:31,100 --> 00:10:33,230
you can also go ahead and copy

223
00:10:33,230 --> 00:10:35,990
these two lines and we can set them in here.

224
00:10:35,990 --> 00:10:38,060
So obviously this is redundant code.

225
00:10:38,060 --> 00:10:39,230
So what we can do is

226
00:10:39,230 --> 00:10:42,170
right-click and here quick actions and

227
00:10:42,170 --> 00:10:46,510
refactoring and we can say create blood effect,

228
00:10:46,505 --> 00:10:56,065
extract the method, call it instantiate blood effect.

229
00:10:56,065 --> 00:11:01,845
And I write instantiate correctly is Dan Shi Da.

230
00:11:01,840 --> 00:11:03,580
Yep, there we go.

231
00:11:03,580 --> 00:11:07,470
Apply the changes and in here we are going to

232
00:11:07,465 --> 00:11:13,495
instantiate the blood effect. Save that.

233
00:11:13,495 --> 00:11:14,985
So now back in,

234
00:11:14,980 --> 00:11:18,190
our game shouldn't be working perfectly.

235
00:11:18,189 --> 00:11:19,819
So if I click on this caliber,

236
00:11:19,815 --> 00:11:24,235
scroll down and the boss Mac South, Let's make it 20.

237
00:11:24,235 --> 00:11:27,075
Uh, no, no, not 20, maybe 40,

238
00:11:27,070 --> 00:11:28,660
just so we can see the transitions

239
00:11:28,659 --> 00:11:31,739
properly. We run the game.

240
00:11:31,735 --> 00:11:34,135
So now the boss comes up.

241
00:11:34,135 --> 00:11:35,955
We shoot him once, and I don't want to

242
00:11:35,950 --> 00:11:38,400
maximize on play on again.

243
00:11:38,395 --> 00:11:41,935
Who should the boss? Where Z?

244
00:11:41,935 --> 00:11:43,405
So we should the boss.

245
00:11:43,405 --> 00:11:44,715
Let's scroll down.

246
00:11:44,710 --> 00:11:48,310
What is his health current health wise, the books.

247
00:11:48,310 --> 00:11:51,640
So such a new bullet.

248
00:11:51,640 --> 00:11:54,760
And okay, so this error is nothing also

249
00:11:54,760 --> 00:11:58,210
because the crystal has some kind of damage.

250
00:11:58,210 --> 00:12:01,740
Okay, so I'm going to make this four instead of 40.

251
00:12:01,735 --> 00:12:05,245
Know what, Let's make it eight. Run the game.

252
00:12:05,245 --> 00:12:06,915
The system is very poor,

253
00:12:06,910 --> 00:12:08,050
so we should at once,

254
00:12:08,050 --> 00:12:09,220
there we go, we scroll down,

255
00:12:09,220 --> 00:12:11,190
it's at six. We should, uh, twice.

256
00:12:11,185 --> 00:12:12,735
There we go. We can see that he gets

257
00:12:12,730 --> 00:12:16,010
angry and now he starts running much faster.

258
00:12:16,010 --> 00:12:17,480
So we shoot him again.

259
00:12:17,480 --> 00:12:20,180
We should him for the last time. And there we go.

260
00:12:20,180 --> 00:12:23,740
He goes into the bottle and he dies.

261
00:12:23,735 --> 00:12:27,035
But there is something a bit wrong but I did not,

262
00:12:27,035 --> 00:12:30,175
like you might have not seen it because I didn't do it.

263
00:12:30,170 --> 00:12:31,700
But when we shoot him once,

264
00:12:31,700 --> 00:12:33,610
shoot him twice, he is getting angry.

265
00:12:33,605 --> 00:12:35,365
I can still shoot him.

266
00:12:35,360 --> 00:12:38,840
And there you go. You can see that he still gets

267
00:12:38,840 --> 00:12:40,640
shot and dies immediately

268
00:12:40,639 --> 00:12:42,729
after he transitions to the walking.

269
00:12:42,725 --> 00:12:44,485
So in the next video,

270
00:12:44,480 --> 00:12:46,460
we are going to make sure that he is

271
00:12:46,460 --> 00:12:49,730
invincible while he is getting angry.

272
00:12:49,730 --> 00:12:51,910
And just for the sake of remembering,

273
00:12:51,905 --> 00:12:56,435
I'm going to add a comment in here and make,

274
00:12:56,434 --> 00:12:59,494
you know what, let's immediately right.

275
00:12:59,495 --> 00:13:06,785
If getting angry, this should not work.

276
00:13:06,785 --> 00:13:09,115
And this is just a demonstration of how

277
00:13:09,110 --> 00:13:12,040
sometimes you might want to add something in the future,

278
00:13:12,035 --> 00:13:13,385
just so you don't forget it.

279
00:13:13,385 --> 00:13:15,355
Add a comment, make sure it works.

280
00:13:15,350 --> 00:13:16,390
I hope you enjoyed.

281
00:13:16,385 --> 00:13:18,995
This was a really nice video it thought as

282
00:13:18,995 --> 00:13:20,755
the important lesson of

283
00:13:20,750 --> 00:13:22,960
the difference between tags and layers,

284
00:13:22,955 --> 00:13:25,295
because sometimes it's hard to explain,

285
00:13:25,295 --> 00:13:28,205
but this was the perfect place to learn it.

286
00:13:28,205 --> 00:13:29,545
So I hope you enjoy it.

287
00:13:29,540 --> 00:13:31,850
I hope you are committing your changes and

288
00:13:31,850 --> 00:13:35,160
I'll see you in the next one.

