1
00:00:00,000 --> 00:00:05,250
Welcome back My favorite game developers to a brand new very long video.

2
00:00:05,250 --> 00:00:08,730
And this one, we have created animations for the blood.

3
00:00:08,730 --> 00:00:10,470
We have learned about arrays.

4
00:00:10,470 --> 00:00:14,340
And now you can see in the hierarchy when we shoot our enemy,

5
00:00:14,340 --> 00:00:18,470
you can see that we have different types of blood being instantiated.

6
00:00:18,470 --> 00:00:23,140
So for example, now the blood to then we have the blood for,

7
00:00:23,135 --> 00:00:25,385
then we have the three.

8
00:00:25,385 --> 00:00:26,395
So what's happening?

9
00:00:26,390 --> 00:00:29,410
We have a lot of Bloods and they are instantiating

10
00:00:29,405 --> 00:00:33,085
kind of randomly because we use an array.

11
00:00:33,080 --> 00:00:37,740
So let's not waste any more time and let's get started.

12
00:00:38,620 --> 00:00:44,590
So time to add some herd effect to our enemies.

13
00:00:44,585 --> 00:00:46,585
Let's go ahead and first of all,

14
00:00:46,580 --> 00:00:48,200
create all of these effects.

15
00:00:48,200 --> 00:00:50,150
So I'm going to go into the sprites,

16
00:00:50,150 --> 00:00:51,920
we have the blood splatter.

17
00:00:51,919 --> 00:01:00,679
I'm going to create a folder for the blood impact splatter.

18
00:01:00,680 --> 00:01:03,800
Maybe we should have called this the death, but no worries,

19
00:01:03,800 --> 00:01:07,510
we'll call this the impact splatters.

20
00:01:07,510 --> 00:01:10,490
So we know that the France and I'm going to go into

21
00:01:10,490 --> 00:01:14,770
the resources and you can see that I've provided you with more blood.

22
00:01:14,765 --> 00:01:19,685
You can either use these and slice them up or you can use these five right here.

23
00:01:19,685 --> 00:01:25,225
So let's choose all of them and drag them down into the folder right here.

24
00:01:25,220 --> 00:01:27,140
Why are we using all of them all?

25
00:01:27,140 --> 00:01:31,970
Because we want to have a bit of diversification between the 1D 2D,

26
00:01:31,970 --> 00:01:33,110
3D and et cetera.

27
00:01:33,110 --> 00:01:39,040
So you can see each one of them is just a little bit different than the other ones.

28
00:01:39,035 --> 00:01:43,285
So I'm going to save this and I'm going to create the animations.

29
00:01:43,280 --> 00:01:45,460
And it's pretty easy I think.

30
00:01:45,455 --> 00:01:50,125
So I'm going to do with and use the magic of editing to do it in 1 second.

31
00:01:50,120 --> 00:01:52,610
So o k, welcome back.

32
00:01:52,610 --> 00:01:54,670
So how did you get all of that?

33
00:01:54,665 --> 00:01:56,305
Let me show you what I did.

34
00:01:56,300 --> 00:01:59,830
So first of all, I created five bloods for the

35
00:01:59,825 --> 00:02:05,395
55 of blood impact that we have now they are not very different from each other,

36
00:02:05,390 --> 00:02:07,100
but there is a slight difference.

37
00:02:07,100 --> 00:02:08,210
So when we run this,

38
00:02:08,210 --> 00:02:10,190
you can see this is the first one.

39
00:02:10,190 --> 00:02:12,830
This is the second one that's a bit different.

40
00:02:12,830 --> 00:02:15,650
The first one is a bit more splashy.

41
00:02:15,650 --> 00:02:17,540
The third one, let's see.

42
00:02:17,540 --> 00:02:20,840
You can see that it falls down more than the second one.

43
00:02:20,840 --> 00:02:23,140
So you can see this is the two.

44
00:02:23,135 --> 00:02:24,385
This one is three.

45
00:02:24,380 --> 00:02:26,800
It's a bit more falling down.

46
00:02:26,795 --> 00:02:28,115
I'm not sure what to call it.

47
00:02:28,115 --> 00:02:32,375
The fourth, you can see it's very small and very concentrated.

48
00:02:32,375 --> 00:02:36,265
And the fifth one you can see it's very GUI.

49
00:02:36,260 --> 00:02:38,330
So what are we going to do?

50
00:02:38,330 --> 00:02:39,950
We're going to save all of that.

51
00:02:39,950 --> 00:02:46,400
I'm going to go into the Prefabs in here and I'm going to create a folder for

