1
00:00:00,000 --> 00:00:01,000
Hello, guys.

2
00:00:01,000 --> 00:00:03,000
In this video, we're going to make our rain in this game.

3
00:00:03,000 --> 00:00:07,000
And I want to make it not only raining, but I want to make a dynamic rain.

4
00:00:07,000 --> 00:00:09,000
So sometimes it's raining, sometimes it's not.

5
00:00:09,000 --> 00:00:12,000
But first we need to begin with making rain itself.

6
00:00:12,000 --> 00:00:15,000
And it's going to be pretty easy because we're going to use acid store.

7
00:00:16,000 --> 00:00:17,000
Let's go to window.

8
00:00:17,000 --> 00:00:18,000
Acid store.

9
00:00:22,000 --> 00:00:23,000
And in the search field.

10
00:00:23,000 --> 00:00:25,000
We just need to type to the rain.

11
00:00:28,000 --> 00:00:28,000
Good.

12
00:00:28,000 --> 00:00:31,000
Now let's go and find the one we need.

13
00:00:31,000 --> 00:00:32,000
This the one?

14
00:00:32,000 --> 00:00:32,000
Exactly.

15
00:00:32,000 --> 00:00:36,000
I'll try to leave the link in case you cannot find it.

16
00:00:39,000 --> 00:00:41,000
Now let's click open in Unity.

17
00:00:42,000 --> 00:00:44,000
And we're going to download this asset.

18
00:00:44,000 --> 00:00:47,000
Once it's downloaded, we need to find it.

19
00:00:47,000 --> 00:00:49,000
For some reason, I lost it.

20
00:00:51,000 --> 00:00:51,000
Yeah.

21
00:00:51,000 --> 00:00:51,000
Here.

22
00:00:51,000 --> 00:00:53,000
And then click install.

23
00:00:53,000 --> 00:00:54,000
I mean import.

24
00:00:54,000 --> 00:00:55,000
We don't need them.

25
00:00:55,000 --> 00:00:57,000
I seen we can uncheck this one.

26
00:00:57,000 --> 00:01:02,000
We need a prefab and we need an editor, but we can uncheck redmi file.

27
00:01:02,000 --> 00:01:03,000
Let's do import.

28
00:01:04,000 --> 00:01:10,000
And if you remember in the lecture about particles, I told you we need to click reload.

29
00:01:10,000 --> 00:01:15,000
So if you remember in the lecture about particles, I told you that it's easy to learn system but hard

30
00:01:15,000 --> 00:01:16,000
to master.

31
00:01:16,000 --> 00:01:20,000
And this is one of good examples what you can do with particles if you know it really well and if you

32
00:01:20,000 --> 00:01:23,000
know how to code, you can make a rain like that.

33
00:01:23,000 --> 00:01:27,000
Someone else already did it and he put it up for free use so we can use it.

34
00:01:27,000 --> 00:01:33,000
Let's go to Rain maker Prefab and we need to find rain prefab to DH.

35
00:01:33,000 --> 00:01:35,000
Let's drag it in the scene.

36
00:01:35,000 --> 00:01:38,000
So this is the rain game object.

37
00:01:38,000 --> 00:01:43,000
It's going to follow camera on its own and it's going to find camera on its own, so we don't need to

38
00:01:43,000 --> 00:01:44,000
place it anywhere.

39
00:01:44,000 --> 00:01:46,000
You can see it here and there.

40
00:01:46,000 --> 00:01:49,000
The camera field is a main camera now and follow camera check.

41
00:01:49,000 --> 00:01:51,000
So it's going to follow camera.

42
00:01:51,000 --> 00:01:53,000
And because camera follows the player.

43
00:01:53,000 --> 00:01:55,000
Rain going to follow the player as well.

44
00:01:55,000 --> 00:01:56,000
Now, how does it work?

45
00:01:56,000 --> 00:01:57,000
What does it do?

46
00:01:58,000 --> 00:02:00,000
Very simple to understand.

47
00:02:00,000 --> 00:02:04,000
Here we can see sounds for light, medium and heavy rain.

48
00:02:04,000 --> 00:02:07,000
There is an audio mixer you can set up if you want, so you can control.

49
00:02:07,000 --> 00:02:08,000
Oh, sorry.

50
00:02:08,000 --> 00:02:10,000
Why that was so easy to miss.

51
00:02:11,000 --> 00:02:12,000
Let me see.

