1
00:00:00,000 --> 00:00:02,430
Welcome back my fellow game developers

2
00:00:02,430 --> 00:00:04,080
to another very long video.

3
00:00:04,080 --> 00:00:05,970
But in this one, it is worth it.

4
00:00:05,970 --> 00:00:08,790
Like every single time we get hit, we break.

5
00:00:08,790 --> 00:00:10,470
We can see that we have this item.

6
00:00:10,470 --> 00:00:11,850
We don't pick it up immediately,

7
00:00:11,850 --> 00:00:14,040
but after a certain time, not only that,

8
00:00:14,040 --> 00:00:16,430
but now when we should the enemy and he dies,

9
00:00:16,425 --> 00:00:20,315
at some point, he also drops and item.

10
00:00:20,310 --> 00:00:21,780
And we obviously didn't fix

11
00:00:21,780 --> 00:00:23,430
the way the layers interact with each other.

12
00:00:23,430 --> 00:00:25,760
But I think because this video was so long,

13
00:00:25,755 --> 00:00:27,095
we didn't have much time.

14
00:00:27,090 --> 00:00:29,430
So without any further or do Let's

15
00:00:29,430 --> 00:00:32,790
not waste any more time and let's get started.

16
00:00:32,790 --> 00:00:34,710
Oh, case.

17
00:00:34,710 --> 00:00:37,700
So now we have the health pickup working,

18
00:00:37,695 --> 00:00:40,285
but not very fun when

19
00:00:40,280 --> 00:00:43,240
you have all the health lying around you.

20
00:00:43,235 --> 00:00:44,155
You could do that.

21
00:00:44,150 --> 00:00:45,590
You could just set

22
00:00:45,590 --> 00:00:47,720
a couple of health pickups in your world and

23
00:00:47,720 --> 00:00:49,360
then pick them up once you

24
00:00:49,355 --> 00:00:51,535
find certain rooms or whatever.

25
00:00:51,530 --> 00:00:55,810
But I think it's much better when you can have some kind

26
00:00:55,805 --> 00:00:57,835
of mechanic that drops

27
00:00:57,830 --> 00:01:00,110
the items and allows you to pick them up.

28
00:01:00,110 --> 00:01:02,930
So for example, if we have the breakable right here,

29
00:01:02,930 --> 00:01:06,260
these urns, if we crush them or break them,

30
00:01:06,260 --> 00:01:07,850
then we will have some kind of

31
00:01:07,850 --> 00:01:10,190
health pickup or when we kill a certain enemy,

32
00:01:10,190 --> 00:01:13,570
then we have also the health pickup get dropped.

33
00:01:13,565 --> 00:01:16,175
So let's do that first things first,

34
00:01:16,175 --> 00:01:19,165
I'm going to go into the Prefabs where

35
00:01:19,160 --> 00:01:22,400
we have the where is it?

36
00:01:22,400 --> 00:01:23,510
Where is it the weapons,

37
00:01:23,510 --> 00:01:26,440
bullets, blood, bullets, enemy.

38
00:01:26,435 --> 00:01:28,445
So apparently we don't have anything.

39
00:01:28,445 --> 00:01:29,845
Oh, you know what?

40
00:01:29,840 --> 00:01:34,900
Let's create a new folder for the pickups.

41
00:01:34,895 --> 00:01:38,255
And then we are going to drop the health pickup in there.

42
00:01:38,255 --> 00:01:39,505
Great. So now we have this.

43
00:01:39,500 --> 00:01:40,880
The next thing we want to do is

44
00:01:40,880 --> 00:01:42,610
we're going to go into the scripts.

45
00:01:42,605 --> 00:01:43,915
We are going to find

46
00:01:43,910 --> 00:01:45,910
the pickups and we are going to create

47
00:01:45,905 --> 00:01:52,255
a new C-sharp script is going to be called item drop.

48
00:01:52,250 --> 00:01:54,160
Now, why are we doing this?

49
00:01:54,155 --> 00:01:58,655
First of all, I wanted to just close this for a second.

50
00:01:58,655 --> 00:02:02,035
So what I wanted to do is I wanted to immediately add

51
00:02:02,030 --> 00:02:05,900
this code right here into the health pickup or I mean,

52
00:02:05,900 --> 00:02:07,090
sorry, into the breakable.

53
00:02:07,085 --> 00:02:08,785
Where are they? Oh, we just closed it

54
00:02:08,780 --> 00:02:11,780
so I wanted to immediately add it to the breakable.

55
00:02:11,780 --> 00:02:12,850
So as soon as we break,

56
00:02:12,845 --> 00:02:14,605
we get a certain item.

