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

2
00:00:03,570 --> 00:00:05,340
In this video, as you can see,

3
00:00:05,340 --> 00:00:06,920
we've added a little image,

4
00:00:06,915 --> 00:00:08,535
we've added a bit of text,

5
00:00:08,535 --> 00:00:10,865
and we've added a big health bar

6
00:00:10,860 --> 00:00:13,080
to represent the health of our boss.

7
00:00:13,080 --> 00:00:14,970
So now when we run the game,

8
00:00:14,970 --> 00:00:16,950
when the boss appears, we shoot him.

9
00:00:16,950 --> 00:00:18,980
You can see that his life depletes.

10
00:00:18,975 --> 00:00:20,825
When we shoot him again, he's angry.

11
00:00:20,820 --> 00:00:22,650
And if we shoot him while he's angry,

12
00:00:22,650 --> 00:00:24,870
you'll notice that he cannot take any damage.

13
00:00:24,870 --> 00:00:26,460
And this is a mechanic of

14
00:00:26,460 --> 00:00:28,880
every boss and every single game.

15
00:00:28,875 --> 00:00:30,735
So I shoot him again, I showed him again,

16
00:00:30,735 --> 00:00:34,445
the Health Bot disappears, the boss dies.

17
00:00:34,440 --> 00:00:38,010
And let's not waste any more time with a very long video,

18
00:00:38,010 --> 00:00:40,420
but leave me, it's important,

19
00:00:40,415 --> 00:00:42,925
and this is what happens when we are creating your eyes.

20
00:00:42,920 --> 00:00:45,680
So let's get started.

21
00:00:45,680 --> 00:00:51,190
Okay, so now we have everything working kind of good.

22
00:00:51,185 --> 00:00:53,885
We are able to damage the boss.

23
00:00:53,885 --> 00:00:55,645
We are able to kill him,

24
00:00:55,640 --> 00:00:57,320
we are able to remove him,

25
00:00:57,320 --> 00:01:01,900
but we do not have any clue of where his health is add.

26
00:01:01,895 --> 00:01:04,105
So what we're going to do is we're going to

27
00:01:04,100 --> 00:01:06,950
create a helper for the boss.

28
00:01:06,950 --> 00:01:09,410
So I'm going to go up in here.

29
00:01:09,410 --> 00:01:11,960
And in this video actually,

30
00:01:11,960 --> 00:01:15,620
I think there is something you can choose for yourself.

31
00:01:15,620 --> 00:01:17,150
So there are two types of

32
00:01:17,150 --> 00:01:19,340
health bars that you can add to the boss.

33
00:01:19,340 --> 00:01:21,260
One of them will be, for example,

34
00:01:21,260 --> 00:01:22,540
if you want the Health Bar to

35
00:01:22,535 --> 00:01:24,515
always be moving with the boss.

36
00:01:24,515 --> 00:01:29,125
But I personally think that is not the best idea because

37
00:01:29,120 --> 00:01:30,290
you'd want to have

38
00:01:30,290 --> 00:01:32,360
your regular enemies have

39
00:01:32,360 --> 00:01:34,210
that health bar on top of their heads.

40
00:01:34,205 --> 00:01:38,165
So maybe having a boss health bar

41
00:01:38,165 --> 00:01:40,855
is better to be kind of like Dark Souls,

42
00:01:40,850 --> 00:01:43,540
either be on the bottom or at the top.

43
00:01:43,535 --> 00:01:47,045
And because we already have the health and the money

44
00:01:47,045 --> 00:01:50,575
and the weapons on the bottom to display for the player.

45
00:01:50,570 --> 00:01:53,230
Then I'm going to create it up here at the top.

46
00:01:53,225 --> 00:01:55,915
So I'm going to open up the UI canvas.

47
00:01:55,910 --> 00:01:57,760
I'm going to open up the health,

48
00:01:57,755 --> 00:02:00,325
I'm going to get the health slider.

49
00:02:00,320 --> 00:02:02,540
And the, we know what cuts

50
00:02:02,540 --> 00:02:04,870
not used the health effects for the boss.

51
00:02:04,865 --> 00:02:06,955
I'm going to duplicate it.

52
00:02:06,950 --> 00:02:09,620
And I'm going to move it outside.

53
00:02:09,620 --> 00:02:11,090
And I'll need to open

54
00:02:11,090 --> 00:02:15,560
the prefabs and I'll need to move the, where is it?

55
00:02:15,560 --> 00:02:19,990
Health, slider and outside right here.

56
00:02:19,985 --> 00:02:22,165
Save that back into our game.