52
00:02:12,000 --> 00:02:13,000
Let's fix it.

53
00:02:14,000 --> 00:02:14,000
Kind of list.

54
00:02:14,000 --> 00:02:16,000
Main Menu tab to start.

55
00:02:16,000 --> 00:02:19,000
Oh, it's our lane, the settings button.

56
00:02:19,000 --> 00:02:20,000
Okay, let's move it below.

57
00:02:20,000 --> 00:02:21,000
Somewhere here.

58
00:02:22,000 --> 00:02:25,000
Now I want to make it smaller and.

59
00:02:27,000 --> 00:02:28,000
Yeah.

60
00:02:29,000 --> 00:02:31,000
So as I was saying.

61
00:02:32,000 --> 00:02:33,000
You can take this rain.

62
00:02:34,000 --> 00:02:40,000
Go to settings and create another mixer for volume of the rain or some buttons to switch it on or switch

63
00:02:40,000 --> 00:02:42,000
it off after next video.

64
00:02:42,000 --> 00:02:46,000
On our day night system, you're going to know how to do that for sure.

65
00:02:46,000 --> 00:02:52,000
But in this video I want to focus on the rain itself and on setting up the random rain from time to

66
00:02:52,000 --> 00:02:52,000
time.

67
00:02:52,000 --> 00:02:53,000
So this is the sounds.

68
00:02:53,000 --> 00:02:54,000
This is all the mixer.

69
00:02:54,000 --> 00:02:55,000
This is the main setting.

70
00:02:55,000 --> 00:02:57,000
We're going to use rain intensity.

71
00:02:57,000 --> 00:02:59,000
If you increase it, it's going to rain more.

72
00:03:00,000 --> 00:03:06,000
And as of now, you can see it's colliding with an object above entire scene we have.

73
00:03:07,000 --> 00:03:09,000
So to fix that, we're going to do some simple steps.

74
00:03:09,000 --> 00:03:12,000
We're going to go over here to Collision mask.

75
00:03:12,000 --> 00:03:13,000
And as of now, we don't have many layers.

76
00:03:13,000 --> 00:03:15,000
We have only ground layer.

77
00:03:15,000 --> 00:03:17,000
Let's choose that one ground.

78
00:03:18,000 --> 00:03:19,000
Now it's going to collide with the ground.

79
00:03:19,000 --> 00:03:21,000
But we cannot see it.

80
00:03:21,000 --> 00:03:25,000
We cannot see it because particles under this game object.

81
00:03:26,000 --> 00:03:28,000
Have different certain layer.

82
00:03:28,000 --> 00:03:29,000
Let's select three.

83
00:03:29,000 --> 00:03:30,000
I mean all of them.

84
00:03:30,000 --> 00:03:37,000
These three go all the way down to renderer and change certain layer to we can select player and we

85
00:03:37,000 --> 00:03:40,000
can give it priority of number one, for example.

86
00:03:42,000 --> 00:03:47,000
Now it is feasible and we're going to need to repeat all of the steps out of the play mode.

87
00:03:47,000 --> 00:03:50,000
I'm just showing it in the play mode, so it's easier to explain.

88
00:03:51,000 --> 00:03:55,000
So now rain intensity can be increased and we can see the rain.

89
00:03:55,000 --> 00:03:57,000
And as you can see, it's colliding with the ground.

90
00:03:59,000 --> 00:04:05,000
Some thing to notice is that particles of the rain going through the ground, sometimes it's happening

91
00:04:05,000 --> 00:04:07,000
because of the settings over here.

92
00:04:08,000 --> 00:04:12,000
Collision, lifetime rain over here.

93
00:04:12,000 --> 00:04:15,000
If you wanted to go through the colliders, you can increase the value.

94
00:04:15,000 --> 00:04:16,000
It's going to look like that.

95
00:04:16,000 --> 00:04:21,000
But I think we should make it a zero so it bounds of the ground.

96
00:04:23,000 --> 00:04:25,000
This is collision for mist.

97
00:04:25,000 --> 00:04:26,000
And.

98
00:04:27,000 --> 00:04:28,000
Wait a second.

99
00:04:31,000 --> 00:04:35,000
Yeah, here is the wind settings, but they're not really important for us.

100
00:04:35,000 --> 00:04:38,000
So the main point for us is the rain intensity.