57
00:02:14,600 --> 00:02:15,980
But then I thought,

58
00:02:15,980 --> 00:02:19,490
what if I wanted some enemies drop items that

59
00:02:19,490 --> 00:02:20,780
wouldn't be much efficient

60
00:02:20,780 --> 00:02:23,150
because we want several things.

61
00:02:23,150 --> 00:02:24,230
Maybe to drop items,

62
00:02:24,230 --> 00:02:25,490
we want different earns,

63
00:02:25,490 --> 00:02:26,960
maybe not just the breakable,

64
00:02:26,960 --> 00:02:29,590
maybe I don't know anything that drops items.

65
00:02:29,585 --> 00:02:32,045
I thought it might be better to just create

66
00:02:32,045 --> 00:02:34,765
a script which is the item dropper and add it

67
00:02:34,760 --> 00:02:37,820
to whatever object we want to drop an item

68
00:02:37,820 --> 00:02:41,170
once he dies or kills or whatever.

69
00:02:41,165 --> 00:02:43,675
Okay, so let's go ahead and do that.

70
00:02:43,670 --> 00:02:44,530
First thing.

71
00:02:44,525 --> 00:02:46,345
First we are going to go ahead

72
00:02:46,340 --> 00:02:48,490
and create a serialized field,

73
00:02:48,485 --> 00:02:51,715
which is going to make sure that we have the option to

74
00:02:51,710 --> 00:02:54,800
check whether he drops items,

75
00:02:54,800 --> 00:02:58,180
whether he or she or whatever drops items.

76
00:02:58,175 --> 00:02:59,875
The second variable I want to

77
00:02:59,870 --> 00:03:02,330
create is a serialized field,

78
00:03:02,330 --> 00:03:04,310
which is of type game object.

79
00:03:04,310 --> 00:03:06,890
And we're going to make it an array and it's going to be

80
00:03:06,890 --> 00:03:09,520
the items too drop.

81
00:03:09,515 --> 00:03:11,375
Now you might be wondering, we only have

82
00:03:11,375 --> 00:03:13,385
one item to drop, which is the health.

83
00:03:13,385 --> 00:03:15,415
But later on we'll create a coin

84
00:03:15,410 --> 00:03:17,600
and maybe even you might want to create

85
00:03:17,600 --> 00:03:19,790
some kind of leveling up systems or you drop

86
00:03:19,790 --> 00:03:22,250
something that travels up just like we have in Hades.

87
00:03:22,250 --> 00:03:23,990
So items to drop,

88
00:03:23,990 --> 00:03:25,790
we have it as an array.

89
00:03:25,790 --> 00:03:28,990
Next thing we'll have as a serialized field,

90
00:03:28,985 --> 00:03:30,715
there's going to be of type float

91
00:03:30,710 --> 00:03:31,790
and it's going to be called

92
00:03:31,790 --> 00:03:36,980
the items drop or item drop.

93
00:03:36,980 --> 00:03:38,630
Chance.

94
00:03:38,630 --> 00:03:41,860
And we're going to set it at 0.5.

95
00:03:41,855 --> 00:03:43,705
So it's a 5050 chance.

96
00:03:43,700 --> 00:03:45,050
And why do we want to have this?

97
00:03:45,050 --> 00:03:46,670
Well, we don't want to have all

98
00:03:46,670 --> 00:03:48,470
of our breakable or all of

99
00:03:48,470 --> 00:03:52,330
our enemies dropping this the items.

100
00:03:52,325 --> 00:03:55,795
So we want to have a 5050 chance of getting an item.

101
00:03:55,790 --> 00:03:56,410
Great.

102
00:03:56,405 --> 00:03:58,135
So now I'm going to go

103
00:03:58,130 --> 00:04:00,500
ahead and remove the start and update.

104
00:04:00,500 --> 00:04:02,750
We will create them if we do need them.

105
00:04:02,750 --> 00:04:08,450
And I'm going to create a public void drop item.

106
00:04:08,450 --> 00:04:10,520
And this will simply go ahead and

107
00:04:10,520 --> 00:04:14,030
create a random integer.

108
00:04:14,030 --> 00:04:15,800
And first of all, we're going to

109
00:04:15,800 --> 00:04:17,690
check for a couple of conditions.

110
00:04:17,690 --> 00:04:21,070
So the first one will be random.

111
00:04:21,065 --> 00:04:26,965
Dot value is less than the items chance to drop.

112
00:04:26,960 --> 00:04:30,020
And what is random dot value that's hover over it and

113
00:04:30,020 --> 00:04:33,820
see returns a random float between 0, one.

114
00:04:33,815 --> 00:04:35,665
So if we get, for example,