57
00:02:22,160 --> 00:02:25,400
Now we have a health slider 1,

58
00:02:25,400 --> 00:02:29,990
which is also an I by accident.

59
00:02:29,990 --> 00:02:33,890
Remove the actual have slider yep. Open brief up.

60
00:02:33,890 --> 00:02:36,230
So sorry for that.

61
00:02:36,230 --> 00:02:38,570
Should have moved the other health slider.

62
00:02:38,570 --> 00:02:40,870
So there we go. This one is in here.

63
00:02:40,865 --> 00:02:44,125
And then I'm going to duplicate this one.

64
00:02:44,120 --> 00:02:48,190
And I'm going to move this one outside of the canvas.

65
00:02:48,185 --> 00:02:50,875
And the one that we have greater than here,

66
00:02:50,870 --> 00:02:52,700
we can simply delete.

67
00:02:52,700 --> 00:02:55,340
So where is the health slider?

68
00:02:55,340 --> 00:02:57,400
There we go. This is the one that we need.

69
00:02:57,395 --> 00:02:59,305
Let's see, move this up.

70
00:02:59,300 --> 00:03:01,270
This will be the boss.

71
00:03:01,265 --> 00:03:03,535
Have slider.

72
00:03:03,970 --> 00:03:08,900
There we go. And I'm just going to go ahead and

73
00:03:08,900 --> 00:03:12,430
maybe create an empty game object

74
00:03:12,425 --> 00:03:15,595
right on here, set it outside.

75
00:03:15,590 --> 00:03:17,210
So the boss slide,

76
00:03:17,210 --> 00:03:25,160
I know this game object to the campus.

77
00:03:25,155 --> 00:03:28,225
False health.

78
00:03:28,225 --> 00:03:34,015
And then add the boss have slider under the boss health.

79
00:03:34,015 --> 00:03:37,035
So this is very annoying whenever you have a prefab

80
00:03:37,030 --> 00:03:40,420
by new want to change it, it's extremely annoying.

81
00:03:40,420 --> 00:03:43,690
So even if I move this one,

82
00:03:43,690 --> 00:03:45,400
I still need to change it right here.

83
00:03:45,400 --> 00:03:47,890
So US health,

84
00:03:47,890 --> 00:03:54,730
slider and then the UI canvas and empty game object,

85
00:03:54,730 --> 00:03:58,420
which is the boss health.

86
00:03:58,420 --> 00:04:00,580
Whereas the boss have.

87
00:04:00,580 --> 00:04:04,950
And let's move the slider to the boss Health.

88
00:04:04,945 --> 00:04:08,735
And let's set the position to be at 0,

89
00:04:08,735 --> 00:04:11,065
0. And there we go.

90
00:04:11,060 --> 00:04:13,060
So now we have the boss slider.

91
00:04:13,055 --> 00:04:15,235
We are working in the prefab.

92
00:04:15,230 --> 00:04:19,600
So in here I also want to make this a bit bigger.

93
00:04:19,595 --> 00:04:23,545
So if I zoom in and let's see what we have in here.

94
00:04:23,540 --> 00:04:26,320
Make this bigger on the side.

95
00:04:26,315 --> 00:04:28,495
Make this bigger on the site.

96
00:04:28,490 --> 00:04:29,770
Also.

97
00:04:29,765 --> 00:04:32,035
Move it up a bit.

98
00:04:32,030 --> 00:04:34,970
And I'm just going to go ahead.

99
00:04:34,970 --> 00:04:39,520
And if you want,

100
00:04:39,515 --> 00:04:41,525
you can go ahead and do it yourself.

101
00:04:41,525 --> 00:04:43,465
Fill in everything.

102
00:04:43,460 --> 00:04:46,820
Let's see all the little adjustments.

103
00:04:46,820 --> 00:04:48,140
This will take a bit of fine

104
00:04:48,140 --> 00:04:49,660
whenever you are, I think you are.

105
00:04:49,655 --> 00:04:52,285
This is why the videos where we have you

106
00:04:52,280 --> 00:04:55,460
are are longer than usual.

107
00:04:55,460 --> 00:04:58,510
So there we go. I think this is good enough.

108
00:04:58,505 --> 00:05:00,785
Yep, seems good to me.

109
00:05:00,785 --> 00:05:03,685
And finally, I want to add a bit of an image.

110
00:05:03,680 --> 00:05:08,800
So I'm going to go into UI image.

111
00:05:08,795 --> 00:05:15,995
And this image will have the boss image.

112
00:05:15,995 --> 00:05:19,085
And we can also add in here the boss name.