101
00:04:38,000 --> 00:04:43,000
And as you can see, high intensity with our mood, the game because it's kind of loud.

102
00:04:44,000 --> 00:04:51,000
So if you put very high intensity, it's going to look like this and it's kind of too much, I guess,

103
00:04:51,000 --> 00:04:53,000
for this game can play a lot.

104
00:04:54,000 --> 00:04:59,000
So what we can do to fix it is to set minimum and maximum rain intensity.

105
00:04:59,000 --> 00:05:04,000
I think maximum can be something like this even less.

106
00:05:06,000 --> 00:05:07,000
They won without missed.

107
00:05:07,000 --> 00:05:08,000
So 49.

108
00:05:08,000 --> 00:05:13,000
This can be the maximum and the lowest can be point one.

109
00:05:14,000 --> 00:05:18,000
Something about 1.5 is okay, what else we need to change here is the rain height.

110
00:05:18,000 --> 00:05:21,000
And the rain with and with is most important.

111
00:05:21,000 --> 00:05:26,000
So if you decrease the value, you can see the rain getting kind of slimmer.

112
00:05:27,000 --> 00:05:28,000
We can make it wider.

113
00:05:28,000 --> 00:05:32,000
And I think it should be somewhat about screen size.

114
00:05:32,000 --> 00:05:38,000
Yeah, we can also increase height and it's going to go from a higher point.

115
00:05:38,000 --> 00:05:41,000
You can see it in the thin window.

116
00:05:42,000 --> 00:05:43,000
But we don't really need it.

117
00:05:43,000 --> 00:05:45,000
So we can make it.

118
00:05:45,000 --> 00:05:46,000
We can place it lower.

119
00:05:47,000 --> 00:05:49,000
Just leave it how it was.

120
00:05:49,000 --> 00:05:54,000
So this is the main settings and then we need to make a custom script to control intensity from time

121
00:05:54,000 --> 00:05:55,000
to time.

122
00:05:55,000 --> 00:05:57,000
Let's go and set it up over again.

123
00:05:57,000 --> 00:05:59,000
First, we're going to select particles.

124
00:06:00,000 --> 00:06:05,000
Find renderer change it to player with the order five.

125
00:06:06,000 --> 00:06:08,000
Now we need to add layers.

126
00:06:08,000 --> 00:06:10,000
Let's go to layers over here.

127
00:06:12,000 --> 00:06:14,000
Let's go to layers and layer.

128
00:06:14,000 --> 00:06:20,000
We're going to have one for player, one for traps and one for coins.

129
00:06:20,000 --> 00:06:23,000
Or we could actually create one layer like interruptible.

130
00:06:23,000 --> 00:06:25,000
But let's keep it like this.

131
00:06:26,000 --> 00:06:27,000
And we have ground already.

132
00:06:29,000 --> 00:06:32,000
So we're going to select player, change it to player.

133
00:06:32,000 --> 00:06:33,000
We can do Yes.

134
00:06:33,000 --> 00:06:34,000
Children as well.

135
00:06:34,000 --> 00:06:35,000
Okay, that's good.

136
00:06:35,000 --> 00:06:36,000
That's good enough for player.

137
00:06:36,000 --> 00:06:39,000
Now let's find other objects in the prefab.

138
00:06:40,000 --> 00:06:42,000
Coin can be changed to.

139
00:06:43,000 --> 00:06:45,000
Coin traps can be changed to a trap.

140
00:06:45,000 --> 00:06:46,000
This is the trap.

141
00:06:46,000 --> 00:06:48,000
And the one inside.

142
00:06:49,000 --> 00:06:50,000
Trump as well.

143
00:06:51,000 --> 00:06:52,000
Okay.

144
00:06:53,000 --> 00:06:56,000
And the platforms are already under the ground layer, I believe.

145
00:06:56,000 --> 00:06:58,000
Otherwise we couldn't move on them.

146
00:06:59,000 --> 00:07:00,000
Yeah.

147
00:07:01,000 --> 00:07:03,000
Okay, let's see what else we want to set up.

148
00:07:03,000 --> 00:07:04,000
Collision mask.

149
00:07:04,000 --> 00:07:06,000
We need to set it up now from nothing.

150
00:07:06,000 --> 00:07:11,000
We need to ground player drops, coins.

151
00:07:11,000 --> 00:07:12,000
Cool enough.

152
00:07:12,000 --> 00:07:13,000
Collision lifetime.