115
00:04:35,660 --> 00:04:39,440
zero-point for it's less than 0.5, we want instantiate.

116
00:04:39,440 --> 00:04:40,990
This is a great way to just

117
00:04:40,985 --> 00:04:43,675
avoid the whole is less than one,

118
00:04:43,670 --> 00:04:45,650
more than 0.5 or wherever this

119
00:04:45,650 --> 00:04:48,360
just gives us a random value between 01.

120
00:04:48,364 --> 00:04:50,304
If it's bigger, we instantiate.

121
00:04:50,300 --> 00:04:52,120
If it's not, then we want.

122
00:04:52,115 --> 00:04:54,175
So then we are going to go

123
00:04:54,170 --> 00:04:56,290
ahead and create a random integer.

124
00:04:56,285 --> 00:05:01,525
So random item number and it's going to be equal to

125
00:05:01,520 --> 00:05:07,850
the random dot range and range.

126
00:05:07,849 --> 00:05:10,519
And in here we are going to have a range

127
00:05:10,520 --> 00:05:14,690
between 0 and the items to drop.

128
00:05:14,689 --> 00:05:18,589
Dot length. So pretty simple what we're doing in here.

129
00:05:18,590 --> 00:05:20,180
We already know all of this

130
00:05:20,180 --> 00:05:22,070
and then we are going to go ahead and

131
00:05:22,070 --> 00:05:27,740
instantiate the items to drop.

132
00:05:27,740 --> 00:05:32,570
And we are going to have it as the random item number.

133
00:05:32,570 --> 00:05:35,800
We're going to set it at the transform dot position

134
00:05:35,795 --> 00:05:39,445
and the transform rotation.

135
00:05:39,440 --> 00:05:40,430
There we go.

136
00:05:40,430 --> 00:05:42,320
So I'm going to save this.

137
00:05:42,320 --> 00:05:44,600
I'm going to go,

138
00:05:44,599 --> 00:05:47,019
oh, and before we do that,

139
00:05:47,015 --> 00:05:49,465
I'm going to also create a condition in here

140
00:05:49,460 --> 00:05:52,300
that I completely forgot for some reason.

141
00:05:52,295 --> 00:05:56,315
I'm going to make sure that if drops items,

142
00:05:56,315 --> 00:05:59,375
then we are going to go ahead and do all of this.

143
00:05:59,375 --> 00:06:01,595
And let's just add a couple of

144
00:06:01,595 --> 00:06:05,065
curly brackets around it so it's better that way.

145
00:06:05,060 --> 00:06:07,180
I don't like having multiple lines under

146
00:06:07,175 --> 00:06:09,595
a single drops items.

147
00:06:09,590 --> 00:06:10,700
Okay, great. So with that,

148
00:06:10,700 --> 00:06:12,490
Don't save that back in our game.

149
00:06:12,485 --> 00:06:15,425
And let's go into the breakable pot.

150
00:06:15,425 --> 00:06:18,525
And that's get these a bit closed.

151
00:06:18,529 --> 00:06:24,229
And then we are going to add a item dropper in here.

152
00:06:24,230 --> 00:06:26,390
And as you can see,

153
00:06:26,390 --> 00:06:28,120
there is a problem.

154
00:06:28,115 --> 00:06:29,725
You can see that we don't have

155
00:06:29,720 --> 00:06:32,660
the deserialized fields and

156
00:06:32,660 --> 00:06:34,730
you can see there is something expected in here,

157
00:06:34,730 --> 00:06:38,090
which is we didn't close off one of the,

158
00:06:38,090 --> 00:06:40,470
okay, so there we go.

159
00:06:40,465 --> 00:06:41,685
Now we save that.

160
00:06:41,680 --> 00:06:46,230
Now we should see in here the great.

161
00:06:46,225 --> 00:06:48,355
So I drops items,

162
00:06:48,355 --> 00:06:50,955
items to droplets, just give it the health pickup.

163
00:06:50,950 --> 00:06:53,470
Let's close this down or lockdown

164
00:06:53,470 --> 00:06:56,280
actually go into the Prefabs.

165
00:06:56,275 --> 00:06:59,685
Where is it, Where is it pickups and the health pickup.

166
00:06:59,680 --> 00:07:01,330
So now we only have the health pickup.

167
00:07:01,330 --> 00:07:02,680
And just for testing purposes,

168
00:07:02,680 --> 00:07:05,440
I'm going to set the items to drop chance to 1.

169
00:07:05,440 --> 00:07:08,530
So we always drop an item, save that.

170
00:07:08,530 --> 00:07:10,120
And now the last thing that we

171
00:07:10,120 --> 00:07:11,670
want to make sure of is that