113
00:05:19,085 --> 00:05:23,275
So I'm going to add a text Mesh probe.

114
00:05:23,270 --> 00:05:27,750
And this will be Kelly.

115
00:05:27,750 --> 00:05:31,050
Make it bold, make it in the middle.

116
00:05:31,045 --> 00:05:34,765
Make it bold, make it a robotic.

117
00:05:34,765 --> 00:05:38,155
And let's No, no, no.

118
00:05:38,250 --> 00:05:40,840
And let's maybe move it.

119
00:05:40,840 --> 00:05:42,730
You either under or over.

120
00:05:42,730 --> 00:05:46,780
It doesn't matter. Choose your own way of creating this.

121
00:05:46,780 --> 00:05:49,390
I'll make it auto size. And there we go.

122
00:05:49,390 --> 00:05:52,330
So Kelly, there we go,

123
00:05:52,330 --> 00:05:55,800
Skelly and here the image will represent the boss.

124
00:05:55,795 --> 00:05:59,385
So I'm going to find in the sprites,

125
00:05:59,380 --> 00:06:05,050
the z, whereas these candy bars, there we go.

126
00:06:05,050 --> 00:06:13,000
So image, Skelly and native set to native size.

127
00:06:12,995 --> 00:06:15,335
Let's preserve aspect ratio.

128
00:06:15,335 --> 00:06:19,245
And let's make it look much, much smaller.

129
00:06:19,249 --> 00:06:21,919
And maybe set it in here and know what,

130
00:06:21,920 --> 00:06:24,050
maybe this is not the best way to do this.

131
00:06:24,050 --> 00:06:28,160
Maybe you can just keep the head so you know what,

132
00:06:28,160 --> 00:06:29,900
let me just delete

133
00:06:29,900 --> 00:06:36,640
this or wait a second and I'm going to edit this photo.

134
00:06:36,635 --> 00:06:38,455
Okay, welcome back.

135
00:06:38,450 --> 00:06:41,780
So all that I did is just edit this photo and you'll

136
00:06:41,780 --> 00:06:45,380
probably have it in your resources.

137
00:06:45,380 --> 00:06:47,080
So I'm going to add it in here.

138
00:06:47,075 --> 00:06:50,095
And the buses image will be the skeleton had.

139
00:06:50,090 --> 00:06:52,180
So there we go. Now we have this.

140
00:06:52,175 --> 00:06:54,065
I know this is not much,

141
00:06:54,065 --> 00:06:56,695
it doesn't really make the game much better,

142
00:06:56,690 --> 00:06:59,190
but it just adds a bit of finance.

143
00:06:59,194 --> 00:07:01,984
So you know that this health bar belongs to

144
00:07:01,985 --> 00:07:05,555
the Skelly boss and you have a small image of his head.

145
00:07:05,555 --> 00:07:07,765
So now we have a good representation.

146
00:07:07,760 --> 00:07:10,400
So now if I go back from the

147
00:07:10,400 --> 00:07:14,200
prefab and for some reason it's not in its place.

148
00:07:14,195 --> 00:07:15,715
We have the boss health.

149
00:07:15,710 --> 00:07:17,380
Let's just delete this.

150
00:07:17,375 --> 00:07:19,025
Keep this both health.

151
00:07:19,025 --> 00:07:23,225
And for some reason it wasn't in its place.

152
00:07:23,225 --> 00:07:28,345
I'm going to go Slider and set the position 0, 0.

153
00:07:28,340 --> 00:07:30,590
And now we have it properly.

154
00:07:30,590 --> 00:07:34,060
And let's adjust the position a bit. And there we go.

155
00:07:34,055 --> 00:07:36,785
Now we have the boths.

156
00:07:36,785 --> 00:07:38,285
Skelly health.

157
00:07:38,285 --> 00:07:40,165
Let's just move it a bit to the left.

158
00:07:40,160 --> 00:07:42,620
And I think it's pretty good right now.

159
00:07:42,620 --> 00:07:46,400
So this is the help we can see on the boss if you want.

160
00:07:46,400 --> 00:07:49,660
We can also change the image of the fill.

161
00:07:49,655 --> 00:07:52,165
So I don't want it to be red.

162
00:07:52,160 --> 00:07:56,260
Maybe I want it to have it in the sprites.

163
00:07:56,255 --> 00:07:56,965
Let's see.

164
00:07:56,960 --> 00:07:59,320
You have your eye.

165
00:07:59,315 --> 00:08:02,045
You are you, are you I elements.

166
00:08:02,045 --> 00:08:03,275
I was pressing the EU,