153
00:07:13,000 --> 00:07:14,000
Let's make it zero.

154
00:07:16,000 --> 00:07:17,000
What was the width?

155
00:07:17,000 --> 00:07:18,000
I don't remember.

156
00:07:18,000 --> 00:07:19,000
Honestly, let.

157
00:07:19,000 --> 00:07:20,000
Let me double check.

158
00:07:23,000 --> 00:07:24,000
Like 1.2.

159
00:07:24,000 --> 00:07:26,000
Let's do 1.2.

160
00:07:28,000 --> 00:07:28,000
Good.

161
00:07:28,000 --> 00:07:30,000
We can leave it like that now.

162
00:07:30,000 --> 00:07:33,000
And unless you want to set up mixer, you can do it.

163
00:07:33,000 --> 00:07:37,000
Now I'm going to go to script folder and create a script.

164
00:07:37,000 --> 00:07:41,000
C Sharp rain controller.

165
00:07:42,000 --> 00:07:49,000
I'm going to unpack this prefab prefab, unpack, fold this one and drag my rain controller above.

166
00:07:50,000 --> 00:07:51,000
Now I'm going to open this.

167
00:07:52,000 --> 00:07:56,000
And if you take a look at this script, let me go inside of it.

168
00:07:57,000 --> 00:08:00,000
It is inherited from his reign script.

169
00:08:00,000 --> 00:08:06,000
And if you go to Baz Rain script, we can find here rain intensity, the one we used in the inspector,

170
00:08:06,000 --> 00:08:10,000
and it uses range to make it look like that slider in the inspector.

171
00:08:14,000 --> 00:08:16,000
So I'm going to copy this.

172
00:08:16,000 --> 00:08:18,000
Go to my brain controller and paste it in.

173
00:08:19,000 --> 00:08:20,000
You don't have to copy.

174
00:08:20,000 --> 00:08:22,000
You can just type the same, basically.

175
00:08:22,000 --> 00:08:26,000
But I want to change it from rain intensity to just intensity.

176
00:08:26,000 --> 00:08:27,000
This will be the name.

177
00:08:29,000 --> 00:08:31,000
Oh, and it can be private for this one.

178
00:08:33,000 --> 00:08:34,000
Sterilized field.

179
00:08:35,000 --> 00:08:40,000
By the way, if you don't type word private here, it's going to be private like that and just like

180
00:08:40,000 --> 00:08:41,000
to type private in my courses.

181
00:08:41,000 --> 00:08:45,000
So it's clear for students, probably, I should tell you that before.

182
00:08:46,000 --> 00:08:47,000
Now we have intensity.

183
00:08:47,000 --> 00:08:48,000
What else we need to know?

184
00:08:48,000 --> 00:08:55,000
We need to know how fast we change in from, let's say, zero to some rain intensity because we cannot

185
00:08:55,000 --> 00:08:58,000
do it like, you know, from zero to point four.

186
00:08:58,000 --> 00:09:04,000
It's going to look real harsh and we want to make it and we want to make smooth transition.

187
00:09:04,000 --> 00:09:09,000
So it's going to be serialized field private float change rate.

188
00:09:09,000 --> 00:09:12,000
We also want to have minimum intensity and maximum intensity.

189
00:09:12,000 --> 00:09:18,000
So private float mean let's do mean value and max value.

190
00:09:20,000 --> 00:09:21,000
We need a cool down.

191
00:09:21,000 --> 00:09:23,000
How often are we going to check?

192
00:09:23,000 --> 00:09:24,000
But you know what?

193
00:09:24,000 --> 00:09:26,000
Let's think about cool down later.

194
00:09:26,000 --> 00:09:28,000
Let's focus on changing the intensity first.

195
00:09:30,000 --> 00:09:32,000
As do private void.

196
00:09:33,000 --> 00:09:35,000
Change intensity.

197
00:09:36,000 --> 00:09:37,000
Inside.

198
00:09:37,000 --> 00:09:40,000
We're going to check all Yeah, we need target intensity.

199
00:09:40,000 --> 00:09:44,000
So we have intensity that we have at the moment and we have target intensity.

200
00:09:44,000 --> 00:09:49,000
So we're going to do the serialize field, private float, target intensity.

201
00:09:49,000 --> 00:09:54,000
In the change intensity, we're going to check if we are decreasing or increasing the value.