52
00:02:46,400 --> 00:02:57,180
the lot backed lashes splashes and I'm going to drag the blood 1,

53
00:02:57,175 --> 00:03:01,935
2, 3, 4, and 5.

54
00:03:01,930 --> 00:03:03,550
I'm going to save all of that.

55
00:03:03,550 --> 00:03:06,040
I'm going to delete them from the hierarchy.

56
00:03:06,040 --> 00:03:07,720
And now we have the blood in here.

57
00:03:07,720 --> 00:03:11,910
Now I think that we will probably have to destroy them and just a bit,

58
00:03:11,905 --> 00:03:14,085
but for now, no worries about that.

59
00:03:14,080 --> 00:03:16,660
We'll fix that when the problem arises.

60
00:03:16,660 --> 00:03:18,900
So what are we going to do?

61
00:03:18,895 --> 00:03:23,755
We want to instantiate these bloods every time the enemy gets hurt?

62
00:03:23,755 --> 00:03:25,995
And the way we do that is first of all,

63
00:03:25,990 --> 00:03:30,820
by obviously getting a reference to it just like we did with the death splatter.

64
00:03:30,820 --> 00:03:34,950
So this will be called the damage effect.

65
00:03:34,950 --> 00:03:37,510
For the damage.

66
00:03:37,505 --> 00:03:39,805
The damage effect.

67
00:03:39,800 --> 00:03:44,540
Let's just keep it at that or you can call the damage blood splatter whatever you want.

68
00:03:44,540 --> 00:03:47,500
And now what we're going to do is we'll simply going to

69
00:03:47,495 --> 00:03:50,485
instantiate it every time we get hurt.

70
00:03:50,480 --> 00:03:56,740
So down here, we are going to duplicate this.

71
00:03:56,735 --> 00:03:59,075
Move it up a bit.

72
00:03:59,075 --> 00:04:02,185
And if you remember how we duplicate Control D,

73
00:04:02,180 --> 00:04:07,340
how did we move this very nicely by holding down Alt and using the arrow keys.

74
00:04:07,340 --> 00:04:10,400
So now we instantiate v.

75
00:04:10,400 --> 00:04:13,660
What should we instantiate the damage effect?

76
00:04:13,655 --> 00:04:17,375
And it's on the transform position of the.

77
00:04:17,375 --> 00:04:20,365
So I'm going to save all of that.

78
00:04:20,360 --> 00:04:22,730
I'm going to go back into our game.

79
00:04:22,730 --> 00:04:25,850
I'm going to choose the enemy here we have the damaging effect,

80
00:04:25,850 --> 00:04:28,250
and let's choose blue one.

81
00:04:28,250 --> 00:04:29,330
Save that.

82
00:04:29,330 --> 00:04:32,090
And now we are going to run the game.

83
00:04:32,090 --> 00:04:35,850
And now I'm going to shoot our enemy.

84
00:04:36,910 --> 00:04:39,520
There we go. You can see the blood.

85
00:04:39,515 --> 00:04:41,495
Obviously it's on repeat.

86
00:04:41,495 --> 00:04:48,515
Okay, so now we need to start instantiating these effects every time the enemy gets hurt.

87
00:04:48,515 --> 00:04:53,995
So where are we instantiating the effect or the impact effects of the bullets?

88
00:04:53,990 --> 00:04:58,820
Well, we are instantiating them in the layer bullet controller.

89
00:04:58,820 --> 00:05:01,760
So you can see this is where we instantiate them.

90
00:05:01,760 --> 00:05:05,660
Now what do we want to do whenever we are hitting a wall,

91
00:05:05,660 --> 00:05:07,850
we have this bullet Impact effect.

92
00:05:07,850 --> 00:05:12,080
But whenever we are hitting an enemy,

93
00:05:12,080 --> 00:05:14,360
we want to have some kind of load effect.

94
00:05:14,360 --> 00:05:18,170
So I'm going to duplicate this line right here.

95
00:05:18,170 --> 00:05:21,710
And I'm going to call this the mature.

96
00:05:21,710 --> 00:05:25,520
I call it the damage fact.

97
00:05:25,520 --> 00:05:28,670
Because this means that there will be some kind of damage

98
00:05:28,670 --> 00:05:32,210
when we have damage means there's blood means there's something different.

99
00:05:32,210 --> 00:05:36,280
And what we'll do in here is every time we hit an enemy,

100
00:05:36,275 --> 00:05:38,845
I'm going to open up the brackets.