167
00:08:03,275 --> 00:08:04,385
but I did not get that.

168
00:08:04,385 --> 00:08:06,085
Okay, so I'm going to go into

169
00:08:06,080 --> 00:08:11,650
the UI elements and get the blue one.

170
00:08:11,645 --> 00:08:14,795
So we'll use the blue one.

171
00:08:15,400 --> 00:08:17,680
Image.

172
00:08:17,675 --> 00:08:19,465
The blue, no, no, no, no,

173
00:08:19,460 --> 00:08:22,480
not this one. Fill area.

174
00:08:22,475 --> 00:08:25,675
The fill the blue slider. Okay.

175
00:08:25,670 --> 00:08:30,540
So now we have the blue slider moving up and down.

176
00:08:30,880 --> 00:08:35,420
And as I've said, this whole section or this whole video,

177
00:08:35,420 --> 00:08:37,370
you need to do your own research.

178
00:08:37,370 --> 00:08:39,640
You need to create your own UI,

179
00:08:39,635 --> 00:08:42,505
and you need to do things the way you would like

180
00:08:42,500 --> 00:08:44,190
them to be.

181
00:08:57,490 --> 00:08:59,270
Oh, okay.

182
00:08:59,270 --> 00:09:03,410
So I think this is good enough.

183
00:09:03,410 --> 00:09:07,800
I'm not sure if it is good enough.

184
00:09:09,190 --> 00:09:15,110
And there is a bit of the edges are not very smooth,

185
00:09:15,110 --> 00:09:16,880
but no worries about that as long as

186
00:09:16,880 --> 00:09:18,950
it represents things properly.

187
00:09:18,950 --> 00:09:20,200
So now we have the health.

188
00:09:20,195 --> 00:09:23,465
The next thing we need to do is to have control over.

189
00:09:23,465 --> 00:09:25,835
So I'm going to go into the bosses health,

190
00:09:25,835 --> 00:09:28,375
I'm going to go into the script.

191
00:09:28,370 --> 00:09:34,570
And in the UI or nano actually in the boss.

192
00:09:34,565 --> 00:09:35,185
There we go.

193
00:09:35,180 --> 00:09:38,210
Right-click create C-sharp script,

194
00:09:38,210 --> 00:09:43,570
and this will be the boss Health Bar at Enter.

195
00:09:43,565 --> 00:09:45,675
Wait for it to compile.

196
00:09:45,679 --> 00:09:50,479
And any day now we have

197
00:09:50,480 --> 00:09:52,790
the boss helpless add it to the boss health in

198
00:09:52,790 --> 00:09:55,750
here that's opened up the boss Health Bar.

199
00:09:55,745 --> 00:09:57,445
And what do we need to have in here?

200
00:09:57,440 --> 00:10:00,290
Well, obviously we want a reference to the slider.

201
00:10:00,289 --> 00:10:03,529
So serialized field slider,

202
00:10:03,530 --> 00:10:06,880
we need to have a UI engine,

203
00:10:06,875 --> 00:10:09,275
Unity engine dot u i.

204
00:10:09,275 --> 00:10:12,115
So now we can have the slider,

205
00:10:12,110 --> 00:10:18,440
then we have the boss health slider set then in here.

206
00:10:18,440 --> 00:10:21,230
So the first thing we do as soon as we start as

207
00:10:21,230 --> 00:10:24,320
we need to set the max value, obviously.

208
00:10:24,320 --> 00:10:27,980
So the boss have

209
00:10:27,980 --> 00:10:34,020
slider dot max value is equal to find objects of type.

210
00:10:34,030 --> 00:10:38,990
And it's going to be the boss health handler.

211
00:10:38,990 --> 00:10:40,760
And from the boss health handler,

212
00:10:40,760 --> 00:10:42,620
we need to get the max health.

213
00:10:42,620 --> 00:10:45,610
So we're going to go into the boss health handler.

214
00:10:45,605 --> 00:10:48,745
And in here create a small method which

215
00:10:48,740 --> 00:10:52,090
is going to be a public int.

216
00:10:52,085 --> 00:10:59,755
Get max health, or get boss max health.

217
00:10:59,750 --> 00:11:04,820
Open up the brackets, return Max, have.

218
00:11:04,820 --> 00:11:08,090
We go save that. Back in here.

219
00:11:08,090 --> 00:11:11,230
Get boss, max, health.

220
00:11:11,225 --> 00:11:12,385
We save that.

221
00:11:12,380 --> 00:11:14,810
Now we're going to slide into the Update,