172
00:07:11,665 --> 00:07:15,775
in where should it be in the break bubbles?

173
00:07:15,775 --> 00:07:17,625
If we go, Where is it?

174
00:07:17,620 --> 00:07:18,940
Where is it burry?

175
00:07:18,940 --> 00:07:21,110
2ls breakable.

176
00:07:21,105 --> 00:07:23,455
And in here we are going to

177
00:07:23,450 --> 00:07:27,110
check after we make sure that we,

178
00:07:27,110 --> 00:07:29,330
Where is it we instantiate the object.

179
00:07:29,330 --> 00:07:33,050
We also want to go ahead and check if the

180
00:07:33,050 --> 00:07:37,940
Get component and item dropper.

181
00:07:37,940 --> 00:07:41,690
And we are going to check and hope we

182
00:07:41,690 --> 00:07:43,520
have mass little thing in here that

183
00:07:43,520 --> 00:07:45,430
will do because it's a serialized field,

184
00:07:45,425 --> 00:07:47,085
Let's just create a returns.

185
00:07:47,080 --> 00:07:55,970
So public bool is item,

186
00:07:55,970 --> 00:07:59,150
item dropper.

187
00:07:59,150 --> 00:08:02,980
And we're going to just return here,

188
00:08:02,975 --> 00:08:07,925
True or whatever it is, the drops item.

189
00:08:08,050 --> 00:08:12,200
So this will return true if it does drop an item so we

190
00:08:12,200 --> 00:08:15,370
can go back and the word was it,

191
00:08:15,365 --> 00:08:19,645
okay, The breakable dot is item dropper.

192
00:08:19,640 --> 00:08:21,260
For this item dropper,

193
00:08:21,260 --> 00:08:23,800
once the player dashes into it,

194
00:08:23,795 --> 00:08:25,175
we trigger the break,

195
00:08:25,175 --> 00:08:27,085
we instantiate the parts and

196
00:08:27,080 --> 00:08:29,030
we check if he is an item dropper,

197
00:08:29,030 --> 00:08:31,910
then we are going to again access

198
00:08:31,910 --> 00:08:37,700
the Get Component Item dropper, drop item.

199
00:08:37,700 --> 00:08:39,590
There we go, save that.

200
00:08:39,590 --> 00:08:41,750
And you know what, I was thinking that maybe

201
00:08:41,750 --> 00:08:44,530
this if statement in here isn't that necessary.

202
00:08:44,525 --> 00:08:47,645
So what let's just remove it.

203
00:08:47,645 --> 00:08:50,615
And now I remember why I forgot it,

204
00:08:50,615 --> 00:08:52,685
because it wasn't necessary there.

205
00:08:52,685 --> 00:08:53,765
So back in here,

206
00:08:53,765 --> 00:08:56,485
save that everything should be working fine.

207
00:08:56,480 --> 00:08:58,550
The only thing that's still bothers me is

208
00:08:58,550 --> 00:09:00,750
that if we tried to get the component,

209
00:09:00,754 --> 00:09:02,164
but it's not there,

210
00:09:02,165 --> 00:09:04,945
so we didn't add it to some kind of breakable pot.

211
00:09:04,940 --> 00:09:07,820
Maybe that will cause a problem if it does,

212
00:09:07,820 --> 00:09:09,500
the best way to fix this is to

213
00:09:09,500 --> 00:09:11,300
create an extra if condition,

214
00:09:11,300 --> 00:09:14,890
an extra layer in here of protection

215
00:09:14,885 --> 00:09:20,225
if the Get Component Item dropper,

216
00:09:20,225 --> 00:09:23,225
and it's different than null,

217
00:09:23,225 --> 00:09:26,435
that means that we do have this item right here.

218
00:09:26,435 --> 00:09:32,125
Then we can go ahead and check for the item dropper.

219
00:09:32,120 --> 00:09:34,400
So this will give us an extra layer of

220
00:09:34,400 --> 00:09:37,550
protection if we don't have the component item dropper,

221
00:09:37,550 --> 00:09:39,130
if it's equal to null,

222
00:09:39,125 --> 00:09:42,335
then we are going to check if we can't drop items,

223
00:09:42,335 --> 00:09:45,625
and then we are going to actually drop an item.

224
00:09:45,620 --> 00:09:49,330
So save that back now again, let's see.

225
00:09:49,325 --> 00:09:51,325
Now this is like, Honestly,

226
00:09:51,320 --> 00:09:53,330
I don't like this a lot because we

227
00:09:53,330 --> 00:09:55,990
should be knowing how we are creating this game,