202
00:09:54,000 --> 00:09:59,000
So for example, if we increase in the value, we're going to do this if intensity.

203
00:10:01,000 --> 00:10:05,000
Is less than target intensity.

204
00:10:05,000 --> 00:10:07,000
It means we increase in the value.

205
00:10:07,000 --> 00:10:10,000
We want to bring intensity to the level of target intensity.

206
00:10:10,000 --> 00:10:13,000
So in that case, we're going to do intensity.

207
00:10:15,000 --> 00:10:15,000
Plus equals.

208
00:10:15,000 --> 00:10:21,000
So we're going to increase it by change rate multiplied by time, dot, delta time.

209
00:10:21,000 --> 00:10:24,000
Now we need to check if we reached that value that we want.

210
00:10:24,000 --> 00:10:34,000
So if intensity is bigger or equals to target intensity, then we set intensity equals to target intensity

211
00:10:35,000 --> 00:10:37,000
and we want to stop doing this changes.

212
00:10:37,000 --> 00:10:39,000
So let's create a boolean.

213
00:10:39,000 --> 00:10:45,000
Crime on the ball can change at intense intensity.

214
00:10:46,000 --> 00:10:49,000
And we're going to set can change intensity to false.

215
00:10:49,000 --> 00:10:52,000
Now we need to the same for decreasing the value.

216
00:10:53,000 --> 00:10:55,000
So if intensity.

217
00:10:55,000 --> 00:10:58,000
Is bigger than target intensity.

218
00:10:59,000 --> 00:11:02,000
Then we're going to change it to the lower value.

219
00:11:02,000 --> 00:11:06,000
So intensity minus equals change rate multiplied by time.

220
00:11:06,000 --> 00:11:13,000
The delta time, if intensity is less or equals to target intensity, what was that target?

221
00:11:15,000 --> 00:11:19,000
Target intensity, then intensity equals target.

222
00:11:19,000 --> 00:11:21,000
Intensity can change.

223
00:11:21,000 --> 00:11:23,000
Intensity equals false.

224
00:11:23,000 --> 00:11:24,000
Good enough.

225
00:11:24,000 --> 00:11:27,000
Now let's make an update that I deleted for no reason.

226
00:11:27,000 --> 00:11:28,000
Update.

227
00:11:29,000 --> 00:11:34,000
Date and I want to change intensity by pressing the button for now.

228
00:11:34,000 --> 00:11:37,000
So I will do if input dot.

229
00:11:39,000 --> 00:11:44,000
Get key down E code R then.

230
00:11:47,000 --> 00:11:48,000
Can change.

231
00:11:48,000 --> 00:11:52,000
Intensity equals true and lower over here we're going to do if.

232
00:11:53,000 --> 00:11:56,000
Can change intensity, then change intensity.

233
00:11:58,000 --> 00:11:59,000
Yeah, something like that.

234
00:11:59,000 --> 00:12:03,000
And we're going to set target intensity with our hands, so it's fine.

235
00:12:04,000 --> 00:12:09,000
The only thing I want to do is to set default value for change rate, and it's going to be 0.05 F.

236
00:12:09,000 --> 00:12:13,000
We really need a small value and minimum value we define before.

237
00:12:13,000 --> 00:12:20,000
So it's going to be minimum 1.2 F and a weight point to F and maximum will be.

238
00:12:20,000 --> 00:12:23,000
.49 F, Let's go back.

239
00:12:24,000 --> 00:12:27,000
So we have target intensity and let's go to play mode.

240
00:12:27,000 --> 00:12:28,000
We can see intensity over here.

241
00:12:32,000 --> 00:12:39,000
So let's say I'll set target intensity to point four and I'll click my R button, my input, boom,

242
00:12:39,000 --> 00:12:43,000
it's increasing until it reaches 0.4.

243
00:12:47,000 --> 00:12:48,000
And then stopped.

244
00:12:48,000 --> 00:12:49,000
Very good.

245
00:12:49,000 --> 00:12:53,000
I'm going to change it again to point one and press the button.

246
00:12:53,000 --> 00:12:54,000
Are.

247
00:12:55,000 --> 00:12:56,000
It's decreasing.

248
00:12:57,000 --> 00:12:58,000
Very nice.

249
00:12:58,000 --> 00:13:04,000
Now we need to connect these to rain intensities from the rain script to rain controller.

250
00:13:05,000 --> 00:13:08,000
Luckily for us, the value in the script is public, if you remember.