101
00:05:38,840 --> 00:05:45,760
And I'm going to add right here that we instantiate and instantiate

102
00:05:45,755 --> 00:05:55,205
the damage effect on the transform position and the transform rotation.

103
00:05:55,205 --> 00:05:58,645
But what we don't want to have as when we're

104
00:05:58,640 --> 00:06:02,320
hitting the enemy and we still instantiate a bullet effect.

105
00:06:02,315 --> 00:06:06,145
So what I'm going to do is I'm going an else statement here.

106
00:06:06,140 --> 00:06:11,240
And I'm going to move this entire line down into that else statement.

107
00:06:11,239 --> 00:06:12,859
How am I doing this?

108
00:06:12,860 --> 00:06:18,640
By holding down Alt and using the arrow keys on one of the lines that I want to move.

109
00:06:18,635 --> 00:06:20,935
So now what happens when the bullet

110
00:06:20,930 --> 00:06:24,620
Impacts or has a collision and that collision has a tag of an enemy,

111
00:06:24,620 --> 00:06:27,380
then we will have this blood splatter

112
00:06:27,380 --> 00:06:30,280
and we will access the animal controller and deal damage.

113
00:06:30,275 --> 00:06:32,285
If not, if it's not the enemy,

114
00:06:32,285 --> 00:06:33,925
which means we are hitting,

115
00:06:33,920 --> 00:06:35,300
I don't know whatever it is.

116
00:06:35,300 --> 00:06:38,690
We are going to have the bullet and back effect.

117
00:06:38,690 --> 00:06:40,250
So I'm going to save this.

118
00:06:40,250 --> 00:06:42,320
I'm going to go back in here.

119
00:06:42,320 --> 00:06:50,500
And here, I'm going to look for my bullet in the prefabs,

120
00:06:50,495 --> 00:06:54,265
prefabs V bilayer bullet in here,

121
00:06:54,260 --> 00:06:56,870
we should have the player,

122
00:06:56,870 --> 00:06:58,780
but I should have the damage effect.

123
00:06:58,775 --> 00:07:00,745
I'm going to lock this in the inspector

124
00:07:00,740 --> 00:07:03,370
so you have this little login here, you can click it.

125
00:07:03,365 --> 00:07:05,015
Now, whatever you press,

126
00:07:05,015 --> 00:07:08,095
you don't change from the player book inspector.

127
00:07:08,090 --> 00:07:11,420
And this is helpful. Why? Because we can now open this file,

128
00:07:11,420 --> 00:07:12,590
choose the blood one,

129
00:07:12,590 --> 00:07:16,060
and let's add it in here into the damage of fact,

130
00:07:16,055 --> 00:07:19,045
save all of that, run the game.

131
00:07:19,040 --> 00:07:23,330
And now we should see that when we are shooting at the wall, we have this impact.

132
00:07:23,330 --> 00:07:24,740
When we shoot an enemy.

133
00:07:24,740 --> 00:07:25,520
There we go.

134
00:07:25,520 --> 00:07:27,440
We have the blood playing on repeat,

135
00:07:27,440 --> 00:07:30,670
which means that we will have to change the animations.

136
00:07:30,665 --> 00:07:34,445
And I didn't tell you that I've created animations.

137
00:07:34,445 --> 00:07:36,475
Can just remove that.

138
00:07:36,470 --> 00:07:38,320
And let me delete this folder.

139
00:07:38,315 --> 00:07:39,685
I had it by mistake.

140
00:07:39,680 --> 00:07:42,640
So splash one, remove this.

141
00:07:42,635 --> 00:07:47,905
Splash to remove this of the looping of the,

142
00:07:47,900 --> 00:07:51,880
oops, I turned it on by mistake. Turn it off.

143
00:07:51,875 --> 00:07:54,125
Turn off. So there you go.

144
00:07:54,125 --> 00:07:59,095
We have all the animations not on looping, okay, save that,

145
00:07:59,090 --> 00:08:00,860
run the game now when we should the enemy,

146
00:08:00,860 --> 00:08:04,360
we should see the blood splatter of blood one.

147
00:08:04,355 --> 00:08:07,835
Okay, So that's fine and dandy and everything is good.

148
00:08:07,835 --> 00:08:11,215
But we have five facts for a reason.

149
00:08:11,210 --> 00:08:14,740
How are we going to make sure that one of them is rendered?

150
00:08:14,735 --> 00:08:17,165
And not only that, how are we going to make sure that

151
00:08:17,165 --> 00:08:20,585
a random number of these is rendered?