228
00:09:55,985 --> 00:09:58,745
Bu, but this is a worst-case scenario.

229
00:09:58,745 --> 00:10:01,205
So run the game.

230
00:10:01,205 --> 00:10:05,185
And now when we try to break a part,

231
00:10:05,180 --> 00:10:07,310
let me just get a destroyed.

232
00:10:07,310 --> 00:10:09,470
And then when we try to break

233
00:10:09,470 --> 00:10:11,690
the part that you see, there we go.

234
00:10:11,690 --> 00:10:12,740
We destroyed it.

235
00:10:12,740 --> 00:10:14,420
And you can see that our health just

236
00:10:14,420 --> 00:10:17,090
move into from 500 to 510.

237
00:10:17,090 --> 00:10:18,370
But there is a problem.

238
00:10:18,365 --> 00:10:19,705
Did you see it?

239
00:10:19,700 --> 00:10:22,420
Did you see the item get dropped?

240
00:10:22,415 --> 00:10:24,725
Nope, you didn't, but the health increased.

241
00:10:24,725 --> 00:10:26,905
So what is the problem?

242
00:10:26,900 --> 00:10:30,320
Well, the problem here is that it's extremely

243
00:10:30,320 --> 00:10:33,890
fast and we don't want this to happen instantaneously.

244
00:10:33,890 --> 00:10:36,260
We actually want to see the item that we've

245
00:10:36,260 --> 00:10:39,340
dropped before we immediately pick it up.

246
00:10:39,335 --> 00:10:42,325
So I'm going to issue it to you as a challenge.

247
00:10:42,320 --> 00:10:44,330
And your challenge is to delay the time

248
00:10:44,330 --> 00:10:46,480
before we can pick up an item.

249
00:10:46,475 --> 00:10:48,985
So first of all, create a new script.

250
00:10:48,980 --> 00:10:50,860
Pick up the layer again.

251
00:10:50,855 --> 00:10:52,405
Why is this? This is

252
00:10:52,400 --> 00:10:54,860
an amazing video for how you structure your game.

253
00:10:54,860 --> 00:10:56,470
Because pick up the layer,

254
00:10:56,465 --> 00:10:57,955
this will enable us to

255
00:10:57,950 --> 00:11:00,530
delay the time before we pick up an item.

256
00:11:00,530 --> 00:11:04,610
And we don't want to add this delaying just for

257
00:11:04,610 --> 00:11:06,410
the health script and then have to copy it

258
00:11:06,410 --> 00:11:08,540
every single time and to all of the coins,

259
00:11:08,540 --> 00:11:10,450
the power-ups and et cetera.

260
00:11:10,445 --> 00:11:13,195
So what we'll do is just create a new script of

261
00:11:13,190 --> 00:11:14,450
pickup the layer and added to

262
00:11:14,450 --> 00:11:16,370
every single item that we want to pick up,

263
00:11:16,370 --> 00:11:19,460
which is much easier and healthier when it comes to

264
00:11:19,460 --> 00:11:23,180
game development and game design structure and so on.

265
00:11:23,180 --> 00:11:25,180
That's why we create a new script.

266
00:11:25,175 --> 00:11:26,785
Then you'll create a float

267
00:11:26,780 --> 00:11:28,550
for the time before we can pick up,

268
00:11:28,550 --> 00:11:31,150
you need to create a Boolean variable that checks

269
00:11:31,145 --> 00:11:34,175
if we can actually pick up the item or not.

270
00:11:34,175 --> 00:11:36,955
Create a core team that after time,

271
00:11:36,950 --> 00:11:39,010
after a certain amount of time, which is the,

272
00:11:39,005 --> 00:11:41,575
obviously the float variable

273
00:11:41,570 --> 00:11:44,860
recreated in here allows us to pick up the item.

274
00:11:44,855 --> 00:11:47,815
And finally, where should we were?

275
00:11:47,810 --> 00:11:50,290
Should we can call this coating?

276
00:11:50,285 --> 00:11:52,735
Where should we be calling the school routine?

277
00:11:52,730 --> 00:11:54,020
So obviously,

278
00:11:54,019 --> 00:11:56,299
good thing I'm not good at coding because I'm

279
00:11:56,300 --> 00:12:00,610
horrible at grammar and everything else anyways,

280
00:12:00,605 --> 00:12:02,765
you know, what's the point of the last sentence?

281
00:12:02,765 --> 00:12:07,055
Pause the video right now and go to the challenge.

282
00:12:07,055 --> 00:12:09,085
Okay, welcome back.

283
00:12:09,080 --> 00:12:11,920
So one thing that I wanted to do is

284
00:12:11,915 --> 00:12:15,035
I want to go into the health pickup.