251
00:13:08,000 --> 00:13:09,000
Over here.

252
00:13:10,000 --> 00:13:11,000
Let me go to base.

253
00:13:13,000 --> 00:13:16,000
Rain intensity is public so we can get access to that.

254
00:13:16,000 --> 00:13:19,000
We want to get access to the component of rain script on the same game object.

255
00:13:19,000 --> 00:13:23,000
So I'm going to do private.

256
00:13:24,000 --> 00:13:27,000
Rain script to RD rain controller.

257
00:13:27,000 --> 00:13:33,000
And I want to show you another way of getting component how you could do it without start function and

258
00:13:33,000 --> 00:13:35,000
without dragging objects in the inspector.

259
00:13:35,000 --> 00:13:40,000
You can do return get component of rain script to D.

260
00:13:41,000 --> 00:13:42,000
Yeah, this will work as well.

261
00:13:42,000 --> 00:13:49,000
Now, in the update we're going to do rain controller dot rain intensity equals to intensity.

262
00:13:49,000 --> 00:13:56,000
So we're going to assign an intensity of the rain script to DX to our intensity in this script.

263
00:13:56,000 --> 00:13:58,000
Pretty simple, right?

264
00:13:59,000 --> 00:14:00,000
I hope so.

265
00:14:01,000 --> 00:14:06,000
And instead of pressing the button, I want to do it randomly from time to time.

266
00:14:06,000 --> 00:14:07,000
So I want to make.

267
00:14:08,000 --> 00:14:10,000
Serialize field private float.

268
00:14:11,000 --> 00:14:14,000
Chance to do rain.

269
00:14:14,000 --> 00:14:16,000
And default value will be 40.

270
00:14:16,000 --> 00:14:18,000
Then we need cool down time.

271
00:14:18,000 --> 00:14:22,000
So how often are we going to check if it's going to rain now or if it's going to stop?

272
00:14:22,000 --> 00:14:24,000
Serialize field.

273
00:14:25,000 --> 00:14:26,000
Pilot float.

274
00:14:26,000 --> 00:14:27,000
Rain check.

275
00:14:27,000 --> 00:14:28,000
Cool down.

276
00:14:28,000 --> 00:14:30,000
And then we need a timer.

277
00:14:30,000 --> 00:14:32,000
So, private float, rain check.

278
00:14:32,000 --> 00:14:33,000
Timer.

279
00:14:33,000 --> 00:14:35,000
Let's decrease the timer all the time.

280
00:14:35,000 --> 00:14:36,000
Rain check.

281
00:14:36,000 --> 00:14:39,000
Timer minus equals time, dot delta time.

282
00:14:39,000 --> 00:14:43,000
And then we need a function.

283
00:14:43,000 --> 00:14:44,000
I'm going to create a function here.

284
00:14:45,000 --> 00:14:45,000
Private void.

285
00:14:45,000 --> 00:14:47,000
Check or rain.

286
00:14:48,000 --> 00:14:49,000
Inside.

287
00:14:49,000 --> 00:14:51,000
We're going to say if.

288
00:14:52,000 --> 00:14:54,000
What was that timer?

289
00:14:54,000 --> 00:14:55,000
Hammer, Rain check.

290
00:14:56,000 --> 00:14:57,000
Sorry.

291
00:14:59,000 --> 00:15:01,000
Rain check timer is less than zero.

292
00:15:01,000 --> 00:15:07,000
Then we're going to set rain check timer to cool down so it won't work for some time.

293
00:15:08,000 --> 00:15:09,000
Cool down.

294
00:15:11,000 --> 00:15:13,000
And then we're going to change the intensity, the target intensity.

295
00:15:13,000 --> 00:15:22,000
We have target intensity equals to random range between mean value and max value.

296
00:15:22,000 --> 00:15:25,000
Then we're going to say we can change intensity.

297
00:15:25,000 --> 00:15:28,000
Now can change intensity equals to true.

298
00:15:30,000 --> 00:15:31,000
And we're going to put it in the update.

299
00:15:33,000 --> 00:15:34,000
Check for rain.

300
00:15:37,000 --> 00:15:43,000
So now it will work and it will check the rain every now and then according to the cool down we have.

301
00:15:43,000 --> 00:15:48,000
But there is a slight issue and it's always going to set value from minimum to maximum.