222
00:11:14,810 --> 00:11:16,880
get it slide because we are using

223
00:11:16,880 --> 00:11:19,250
a slider or how often waiting on a slider.

224
00:11:19,250 --> 00:11:20,890
So an update we are going to

225
00:11:20,885 --> 00:11:23,335
all the time get the hub loss have

226
00:11:23,330 --> 00:11:25,970
slider dot value and it's going

227
00:11:25,970 --> 00:11:29,170
to be equal to find objects of type,

228
00:11:29,165 --> 00:11:32,705
health handler, boss, health handler.

229
00:11:32,705 --> 00:11:36,365
And we are going to get the current.

230
00:11:36,365 --> 00:11:38,755
So I'm going to duplicate this one.

231
00:11:38,750 --> 00:11:43,410
Get boss, current health,

232
00:11:43,510 --> 00:11:46,280
current health, save that.

233
00:11:46,280 --> 00:11:49,700
So this is just a return method of integer.

234
00:11:49,700 --> 00:11:51,230
Nothing too complicated.

235
00:11:51,230 --> 00:11:55,310
So get boss current health all the time.

236
00:11:55,310 --> 00:11:58,400
And now let's go ahead and assign the slider.

237
00:11:58,400 --> 00:12:00,800
So open this up.

238
00:12:00,800 --> 00:12:04,910
The slider and work is the slider.

239
00:12:04,910 --> 00:12:07,540
This one is the sliders save all of that.

240
00:12:07,535 --> 00:12:11,945
Let's make this a bit bigger, run the game.

241
00:12:12,190 --> 00:12:15,040
So now we should see

242
00:12:15,035 --> 00:12:17,285
the health slider move

243
00:12:17,285 --> 00:12:20,035
the enemies both so you shoot him. There we go.

244
00:12:20,030 --> 00:12:21,170
So as you can see,

245
00:12:21,170 --> 00:12:23,690
his health gets smaller and he gets

246
00:12:23,690 --> 00:12:27,200
angry right about the halfway point of our game.

247
00:12:27,200 --> 00:12:31,030
Finally, when we shoot them for the last time, he dies.

248
00:12:31,025 --> 00:12:33,155
But we still have this health bark.

249
00:12:33,155 --> 00:12:34,495
And not only that, we have

250
00:12:34,490 --> 00:12:36,560
this small error appearing in here,

251
00:12:36,560 --> 00:12:40,070
well actually not a small error, a constant error.

252
00:12:40,070 --> 00:12:41,630
So I'm going to collapse it.

253
00:12:41,630 --> 00:12:44,780
Double-click in here and see what the problem is.

254
00:12:44,780 --> 00:12:46,730
Find objects of type.

255
00:12:46,730 --> 00:12:48,710
So this is a null reference.

256
00:12:48,709 --> 00:12:50,239
Null reference means that we are

257
00:12:50,240 --> 00:12:51,950
trying to get a reference to

258
00:12:51,950 --> 00:12:56,000
something that does not exist or the return is not.

259
00:12:56,000 --> 00:12:59,230
So in here we have the boss health handler.

260
00:12:59,225 --> 00:13:01,135
And obviously when we die,

261
00:13:01,130 --> 00:13:02,870
we destroy the boss.

262
00:13:02,870 --> 00:13:04,400
And when we destroy the boss,

263
00:13:04,400 --> 00:13:06,740
the boss health handler goals William.

264
00:13:06,740 --> 00:13:10,330
So we need to find a solution to that,

265
00:13:10,325 --> 00:13:12,905
and that is going to be your challenge.

266
00:13:12,905 --> 00:13:14,605
Your challenge is to remove

267
00:13:14,600 --> 00:13:17,770
the Health Bar and make the boss invincible.

268
00:13:17,765 --> 00:13:20,765
Maybe your challenge isn't to fix the error.

269
00:13:20,765 --> 00:13:23,005
Anyways, let's see what we have in here.

270
00:13:23,000 --> 00:13:24,950
First of all, when the boss dies,

271
00:13:24,950 --> 00:13:26,480
make sure that the health bar is

272
00:13:26,480 --> 00:13:28,430
removed and stop the error.

273
00:13:28,430 --> 00:13:30,560
You'll need to obviously remove

274
00:13:30,560 --> 00:13:33,560
the Health Bar and remove the image and the picture.

275
00:13:33,560 --> 00:13:35,210
So we don't no longer have to

276
00:13:35,210 --> 00:13:36,830
call that every single time.

277
00:13:36,830 --> 00:13:39,290
Then you'll need to make sure that when