285
00:12:15,035 --> 00:12:17,765
Nope, not the health pickup, the breakable part.

286
00:12:17,765 --> 00:12:18,985
And I'm going to apply

287
00:12:18,980 --> 00:12:21,200
the changes to all of the other parts,

288
00:12:21,200 --> 00:12:24,100
but make sure that whenever you do add a pot,

289
00:12:24,095 --> 00:12:25,735
that you make sure to

290
00:12:25,730 --> 00:12:27,590
check whether it drops an item or not

291
00:12:27,590 --> 00:12:31,250
and you have to change the items drop chance obviously.

292
00:12:31,250 --> 00:12:33,530
And electron, of course we will be changing that.

293
00:12:33,530 --> 00:12:37,040
So always keep that in mind when adding new bots.

294
00:12:37,040 --> 00:12:40,190
And then we need to go into the,

295
00:12:40,190 --> 00:12:42,440
where is it the room, the enemies.

296
00:12:42,440 --> 00:12:43,700
We have a couple of enemies.

297
00:12:43,700 --> 00:12:47,680
Let's just check this one and add to him item dropper.

298
00:12:47,675 --> 00:12:48,355
There we go.

299
00:12:48,350 --> 00:12:49,690
So he drops an item.

300
00:12:49,685 --> 00:12:51,355
What is the item that he drops?

301
00:12:51,350 --> 00:12:55,400
It will be That's why we always lock it down.

302
00:12:55,400 --> 00:12:58,880
Then we add the item that's set it as 11.

303
00:12:58,880 --> 00:13:00,610
Should we be dropping an item?

304
00:13:00,605 --> 00:13:04,315
Let's go into the NMI controller in here.

305
00:13:04,310 --> 00:13:05,980
Where does he die?

306
00:13:05,975 --> 00:13:08,875
Damage enemy if health is less than 0,

307
00:13:08,870 --> 00:13:10,700
instantiate the straw game objects.

308
00:13:10,700 --> 00:13:12,530
So the Deaf splatter.

309
00:13:12,530 --> 00:13:18,590
We will also check in here if the component, now what?

310
00:13:18,590 --> 00:13:22,520
Whereas the breakable, we copy this one.

311
00:13:22,520 --> 00:13:24,770
And then we just pasted in here.

312
00:13:24,770 --> 00:13:27,340
So this is redundant code.

313
00:13:27,335 --> 00:13:30,115
But I'm going to let it slide because of all of

314
00:13:30,110 --> 00:13:32,480
the other efficient things that we've created.

315
00:13:32,480 --> 00:13:35,450
So we check if we do have an item dropper,

316
00:13:35,450 --> 00:13:37,810
then we check if he is a dropper,

317
00:13:37,805 --> 00:13:40,175
and then we go ahead and drop the item.

318
00:13:40,175 --> 00:13:41,995
So let's try to test this

319
00:13:41,990 --> 00:13:45,610
out on the skeleton enemy will apply the changes.

320
00:13:45,605 --> 00:13:47,665
So now all the enemies should have

321
00:13:47,660 --> 00:13:50,390
the script to run the game.

322
00:13:50,390 --> 00:13:53,690
And I know this was not at all part of the challenge,

323
00:13:53,690 --> 00:13:56,690
but I just want to test it out so we should the bullets

324
00:13:56,690 --> 00:13:58,370
finally he dies and we can pick

325
00:13:58,370 --> 00:14:00,530
up an item that see if it works.

326
00:14:00,530 --> 00:14:01,840
I get it.

327
00:14:01,835 --> 00:14:03,715
I pick up the item. Excellent.

328
00:14:03,710 --> 00:14:05,600
Now the next thing is to delay,

329
00:14:05,600 --> 00:14:07,480
which is the actual challenge.

330
00:14:07,475 --> 00:14:09,875
So let's go into the,

331
00:14:09,875 --> 00:14:11,335
I know this was a side note,

332
00:14:11,330 --> 00:14:13,670
but maybe you might have not

333
00:14:13,670 --> 00:14:14,960
exactly knew what to do in

334
00:14:14,960 --> 00:14:16,850
this case. No worries about that.

335
00:14:16,850 --> 00:14:19,420
Let's go into the scripts.

336
00:14:19,415 --> 00:14:23,515
The pickups, and right-click in here,

337
00:14:23,510 --> 00:14:25,250
create a new C Sharp script,

338
00:14:25,250 --> 00:14:27,940
which is going to be the PEC.

339
00:14:27,935 --> 00:14:32,485
Pick up, the big,

340
00:14:32,480 --> 00:14:39,050
oops, Pick up the layer, hit Enter.