152
00:08:20,585 --> 00:08:25,025
So we need multiple objects of blood in here.

153
00:08:25,025 --> 00:08:29,125
Now, what we can do is we can simply go ahead and duplicate this five times.

154
00:08:29,120 --> 00:08:32,000
Damage 123, etc.

155
00:08:32,000 --> 00:08:35,720
So we have five damages that we can call at randomly.

156
00:08:35,720 --> 00:08:41,510
That's a solution, but it's not the optimal solution because for example,

157
00:08:41,510 --> 00:08:45,970
let's say we want to have maybe 17 damage effects.

158
00:08:45,965 --> 00:08:49,435
Do we have to go ahead and create 17 variables?

159
00:08:49,430 --> 00:08:53,480
Well, you can, but first of all, it's very cumbersome.

160
00:08:53,480 --> 00:08:57,190
Second of all, it's not a good way of using the resources.

161
00:08:57,185 --> 00:09:01,985
What is a good way of using resources as creating something called an array?

162
00:09:01,985 --> 00:09:04,175
So what is an array?

163
00:09:04,175 --> 00:09:11,935
An array allows you to store multiple objects of the same type in a single variable.

164
00:09:11,930 --> 00:09:15,950
So we can go ahead and create an int.

165
00:09:15,950 --> 00:09:19,900
So for example, a array of integers,

166
00:09:19,895 --> 00:09:23,585
for example, which is the number of enemies.

167
00:09:23,584 --> 00:09:25,674
So I can store, for example,

168
00:09:25,670 --> 00:09:28,970
4, 6, 11, and 71.

169
00:09:28,970 --> 00:09:33,170
And each one of these little data's in the array.

170
00:09:33,170 --> 00:09:35,150
You can see that we have first of all,

171
00:09:35,150 --> 00:09:37,610
the type just like an a variable,

172
00:09:37,610 --> 00:09:40,420
but the only difference, we add these two square brackets.

173
00:09:40,415 --> 00:09:43,765
We have the name and we have the values.

174
00:09:43,760 --> 00:09:49,370
And each one of those values is or has an index inside.

175
00:09:49,370 --> 00:09:52,370
So for example, the four is indexed at 0.

176
00:09:52,370 --> 00:09:57,380
And remember we always start indexing at 0, not 10.

177
00:09:57,380 --> 00:09:59,300
The six is at index one,

178
00:09:59,300 --> 00:10:01,340
the 11 is at index two,

179
00:10:01,340 --> 00:10:03,220
and the three is at index.

180
00:10:03,215 --> 00:10:09,415
I mean, 71 is at index 3 and we can have as many as we would like.

181
00:10:09,410 --> 00:10:14,330
So now that you have a bit of an understanding of what arrays are,

182
00:10:14,330 --> 00:10:17,870
and one more thing we can determine the length of an array.

183
00:10:17,870 --> 00:10:24,190
So for example, the length of this array is four because we have four values.

184
00:10:24,185 --> 00:10:28,175
So out of the way, this little explanation,

185
00:10:28,175 --> 00:10:33,115
let's try to implement it a little bit and you can see how that works.

186
00:10:33,110 --> 00:10:38,440
So I'm going to go back and unity or actually no in here.

187
00:10:38,435 --> 00:10:42,965
And how do we convert this damage effect to an array?

188
00:10:42,965 --> 00:10:45,725
We simply add these two square brackets.

189
00:10:45,724 --> 00:10:49,714
And now I think it's appropriate to name this not damage effect,

190
00:10:49,715 --> 00:10:53,335
but damage effects with an S on the end,

191
00:10:53,330 --> 00:10:54,850
because it's plural now.

192
00:10:54,845 --> 00:10:58,015
So we'll use our handy tool of control or, or,

193
00:10:58,010 --> 00:11:02,020
and we'll simply add an S at the end, hit Enter.

194
00:11:02,015 --> 00:11:04,165
Now the damage effect here is different,

195
00:11:04,160 --> 00:11:07,700
but you can see that the instantiation now is wrong.

196
00:11:07,700 --> 00:11:14,620
Why? Because we are trying to instantiate an array of effects which does not work good,

197
00:11:14,615 --> 00:11:16,285
but we will fix that,

198
00:11:16,280 --> 00:11:19,880
or actually you are going to fix that later on in the challenge.

199
00:11:19,880 --> 00:11:23,820
First of all, let's add all of the damage and see how it looks in the inspector.

200
00:11:23,824 --> 00:11:26,764
So if I go to my bullet,