278
00:13:39,290 --> 00:13:42,080
the bus is going into the angry state,

279
00:13:42,080 --> 00:13:44,330
we want to make him invincible.

280
00:13:44,330 --> 00:13:46,250
So when he is getting angry,

281
00:13:46,250 --> 00:13:48,320
we don't want to be able to shoot him.

282
00:13:48,320 --> 00:13:49,610
This is first of all, not

283
00:13:49,610 --> 00:13:51,140
fair to the boss because he cannot

284
00:13:51,140 --> 00:13:54,200
attack us or move when he is getting angry.

285
00:13:54,200 --> 00:13:56,630
Second of all, because in every single game

286
00:13:56,630 --> 00:13:59,420
when a boss transitions into the second phase,

287
00:13:59,420 --> 00:14:00,890
you cannot hit him.

288
00:14:00,890 --> 00:14:03,350
This is something standard and all games.

289
00:14:03,350 --> 00:14:05,030
So I'm going to give you a hint

290
00:14:05,030 --> 00:14:06,800
of how to do the last part.

291
00:14:06,800 --> 00:14:10,610
You'll need to add behavior to the get anger state.

292
00:14:10,610 --> 00:14:11,990
And as I told you,

293
00:14:11,990 --> 00:14:14,150
we need to fix the problem of the error.

294
00:14:14,150 --> 00:14:18,770
While obviously when we actually disable the half bark

295
00:14:18,770 --> 00:14:20,570
at no longer calls for

296
00:14:20,570 --> 00:14:23,600
the players held the bosses health handler,

297
00:14:23,600 --> 00:14:25,480
so we no longer have the arrow.

298
00:14:25,475 --> 00:14:27,245
So with that information,

299
00:14:27,245 --> 00:14:31,505
pause the video right now and go do the challenge.

300
00:14:31,505 --> 00:14:34,255
So, okay, welcome back.

301
00:14:34,250 --> 00:14:36,890
So the first thing that we're going to do

302
00:14:36,890 --> 00:14:41,210
is we're going to go into the update and here.

303
00:14:41,210 --> 00:14:44,000
And we're going to check if

304
00:14:44,000 --> 00:14:49,100
the boss health slider dot value

305
00:14:49,100 --> 00:14:53,040
is less than or equal to 0,

306
00:14:53,040 --> 00:14:55,270
that means that we are going to

307
00:14:55,270 --> 00:14:59,260
destroy the entire game object.

308
00:14:59,260 --> 00:15:01,900
Now we, we don't have to destroy the game object.

309
00:15:01,900 --> 00:15:04,960
We can maybe set the game object to active,

310
00:15:04,960 --> 00:15:07,800
false, or set it to inactive.

311
00:15:07,795 --> 00:15:10,005
But I'm just going to destroy it just

312
00:15:10,000 --> 00:15:12,280
so we make sure we don't have anything anymore.

313
00:15:12,280 --> 00:15:13,750
So save that.

314
00:15:13,750 --> 00:15:17,380
And then we are going to go into the boss health handler.

315
00:15:17,380 --> 00:15:20,170
And in here we are going to create a variable.

316
00:15:20,170 --> 00:15:21,990
And that variable is going to be

317
00:15:21,985 --> 00:15:29,545
a public bool and is in invincible.

318
00:15:29,544 --> 00:15:31,844
And it's going to be set

319
00:15:31,840 --> 00:15:33,820
to false at the beginning or you know what?

320
00:15:33,820 --> 00:15:35,390
Let's not make it public.

321
00:15:35,385 --> 00:15:37,735
Let's make it a private.

322
00:15:37,730 --> 00:15:39,680
And we'll create a method in

323
00:15:39,680 --> 00:15:41,860
here that is going to be public,

324
00:15:41,855 --> 00:15:44,875
int or no, Actually, sorry, void.

325
00:15:44,870 --> 00:15:46,030
Set.

326
00:15:46,025 --> 00:15:48,745
The boss.

327
00:15:48,740 --> 00:15:51,970
Even subtle.

328
00:15:51,965 --> 00:15:55,805
And it's going to take in a parameter which is a Boolean.

329
00:15:55,805 --> 00:16:01,165
And it's going to be is

330
00:16:01,160 --> 00:16:05,410
Skelly or normal not

331
00:16:05,405 --> 00:16:13,055
that is boss in a given symbol.

332
00:16:13,055 --> 00:16:17,495
And then in here we are going to say that is invincible

333
00:16:17,495 --> 00:16:22,385
is equal to, is boss invincible.

334
00:16:22,385 --> 00:16:23,635
Save that.