341
00:14:39,050 --> 00:14:43,500
Wait for this to compile and double-click in here.

342
00:14:43,500 --> 00:14:45,850
Double-click in here.

343
00:14:45,850 --> 00:14:48,130
And let's see what we are going to do.

344
00:14:48,130 --> 00:14:49,720
First of all, we're going to create

345
00:14:49,720 --> 00:14:52,990
the serialized field for the float,

346
00:14:52,990 --> 00:14:59,230
which is the time before pick up.

347
00:14:59,230 --> 00:15:03,070
And let's just set it at around 0.5 seconds.

348
00:15:03,070 --> 00:15:06,990
Then we are going to create a private bool

349
00:15:06,985 --> 00:15:12,595
can be picked up.

350
00:15:12,595 --> 00:15:14,865
Save that now and start.

351
00:15:14,860 --> 00:15:16,510
We are going to make sure that can be

352
00:15:16,510 --> 00:15:18,980
picked up as equal to false.

353
00:15:18,984 --> 00:15:23,174
And then we are going to create the Coubertin And here,

354
00:15:23,170 --> 00:15:25,800
which is going to be the eye enumerator.

355
00:15:25,800 --> 00:15:29,470
And it's going to be called the pick-up, cool down.

356
00:15:29,465 --> 00:15:36,215
Yeah, sure, pick up, cool down.

357
00:15:36,215 --> 00:15:42,185
And then in here we are going to yield, return, new.

358
00:15:42,185 --> 00:15:44,365
Wait four seconds.

359
00:15:44,360 --> 00:15:47,690
And I'm pretty sure by this point, you know,

360
00:15:47,690 --> 00:15:50,780
co routines so well that you are bored of

361
00:15:50,780 --> 00:15:54,070
me every time saying yield return you for weight seconds.

362
00:15:54,065 --> 00:15:55,405
You're probably saying Michael,

363
00:15:55,400 --> 00:15:57,170
we already know how to do this.

364
00:15:57,170 --> 00:15:58,540
Please stop.

365
00:15:58,535 --> 00:15:59,105
Nope.

366
00:15:59,105 --> 00:16:00,425
We're going to learn.

367
00:16:00,425 --> 00:16:04,945
He has Gantt be picked up is equal back to true.

368
00:16:04,940 --> 00:16:06,200
Save that.

369
00:16:06,200 --> 00:16:10,220
And now we are going to go into the item dropper.

370
00:16:10,220 --> 00:16:13,600
And I'm sorry, I mean, the health pickup.

371
00:16:13,595 --> 00:16:14,935
And in here we're going

372
00:16:14,930 --> 00:16:18,430
to check if it has been picked up.

373
00:16:18,425 --> 00:16:20,875
And we're also going to check.

374
00:16:20,870 --> 00:16:25,790
And if the Get component,

375
00:16:25,790 --> 00:16:28,930
the picked up, the layer,

376
00:16:28,925 --> 00:16:31,945
that what should it be called?

377
00:16:31,940 --> 00:16:33,170
Where is it?

378
00:16:33,170 --> 00:16:37,670
Can be picked up? Let's go ahead and return this.

379
00:16:37,670 --> 00:16:47,060
So public boolean, it can be picked up.

380
00:16:47,060 --> 00:16:50,670
And we're just going to return.

381
00:16:50,830 --> 00:16:54,250
Can be picked up variable.

382
00:16:54,245 --> 00:16:57,805
Okay, not very creative name for this one, but it works.

383
00:16:57,800 --> 00:16:59,960
And here is some kind of problem that

384
00:16:59,960 --> 00:17:03,790
type vector definition can be picked up.

385
00:17:03,785 --> 00:17:04,685
Okay?

386
00:17:04,685 --> 00:17:08,965
So can, can be picked up.

387
00:17:08,960 --> 00:17:11,510
Sure, let's say has called a method.

388
00:17:11,510 --> 00:17:14,150
So I believe it's just because of the name.

389
00:17:14,150 --> 00:17:16,970
So you can't name the variable just as you

390
00:17:16,970 --> 00:17:20,390
name the method that you want.

391
00:17:20,390 --> 00:17:21,620
So we'll just call it method

392
00:17:21,620 --> 00:17:23,380
because we have the imagination of

393
00:17:23,375 --> 00:17:28,085
a small fruit fly and then can be picked up method.

394
00:17:28,085 --> 00:17:29,795
And this should do the trick.

395
00:17:29,795 --> 00:17:32,215
Now the last thing and the last part of

396
00:17:32,210 --> 00:17:35,270
this challenge was where do we call the Colton?

397
00:17:35,269 --> 00:17:38,199
I hope you thought about that and I hope to figure that