302
00:15:49,000 --> 00:15:54,000
And in this way there will be always rain just with a different intensity.

303
00:15:54,000 --> 00:15:58,000
So what I want to do here is to stop rain sometimes, like at all.

304
00:15:58,000 --> 00:15:59,000
How are we going to do this?

305
00:15:59,000 --> 00:16:01,000
We're going to use this chance to rain.

306
00:16:01,000 --> 00:16:03,000
We're going to do if check.

307
00:16:05,000 --> 00:16:13,000
Simple check if random range from 0 to 100 is bigger than chance to rain.

308
00:16:15,000 --> 00:16:19,000
Then we're going to set target intensity to random between minimum and maximum.

309
00:16:19,000 --> 00:16:26,000
And if it's not, then we're going to set target intensity to zero and it's going to decrease and it

310
00:16:26,000 --> 00:16:28,000
won't do anything for next 40 seconds.

311
00:16:28,000 --> 00:16:31,000
And then we can change intensity to true.

312
00:16:31,000 --> 00:16:33,000
I'm going to place it here to avoid confusion.

313
00:16:35,000 --> 00:16:35,000
And.

314
00:16:35,000 --> 00:16:36,000
Yeah.

315
00:16:37,000 --> 00:16:38,000
Good enough.

316
00:16:38,000 --> 00:16:39,000
We done with the script.

317
00:16:41,000 --> 00:16:42,000
How do you like it?

318
00:16:42,000 --> 00:16:43,000
I like it.

319
00:16:47,000 --> 00:16:52,000
I will set raincheck cooldown to 2 seconds and our chance to rain is zero for some reason.

320
00:16:53,000 --> 00:16:54,000
I'll try.

321
00:16:54,000 --> 00:16:55,000
I'll try 99.

322
00:16:56,000 --> 00:16:59,000
Let's go to play mode and see how does it work for us.

323
00:16:59,000 --> 00:17:03,000
So it's going to check every 2 seconds, which is pretty open so we can see changes if they work or

324
00:17:03,000 --> 00:17:04,000
not.

325
00:17:06,000 --> 00:17:07,000
What's that?

326
00:17:11,000 --> 00:17:11,000
Did.

327
00:17:11,000 --> 00:17:13,000
I think I put the wrong sign.

328
00:17:14,000 --> 00:17:15,000
If I'll put one here.

329
00:17:16,000 --> 00:17:17,000
Yeah.

330
00:17:17,000 --> 00:17:18,000
I.

331
00:17:18,000 --> 00:17:18,000
We need to fix.

332
00:17:18,000 --> 00:17:19,000
Let's do it right now.

333
00:17:20,000 --> 00:17:23,000
This one should be less than.

334
00:17:24,000 --> 00:17:25,000
Yeah, right.

335
00:17:25,000 --> 00:17:26,000
If random range.

336
00:17:26,000 --> 00:17:27,000
If values less than chance to rain.

337
00:17:31,000 --> 00:17:35,000
So now with a high chance, it's going to rain all the time and because of the high cooldown, we can

338
00:17:35,000 --> 00:17:38,000
see how it's changing from there to there all the time.

339
00:17:41,000 --> 00:17:48,000
What we can do next to fix it is to set code down to something bigger, like 20 seconds.

340
00:17:49,000 --> 00:17:54,000
And chance the rain can be maybe 40 or something about that.

341
00:17:57,000 --> 00:18:00,000
And now I'll try to run for some time and see how does it work for me.

342
00:18:03,000 --> 00:18:07,000
This drops water and drops bouncing off the traps of the player.

343
00:18:07,000 --> 00:18:08,000
Looks pretty nice.

344
00:18:12,000 --> 00:18:13,000
Rain stopped.

345
00:18:17,000 --> 00:18:21,000
Okay, let's say that chance is pretty low, so we need to we need to increase the chance.

346
00:18:22,000 --> 00:18:24,000
So maybe a chance to rent can be 5050.

347
00:18:24,000 --> 00:18:25,000
I don't know, guys.

348
00:18:25,000 --> 00:18:26,000
This is all about balance.

349
00:18:26,000 --> 00:18:28,000
How often you want it to rain.

350
00:18:28,000 --> 00:18:30,000
But we did it.

351
00:18:30,000 --> 00:18:33,000
Script is working and let's go into the next video.

352
00:18:33,000 --> 00:18:35,000
Let's make beautiful skybox.