335
00:16:23,630 --> 00:16:26,720
And in here, before we take damage, as you can see,

336
00:16:26,720 --> 00:16:28,810
we have the comment if getting angry,

337
00:16:28,805 --> 00:16:30,065
this should not work.

338
00:16:30,065 --> 00:16:35,035
So we're going to say, if is invincible,

339
00:16:35,030 --> 00:16:38,050
then we are going to help,

340
00:16:38,045 --> 00:16:41,555
then we are going to just return.

341
00:16:41,555 --> 00:16:43,825
So return means.

342
00:16:43,820 --> 00:16:45,610
When we do return,

343
00:16:45,605 --> 00:16:47,575
just like we have the return values

344
00:16:47,570 --> 00:16:49,300
and here once we get to the return,

345
00:16:49,295 --> 00:16:51,055
this entire method stops.

346
00:16:51,050 --> 00:16:53,420
So anything under this line of code.

347
00:16:53,420 --> 00:16:55,400
So in here, anything that we write will

348
00:16:55,400 --> 00:16:57,860
not be registered after the return.

349
00:16:57,860 --> 00:17:00,080
And this is exactly what we do in here.

350
00:17:00,080 --> 00:17:02,420
So when we take damage in here,

351
00:17:02,420 --> 00:17:04,630
we check if he is invincible.

352
00:17:04,625 --> 00:17:06,875
We open this one up.

353
00:17:06,875 --> 00:17:07,805
Sorry.

354
00:17:07,805 --> 00:17:10,405
We enter into the condition,

355
00:17:10,400 --> 00:17:12,250
we execute the return and none

356
00:17:12,245 --> 00:17:14,365
of these lines get executed.

357
00:17:14,360 --> 00:17:16,880
So we basically return a value,

358
00:17:16,880 --> 00:17:18,340
and because this is a void,

359
00:17:18,335 --> 00:17:19,805
we can return anything.

360
00:17:19,805 --> 00:17:21,425
If it was an integer,

361
00:17:21,425 --> 00:17:24,995
not a void, we could just return 0.

362
00:17:24,995 --> 00:17:27,335
So I'm going to remove this.

363
00:17:27,335 --> 00:17:28,945
I'm going to save all of this.

364
00:17:28,940 --> 00:17:31,190
And now how are we actually going to

365
00:17:31,190 --> 00:17:33,560
be setting the is invincible?

366
00:17:33,560 --> 00:17:35,600
I'm going to go back in here.

367
00:17:35,600 --> 00:17:37,940
I had this one running.

368
00:17:37,940 --> 00:17:40,250
And let's this out.

369
00:17:40,250 --> 00:17:42,230
First of all, the Health Bar.

370
00:17:42,230 --> 00:17:45,670
So Shruti, should the Shruti.

371
00:17:45,665 --> 00:17:47,395
Surely, there we go.

372
00:17:47,390 --> 00:17:49,990
And when he finishes this animation, he will die.

373
00:17:49,985 --> 00:17:51,865
And you can see that we no longer have

374
00:17:51,860 --> 00:17:55,010
a health bar and we no longer have any errors.

375
00:17:55,010 --> 00:17:55,730
Excellent.

376
00:17:55,730 --> 00:17:58,370
Now the next thing to do is to go into

377
00:17:58,370 --> 00:18:02,170
the animator and to the getting angry state.

378
00:18:02,165 --> 00:18:04,525
And why is this not becoming smaller?

379
00:18:04,520 --> 00:18:05,540
Okay, so in the end,

380
00:18:05,540 --> 00:18:08,270
get angry, we're going to add a behavior.

381
00:18:08,270 --> 00:18:15,960
We're going to call it the boss, underscore, get angry.

382
00:18:15,964 --> 00:18:20,104
New script, create an ad.

383
00:18:20,105 --> 00:18:25,085
And obviously it will be created in the assets in here,

384
00:18:25,085 --> 00:18:26,615
the boss get angry.

385
00:18:26,615 --> 00:18:28,645
I'm going to move it into

386
00:18:28,640 --> 00:18:32,040
the scripts Boss folder

387
00:18:32,044 --> 00:18:34,854
for file or whatever you wanna call it.

388
00:18:34,850 --> 00:18:37,580
So was, there we go.

389
00:18:37,580 --> 00:18:39,710
So both get angry.

390
00:18:39,710 --> 00:18:41,050
Open this one up.

391
00:18:41,045 --> 00:18:44,005
As we can see, the last two we will not need.

392
00:18:44,000 --> 00:18:50,220
And these ones will be control KU.