398
00:17:38,195 --> 00:17:41,885
out that it should be called immediately and start.

399
00:17:41,885 --> 00:17:45,445
So the start, we start the co-routine.

400
00:17:45,440 --> 00:17:48,380
That is can be, Nope, I mean,

401
00:17:48,380 --> 00:17:51,940
pick up, cool down,

402
00:17:51,935 --> 00:17:54,635
pick up, cool down. There we go.

403
00:17:54,635 --> 00:17:55,865
So why and start?

404
00:17:55,865 --> 00:17:59,035
Because we are instantiating the item.

405
00:17:59,030 --> 00:18:01,390
So as soon as we instantiate the item,

406
00:18:01,385 --> 00:18:03,125
it has the pickup D layer,

407
00:18:03,125 --> 00:18:05,795
we immediately start the Colton.

408
00:18:05,795 --> 00:18:07,985
So back in our game.

409
00:18:07,985 --> 00:18:13,615
Let's see in here, the layer.

410
00:18:13,610 --> 00:18:15,460
Pick up the layer.

411
00:18:15,455 --> 00:18:17,155
How many, how long does it wait?

412
00:18:17,150 --> 00:18:20,140
And I'm going to apply the changes to everyone.

413
00:18:20,135 --> 00:18:22,315
So now when we run the game,

414
00:18:22,310 --> 00:18:24,290
we should see that as soon as we

415
00:18:24,290 --> 00:18:26,870
hit the break bubbles, there we go.

416
00:18:26,870 --> 00:18:27,980
We hit the brake bolts.

417
00:18:27,980 --> 00:18:30,430
We don't pick up immediately the item.

418
00:18:30,425 --> 00:18:31,865
We see it getting dropped.

419
00:18:31,865 --> 00:18:32,875
There we go.

420
00:18:32,870 --> 00:18:35,300
Yep. You can see right now that it's still there.

421
00:18:35,300 --> 00:18:37,690
We haven't picked it up, but now we can,

422
00:18:37,685 --> 00:18:39,115
let's try something different.

423
00:18:39,110 --> 00:18:41,680
Let's add the delaying to

424
00:18:41,675 --> 00:18:44,785
around three seconds and see if it works.

425
00:18:44,780 --> 00:18:45,800
In real life.

426
00:18:45,800 --> 00:18:47,890
We're going to get hit.

427
00:18:47,885 --> 00:18:50,975
We are going to destroy this and try to pick it up.

428
00:18:50,975 --> 00:18:53,155
Okay, so that worked pretty

429
00:18:53,150 --> 00:18:56,120
fast and I'm wondering what the problem is here.

430
00:18:56,120 --> 00:18:58,040
Oh, okay, welcome back.

431
00:18:58,040 --> 00:19:02,380
So the biggest mistake that has ever been made,

432
00:19:02,375 --> 00:19:05,155
I changed this health pickup to 10,

433
00:19:05,150 --> 00:19:07,640
but the actual prefab hasn't changed.

434
00:19:07,640 --> 00:19:09,920
So let's apply the changes.

435
00:19:09,920 --> 00:19:12,400
I was wondering everything is working smoothly,

436
00:19:12,395 --> 00:19:14,875
but for some reason this wasn't working.

437
00:19:14,870 --> 00:19:17,740
So there we go with the steroid and now we have 10,

438
00:19:17,735 --> 00:19:20,245
10 seconds before we can actually pick it up,

439
00:19:20,240 --> 00:19:25,210
but we are going to set it to about 0.5. Save that.

440
00:19:25,205 --> 00:19:26,165
I hope you enjoy it.

441
00:19:26,165 --> 00:19:27,365
I hope you liked

442
00:19:27,365 --> 00:19:29,365
all the different mechanics

443
00:19:29,360 --> 00:19:31,210
and small tweak things and the

444
00:19:31,205 --> 00:19:33,805
adding and removing and making sure

445
00:19:33,800 --> 00:19:36,860
that we can apply different things, different items.

446
00:19:36,860 --> 00:19:38,990
So I know this was a long video.

447
00:19:38,990 --> 00:19:40,420
Thank you for your attention.

448
00:19:40,415 --> 00:19:43,345
Thank you for staging all of your files every

449
00:19:43,340 --> 00:19:44,720
single time and making

450
00:19:44,720 --> 00:19:46,790
all of the progress that you've made.

451
00:19:46,790 --> 00:19:49,090
I also thank you for the refute,

452
00:19:49,085 --> 00:19:52,165
amazing amazing review that you've left

453
00:19:52,160 --> 00:19:56,400
me and I'll see you in the next video.