201
00:11:26,765 --> 00:11:31,015
in the prefabs player bullet,

202
00:11:31,010 --> 00:11:33,740
you can see right here, where is it?

203
00:11:33,740 --> 00:11:35,980
So something is wrong.

204
00:11:35,975 --> 00:11:38,065
What is the problem?

205
00:11:38,060 --> 00:11:40,340
And the console? Let's double-click and see.

206
00:11:40,340 --> 00:11:43,130
Oh, so let me just comment this out.

207
00:11:43,130 --> 00:11:45,250
Save that sometimes when you have an error,

208
00:11:45,245 --> 00:11:47,275
the script doesn't assemble properly.

209
00:11:47,270 --> 00:11:49,750
So now that we fix this problem,

210
00:11:49,745 --> 00:11:53,455
and we can see right here that we have damage effects,

211
00:11:53,450 --> 00:11:55,370
no longer a single element,

212
00:11:55,370 --> 00:11:58,780
but we can open it up and have a list of elements.

213
00:11:58,775 --> 00:12:02,995
What we can do is we can say that the array size is two. Hit enter.

214
00:12:02,990 --> 00:12:04,420
Now we have two elements,

215
00:12:04,415 --> 00:12:09,845
or we can do it the old-fashioned way and hit the plus right here and add an object.

216
00:12:09,845 --> 00:12:13,415
But I will show you an even nifty trick.

217
00:12:13,415 --> 00:12:15,995
I'm going to lock the inspector in here.

218
00:12:15,995 --> 00:12:19,495
I'm going to go to my prefabs.

219
00:12:19,490 --> 00:12:21,620
I'm going to click on the first one,

220
00:12:21,620 --> 00:12:23,960
hold down, shift, click on the last one.

221
00:12:23,960 --> 00:12:29,620
So I have all of them selected and I'm going to drag them to the damaging effect.

222
00:12:29,615 --> 00:12:32,675
And voila, now you have why did I use water?

223
00:12:32,675 --> 00:12:37,645
Now we have the 50 bloods and you can see the elements numbered from 0,

224
00:12:37,640 --> 00:12:40,730
1, 2, 3, and 4.

225
00:12:40,730 --> 00:12:46,760
Now the next step is to instantiate one of them randomly.

226
00:12:46,760 --> 00:12:48,770
And I can show you,

227
00:12:48,770 --> 00:12:51,360
first of all, this will be a challenge.

228
00:12:51,364 --> 00:12:54,094
I'm not sure which I should show you first.

229
00:12:54,095 --> 00:12:56,875
Let me first of all, show you this.

230
00:12:56,870 --> 00:13:00,230
So we have something called random range,

231
00:13:00,230 --> 00:13:02,540
which returns a random number.

232
00:13:02,540 --> 00:13:04,120
Go ahead, look at up.

233
00:13:04,115 --> 00:13:07,145
Now it's time for your challenge.

234
00:13:07,145 --> 00:13:11,245
And your challenge is to create a random effect.

235
00:13:11,240 --> 00:13:15,940
So number one, create a random splash from 0

236
00:13:15,935 --> 00:13:21,035
as the minimum value and the length of the array as the maximum value.

237
00:13:21,035 --> 00:13:22,985
So now you're a bit confused.

238
00:13:22,985 --> 00:13:25,065
What is Michael talking about?

239
00:13:25,065 --> 00:13:27,025
Again, we go back to this one.

240
00:13:27,020 --> 00:13:29,350
The minimum, the maximum.

241
00:13:29,345 --> 00:13:33,515
There you go. Use this, look for it.

242
00:13:33,515 --> 00:13:35,825
Back in here.

243
00:13:35,825 --> 00:13:41,125
Assign that value to an integer variable that you will create locally.

244
00:13:41,120 --> 00:13:43,910
So create a random integer,

245
00:13:43,910 --> 00:13:47,160
assign it a random number.

246
00:13:47,164 --> 00:13:49,344
Look for random latrines 0.

247
00:13:49,340 --> 00:13:50,860
Okay, so I've added that.

248
00:13:50,855 --> 00:13:52,955
And finally, I will give you a hint.

249
00:13:52,955 --> 00:13:54,295
If you don't want the hint,

250
00:13:54,290 --> 00:13:57,580
It's about how do we get the length of the array.

251
00:13:57,575 --> 00:13:58,765
I'll give you the hint. If not,

252
00:13:58,760 --> 00:14:00,470
pause the video, go to the challenge.

253
00:14:00,470 --> 00:14:05,240
You want to have the hint, use dot length to get the length of the array.