393
00:18:52,360 --> 00:18:57,130
Control key, you can control KU.

394
00:18:57,125 --> 00:18:59,315
So in here, what should we be doing?

395
00:18:59,315 --> 00:19:01,465
Where should we be making sure that

396
00:19:01,460 --> 00:19:04,060
the boss is invincible or setting it up?

397
00:19:04,055 --> 00:19:06,565
Well, I believe we should first of all,

398
00:19:06,560 --> 00:19:09,710
set it to true when we enter into the state.

399
00:19:09,710 --> 00:19:15,450
So I'm going to access the animator component.

400
00:19:15,580 --> 00:19:20,390
So now we have access to the boss health handler.

401
00:19:20,390 --> 00:19:22,700
And in here we are going to set

402
00:19:22,700 --> 00:19:26,300
the boss invincibility to true.

403
00:19:26,300 --> 00:19:28,780
And then when we exit,

404
00:19:28,775 --> 00:19:33,875
I'm going to duplicate this line and move it down.

405
00:19:33,875 --> 00:19:36,005
And when we exit the state,

406
00:19:36,005 --> 00:19:38,465
then we again can get hit.

407
00:19:38,465 --> 00:19:40,375
So as you can see,

408
00:19:40,370 --> 00:19:45,070
right here, we've created the set boss invincible.

409
00:19:45,065 --> 00:19:48,005
We have a parameter that we need to send it.

410
00:19:48,005 --> 00:19:49,615
We access it using

411
00:19:49,610 --> 00:19:51,850
the component of the boss health handler,

412
00:19:51,845 --> 00:19:55,195
which is also present with the animator.

413
00:19:55,190 --> 00:19:58,160
So we have both components on the same game object.

414
00:19:58,160 --> 00:20:00,160
That's why we can access the animator,

415
00:20:00,155 --> 00:20:01,825
get a component which is

416
00:20:01,820 --> 00:20:04,990
the half Handler said the boss invincibility to true.

417
00:20:04,985 --> 00:20:07,255
And in here, when we said is

418
00:20:07,250 --> 00:20:10,040
invincible to whatever the boss,

419
00:20:10,040 --> 00:20:11,980
invincible whatever the parameter.

420
00:20:11,975 --> 00:20:14,125
If it is true, then it returns.

421
00:20:14,120 --> 00:20:16,450
If it's false, then we do not return.

422
00:20:16,445 --> 00:20:17,675
The boss takes damage.

423
00:20:17,675 --> 00:20:18,605
We save that.

424
00:20:18,605 --> 00:20:20,065
We go back into our game.

425
00:20:20,060 --> 00:20:22,130
Who were.

426
00:20:22,130 --> 00:20:25,240
So up here, we run the game.

427
00:20:25,235 --> 00:20:28,895
We should the bus once, twice.

428
00:20:28,895 --> 00:20:32,525
And you can see right here that while he is angry,

429
00:20:32,525 --> 00:20:33,685
he does not get damaged.

430
00:20:33,680 --> 00:20:35,800
So I've shot him three to four times.

431
00:20:35,795 --> 00:20:37,085
He does not get damaged.

432
00:20:37,085 --> 00:20:39,235
Finally, I shoot him, he dies.

433
00:20:39,230 --> 00:20:40,730
And there we go.

434
00:20:40,730 --> 00:20:43,430
We'd have no errors except for this one which is I

435
00:20:43,430 --> 00:20:46,820
believe something that isn't any of our concern,

436
00:20:46,820 --> 00:20:48,890
something about the panel.

437
00:20:48,890 --> 00:20:50,650
We have this OK time.

438
00:20:50,645 --> 00:20:52,505
So we're going to go out,

439
00:20:52,505 --> 00:20:56,725
we're going to make sure to stage all of our files and

440
00:20:56,720 --> 00:21:02,150
now created a health bar.

441
00:21:02,150 --> 00:21:03,490
So I hope you enjoyed,

442
00:21:03,485 --> 00:21:05,275
excuse me for the long video,

443
00:21:05,270 --> 00:21:08,270
but this is what happens when we are creating UI.

444
00:21:08,270 --> 00:21:10,280
This is all based on your preference,

445
00:21:10,280 --> 00:21:11,750
how you want your game to look.

446
00:21:11,750 --> 00:21:13,970
And I'll see you in the next video.

447
00:21:13,970 --> 00:21:16,700
And I believe the final video where we will make

448
00:21:16,700 --> 00:21:20,300
the boss actually shoot after a certain amount of time.

449
00:21:20,300 --> 00:21:22,470
So see you then.