254
00:14:05,240 --> 00:14:08,090
You can even look up a couple of examples are no,

255
00:14:08,090 --> 00:14:10,180
this is a bit of a hard challenge.

256
00:14:10,175 --> 00:14:13,345
I would add on a scale of one to 10 as a beginner,

257
00:14:13,340 --> 00:14:15,620
this is a 10 because first of all,

258
00:14:15,620 --> 00:14:17,050
you've just learned arrays.

259
00:14:17,045 --> 00:14:19,085
Second of all, you are using random.

260
00:14:19,085 --> 00:14:20,615
I know it's hard.

261
00:14:20,615 --> 00:14:22,645
Take your time, pause the video,

262
00:14:22,640 --> 00:14:25,490
use your solving problems skills,

263
00:14:25,490 --> 00:14:27,190
everything that you've acquired,

264
00:14:27,185 --> 00:14:31,505
and don't worry about it when you finish the challenge.

265
00:14:31,505 --> 00:14:32,975
If you don't know how to do it,

266
00:14:32,975 --> 00:14:34,645
I'll do it in front of you, but try.

267
00:14:34,640 --> 00:14:38,350
Most important, at least give yourself five minutes to try.

268
00:14:38,345 --> 00:14:44,045
So pause the video right now and go do your best and the Chaldean.

269
00:14:44,170 --> 00:14:46,520
Okay, welcome back.

270
00:14:46,520 --> 00:14:49,430
So whenever we hit an enemy,

271
00:14:49,430 --> 00:14:54,670
what we're going to do is we are going to create a random variable and locally,

272
00:14:54,665 --> 00:14:57,415
so locally means inside of here,

273
00:14:57,410 --> 00:14:58,640
every time we hit an enemy,

274
00:14:58,640 --> 00:15:01,690
I'm going to say that we have an integer variable,

275
00:15:01,685 --> 00:15:07,115
which is going to be the selected splatter.

276
00:15:07,115 --> 00:15:11,515
And it's going to be equal to a random range.

277
00:15:11,510 --> 00:15:14,430
So just like we have in the examples,

278
00:15:14,434 --> 00:15:21,474
and Unity's documentation is going to be between 0 and the death splatter or no,

279
00:15:21,470 --> 00:15:25,400
what we call it, appear the damage affects.

280
00:15:25,400 --> 00:15:30,570
The damage affects dot length.

281
00:15:30,574 --> 00:15:31,564
Save that.

282
00:15:31,565 --> 00:15:33,955
So now what happens in here,

283
00:15:33,950 --> 00:15:36,050
we have this integer.

284
00:15:36,050 --> 00:15:38,530
It's equal to a random range.

285
00:15:38,525 --> 00:15:41,065
And you can see right here that we have the minimum.

286
00:15:41,060 --> 00:15:44,080
So why is it 0? Because we want to choose

287
00:15:44,075 --> 00:15:47,195
a random number from the array that we have in here.

288
00:15:47,195 --> 00:15:50,005
And the first index is 0,

289
00:15:50,000 --> 00:15:54,580
and the last index is going to be the damage length.

290
00:15:54,575 --> 00:15:58,775
But there is something very important that I want to point out to you.

291
00:15:58,775 --> 00:16:01,205
And if we look here at the explanation,

292
00:16:01,205 --> 00:16:06,655
you can see that the minimum is inclusive while the maximum is exclusive.

293
00:16:06,650 --> 00:16:08,540
What does that mean? Inclusive?

294
00:16:08,540 --> 00:16:14,030
That means that we can choose a random from 0 to the maximum.

295
00:16:14,030 --> 00:16:15,830
So 0 is inside.

296
00:16:15,829 --> 00:16:18,919
0 can be one of those random numbers.

297
00:16:18,920 --> 00:16:22,070
But the maximum, which is the length, cannot.

298
00:16:22,070 --> 00:16:26,150
And this is important because indexing in an array,

299
00:16:26,150 --> 00:16:27,730
if we choose the length,

300
00:16:27,725 --> 00:16:31,105
the length is always bigger than the last index.

301
00:16:31,100 --> 00:16:35,010
Because if I go back and the example in here, let me show you.

302
00:16:35,010 --> 00:16:38,520
So let's say what is the length of this entire array?

303
00:16:38,515 --> 00:16:41,125
It's four because we have four points.

304
00:16:41,125 --> 00:16:46,395
But if I try to access the fourth number in this array,

305
00:16:46,390 --> 00:16:51,090
I will get an error because we have the index is 0, 1, 2,

306
00:16:51,085 --> 00:16:53,595
3 if I try to access the fourth,

307
00:16:53,590 --> 00:16:55,380
so for there is nothing,

308
00:16:55,375 --> 00:16:58,035
I get an error and I start crying.

309
00:16:58,030 --> 00:17:01,180
Not necessarily, but I hope you get the point.

310
00:17:01,180 --> 00:17:04,930
Next thing we're going to do is we want to instantiate.

311
00:17:04,930 --> 00:17:08,160
So now that we have our random number,

312
00:17:08,155 --> 00:17:11,395
what we can do as from between the effects,

313
00:17:11,395 --> 00:17:17,505
I can open up the brackets and I can use the selected splatter random.

314
00:17:17,505 --> 00:17:24,185
So now I have a random number which is between 0 and the length minus one,

315
00:17:24,185 --> 00:17:26,675
obviously because it's exclusive.

316
00:17:26,675 --> 00:17:30,655
And now I can instantiate the damage effects

317
00:17:30,650 --> 00:17:34,880
or one of the damage effects randomly using this number.

318
00:17:34,880 --> 00:17:37,910
So I could have said the 0 V1,

319
00:17:37,909 --> 00:17:41,539
but I've selected the random splatter.

320
00:17:41,540 --> 00:17:43,370
So let's save that.

321
00:17:43,370 --> 00:17:45,020
I hope you understand everything.

322
00:17:45,020 --> 00:17:47,200
If not, just take another look at it,

323
00:17:47,195 --> 00:17:49,385
maybe replay the video, understand everything.

324
00:17:49,385 --> 00:17:54,115
I've tried to be as detailed as possible while being a boring.

325
00:17:54,110 --> 00:17:57,520
I think this is one of the longer videos, but no worries.

326
00:17:57,515 --> 00:17:59,275
I'm going to go into my game.

327
00:17:59,270 --> 00:18:03,220
We're going to remove this right here is like the enemy.

328
00:18:03,215 --> 00:18:05,155
And by the way,

329
00:18:05,150 --> 00:18:07,480
I also made sure that all the blood you can see right here,

330
00:18:07,475 --> 00:18:09,275
the sorting layer as the enemy.

331
00:18:09,275 --> 00:18:11,905
So you can see it. And where's the enemy?

332
00:18:11,900 --> 00:18:15,170
I'm going to give him a thousand or 10 thousand health

333
00:18:15,170 --> 00:18:18,920
just so we can see properly all the blood splatters.

334
00:18:18,920 --> 00:18:20,890
So I'm going to get there but close,

335
00:18:20,885 --> 00:18:23,495
I'm going to shoot 12345.

336
00:18:23,495 --> 00:18:24,955
So there you go.

337
00:18:24,950 --> 00:18:29,690
You can see the something isn't completely right,

338
00:18:29,690 --> 00:18:31,360
so I'm going to shoot.

339
00:18:31,355 --> 00:18:35,605
And what is the problem with this 1, 0 case?

340
00:18:35,600 --> 00:18:41,870
So I just found the problem and the blood 5 I've added right here, the blood.

341
00:18:41,870 --> 00:18:43,640
Look when you play the animation,

342
00:18:43,640 --> 00:18:46,490
the last one is a red dot.

343
00:18:46,490 --> 00:18:47,590
So what I'm going to do,

344
00:18:47,585 --> 00:18:50,755
I'm going to remove the last one. And there you go.

345
00:18:50,750 --> 00:18:55,280
Now, we only have this when the blood finishes at the spears.

346
00:18:55,280 --> 00:18:57,380
Save all of that.

347
00:18:57,380 --> 00:18:59,960
And let me just choose the moon.

348
00:18:59,960 --> 00:19:03,940
The blood 5 and a live changes.

349
00:19:03,935 --> 00:19:08,785
Delete it again in the bullet. Let me see.

350
00:19:08,780 --> 00:19:14,980
Maybe because we changed something, maybe prefabs bullet.

351
00:19:14,975 --> 00:19:17,345
Okay. Still working, save that,

352
00:19:17,345 --> 00:19:18,835
go back in our game.

353
00:19:18,830 --> 00:19:21,860
Obviously we'll need to remove all of these so a shoe,

354
00:19:21,860 --> 00:19:23,860
the enemy, let's see.

355
00:19:23,855 --> 00:19:25,375
We have different bloods.

356
00:19:25,370 --> 00:19:27,800
Nope, it's still there for some reason.

357
00:19:27,800 --> 00:19:29,980
Why is that? It's very annoying.

358
00:19:29,975 --> 00:19:33,125
Okay. So I discovered that the blood for

359
00:19:33,125 --> 00:19:37,075
also has its last frame as this red annoying dots.

360
00:19:37,070 --> 00:19:40,220
So I'm going to delete it and save that.

361
00:19:40,220 --> 00:19:43,220
I'm immediately deleting it inside of the prefab.

362
00:19:43,220 --> 00:19:44,810
So I simply go to the prefab,

363
00:19:44,810 --> 00:19:45,830
double-click on the three.

364
00:19:45,830 --> 00:19:51,400
Let's see if this one also has the little annoying red dot that you go up.

365
00:19:51,395 --> 00:19:52,835
Okay, So there you go.

366
00:19:52,835 --> 00:20:00,595
It's also has it save that and blood to zoom and see the animation.

367
00:20:00,590 --> 00:20:04,370
Okay, another bloody work.

368
00:20:04,370 --> 00:20:07,400
This video is getting out of control.

369
00:20:07,400 --> 00:20:08,870
So there we go,

370
00:20:08,870 --> 00:20:11,030
the last one, we also delete that.

371
00:20:11,030 --> 00:20:12,290
And one thing I noticed,

372
00:20:12,290 --> 00:20:15,710
I want to choose all of the prefabs and make sure that all

373
00:20:15,710 --> 00:20:19,240
of their positions is at 0 so they don't get instantiated.

374
00:20:19,235 --> 00:20:21,155
And some weird place.

375
00:20:21,155 --> 00:20:22,715
Anyways, back to our game.

376
00:20:22,715 --> 00:20:27,105
I hope this time everything should be working perfectly.

377
00:20:27,109 --> 00:20:32,449
So I'm going to run the game and I'm going to shoot the enemy.

378
00:20:32,450 --> 00:20:33,110
There you go.

379
00:20:33,110 --> 00:20:34,760
This is the thick blood.

380
00:20:34,760 --> 00:20:36,400
Sugar them again.

381
00:20:36,395 --> 00:20:39,655
Again, it's a different kind of blood. You can see it's blocked.

382
00:20:39,650 --> 00:20:41,000
Three.

383
00:20:41,000 --> 00:20:45,850
Blood for Blood one.

384
00:20:45,850 --> 00:20:51,000
There you go. You can simplify to again, blood one.

385
00:20:50,995 --> 00:20:53,715
So as you can see, whenever we are shooting the enemy,

386
00:20:53,710 --> 00:20:57,340
we have different types of blood's getting instantiate.

387
00:20:57,340 --> 00:21:01,300
So you can see it's a random number getting shot out.

388
00:21:01,300 --> 00:21:03,220
So I hope you enjoyed.

389
00:21:03,220 --> 00:21:05,950
Obviously, there are a couple of things that we will need to

390
00:21:05,950 --> 00:21:09,180
fix with our blood not getting destroyed at the end,

391
00:21:09,175 --> 00:21:13,885
we might find a different way of fixing it once we learned some extra tools,

392
00:21:13,885 --> 00:21:17,915
or maybe we can just remove them using the events and our animations,

393
00:21:17,919 --> 00:21:19,839
which is also very helpful.

394
00:21:19,840 --> 00:21:21,550
So I hope you enjoyed,

395
00:21:21,550 --> 00:21:23,470
I hope you're enjoying this course.

396
00:21:23,470 --> 00:21:27,370
I hope you're not being a bit demotivated by the length of the,

397
00:21:27,365 --> 00:21:30,815
some of the videos because I go into a couple of details.

398
00:21:30,815 --> 00:21:35,045
I hope you like the fact that I make mistakes and keep them in here so we can

399
00:21:35,045 --> 00:21:40,225
fix them together and leave me a review if you are enjoying.

400
00:21:40,220 --> 00:21:41,600
I know I've said it before.

401
00:21:41,600 --> 00:21:43,430
I will maybe say a couple of times,

402
00:21:43,430 --> 00:21:47,390
so make sure to do the review so you don't have to hear it anymore.

403
00:21:47,390 --> 00:21:51,860
And make sure to of course, do the commits.

404
00:21:51,860 --> 00:21:57,320
I'll see you in the next video where we will be giving the enemy and ability to shoot us.

405
00:21:57,320 --> 00:21:58,940
So currently he is very weak.

406
00:21:58,940 --> 00:22:01,930
We want to give him a way to defend himself.

407
00:22:01,925 --> 00:22:04,025
So see you then.

