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

2
00:00:03,420 --> 00:00:05,850
to a brand new video and this one,

3
00:00:05,850 --> 00:00:08,160
instead of just adding the points

4
00:00:08,160 --> 00:00:10,640
to our layer or to our game manager,

5
00:00:10,635 --> 00:00:13,245
we actually have this coin right here.

6
00:00:13,245 --> 00:00:15,225
And as you can see, it rotates.

7
00:00:15,225 --> 00:00:16,415
It's really cool.

8
00:00:16,410 --> 00:00:18,920
And if you hear when we pick it up,

9
00:00:18,915 --> 00:00:21,815
there is a small explosion.

10
00:00:21,810 --> 00:00:23,010
Why an explosion?

11
00:00:23,010 --> 00:00:25,320
Because I didn't take the time to actually find

12
00:00:25,320 --> 00:00:28,920
some sound effect for the picking up of the coin.

13
00:00:28,920 --> 00:00:30,900
So with that of the way,

14
00:00:30,900 --> 00:00:35,040
let's not waste any more time and let's get started.

15
00:00:35,035 --> 00:00:36,865
Oh, okay.

16
00:00:36,860 --> 00:00:38,810
So time to start actually

17
00:00:38,810 --> 00:00:41,270
picking up the money that we've created.

18
00:00:41,270 --> 00:00:43,570
So I'm going to clear all of this.

19
00:00:43,565 --> 00:00:45,325
I'm going to open the script and

20
00:00:45,320 --> 00:00:47,630
remove what we have in here for

21
00:00:47,630 --> 00:00:49,760
the BBC or whatever it

22
00:00:49,760 --> 00:00:52,450
is displaying and adding using the keyboard.

23
00:00:52,445 --> 00:00:55,835
So back in here way for it to compile.

24
00:00:55,835 --> 00:00:59,485
And in the sprites in here,

25
00:00:59,480 --> 00:01:05,300
I'm going to create a new folder for the coins.

26
00:01:05,300 --> 00:01:08,000
Double-click, open this up and I'm going

27
00:01:08,000 --> 00:01:10,430
to go into the resources in here.

28
00:01:10,430 --> 00:01:11,690
And as you can see,

29
00:01:11,690 --> 00:01:14,450
we have the rotating coin,

30
00:01:14,450 --> 00:01:18,560
the coin blink and the coin shine.

31
00:01:18,560 --> 00:01:20,320
So choose whichever you want.

32
00:01:20,315 --> 00:01:24,425
I want the rotate because I like to see the coins rotate.

33
00:01:24,425 --> 00:01:28,555
So at this end here opens up.

34
00:01:28,550 --> 00:01:30,950
Let's see what these look like.

35
00:01:30,950 --> 00:01:34,430
Really nice coins, but I feel that they might be a

36
00:01:34,430 --> 00:01:35,990
little bit out of place with

37
00:01:35,990 --> 00:01:38,110
the 2D graphics that we have,

38
00:01:38,105 --> 00:01:39,905
but no worries, we are using

39
00:01:39,905 --> 00:01:41,875
free assets from open game art.

40
00:01:41,870 --> 00:01:43,430
So there we go.

41
00:01:43,430 --> 00:01:44,890
We add this in here.

42
00:01:44,885 --> 00:01:46,945
This will be a huge coin.

43
00:01:46,940 --> 00:01:50,570
Prepare for the huge Coyne.

44
00:01:50,570 --> 00:01:52,700
Whoa, I never thought,

45
00:01:52,700 --> 00:01:55,160
I really didn't know this coin would be that huge.

46
00:01:55,160 --> 00:01:59,220
So let's make it a bit smaller.

47
00:01:59,590 --> 00:02:01,630
Even more.

48
00:02:01,625 --> 00:02:04,375
So 400, lets see.

49
00:02:04,370 --> 00:02:08,450
We can, by the way, you make the scaling a bit smaller,

50
00:02:08,450 --> 00:02:10,970
but I like to change the pixels per unit.

51
00:02:10,970 --> 00:02:14,270
And even this, Let's make it 800.

52
00:02:14,270 --> 00:02:16,490
So we make two

53
00:02:16,490 --> 00:02:19,330
times smaller than whatever it is right now.

54
00:02:19,325 --> 00:02:21,215
That's still huge.

55
00:02:21,215 --> 00:02:25,765
And let's make it 1600.

56
00:02:25,760 --> 00:02:27,250
So come on, please.

57
00:02:27,245 --> 00:02:29,795
We needed a bit smaller.

58
00:02:29,795 --> 00:02:31,865
Oh my God.

59
00:02:31,865 --> 00:02:34,585
I would not expect this amount.

60
00:02:34,580 --> 00:02:38,710
3500 seriously, this should be very small right now.

61
00:02:38,705 --> 00:02:39,505
Okay, Great.

62
00:02:39,500 --> 00:02:42,130
So I think this coin, There we go.

63
00:02:42,125 --> 00:02:44,485
So this is a small coin that is

64
00:02:44,480 --> 00:02:47,480
going to be rotating around and we can pick it up.

65
00:02:47,480 --> 00:02:49,370
And actually, you know what,

66
00:02:49,370 --> 00:02:52,050
maybe make it 3000.

67
00:02:52,300 --> 00:02:55,100
And there we go, apply the changes.

68
00:02:55,100 --> 00:02:56,920
Let's make it point.

69
00:02:56,915 --> 00:03:00,845
Point, and we don't need to make multiple.

70
00:03:00,845 --> 00:03:02,605
There we go, save that.

71
00:03:02,600 --> 00:03:08,270
Now this is going to be the Bitcoin 0 case.

72
00:03:08,270 --> 00:03:11,210
So now what we're going to do is we're going to

73
00:03:11,210 --> 00:03:14,500
go into the animation and create an animation.

74
00:03:14,495 --> 00:03:20,075
So an asset's animations right-click New Folder,

75
00:03:20,075 --> 00:03:27,265
rotating a Bitcoin, double-click in here and rotate.

76
00:03:27,260 --> 00:03:28,120
That's it.

77
00:03:28,115 --> 00:03:29,135
All we need to do.

78
00:03:29,135 --> 00:03:31,265
A drag these n and that's right.

79
00:03:31,265 --> 00:03:32,845
Okay, that's too fast.

80
00:03:32,840 --> 00:03:34,580
Let's separate them a bit.

81
00:03:34,580 --> 00:03:40,700
So every point, there we go,

82
00:03:40,700 --> 00:03:43,510
I think this is a good enough rotate.

83
00:03:43,505 --> 00:03:46,075
So and for some reason I feel

84
00:03:46,070 --> 00:03:48,590
that it's a bit annoying, but no worries.

85
00:03:48,590 --> 00:03:51,800
Now we're going to go ahead and add a new script in here.

86
00:03:51,800 --> 00:03:53,060
So I'm going to go into

87
00:03:53,060 --> 00:03:56,990
the scripts and to worship into the pickups.

88
00:03:56,990 --> 00:04:00,080
Right-click and create a new C-sharp script,

89
00:04:00,080 --> 00:04:05,310
which is going to be the go and pick up a coin.

90
00:04:06,760 --> 00:04:08,930
Pick up.

91
00:04:08,930 --> 00:04:13,730
There we go. So now we have the coin pickup.

92
00:04:13,730 --> 00:04:16,490
Let's make that smaller. There we go.

93
00:04:16,490 --> 00:04:19,460
So added to the Bitcoin and

94
00:04:19,460 --> 00:04:22,870
let's open it up and Visual Studio.

95
00:04:22,865 --> 00:04:25,535
So if I go get the health pickup,

96
00:04:25,535 --> 00:04:26,875
it's pretty much the same.

97
00:04:26,870 --> 00:04:29,470
So where is it?

98
00:04:29,465 --> 00:04:30,865
Where is the health pickup?

99
00:04:30,860 --> 00:04:32,530
So this is pretty much the same.

100
00:04:32,525 --> 00:04:34,745
I'm just going to copy the code.

101
00:04:34,745 --> 00:04:37,675
I'm going to paste it in here.

102
00:04:37,670 --> 00:04:39,170
And the only things that are

103
00:04:39,170 --> 00:04:40,730
going to change as for example,

104
00:04:40,730 --> 00:04:44,660
the coin amount that you will get from this coin,

105
00:04:44,660 --> 00:04:46,180
so I'll keep it at them.

106
00:04:46,175 --> 00:04:48,875
And maybe also the picked up,

107
00:04:48,875 --> 00:04:51,875
which is going to be good and pick it up.

108
00:04:51,875 --> 00:04:54,745
And k can be picked up method.

109
00:04:54,740 --> 00:04:57,740
Okay, so the pickup, the layer.

110
00:04:57,740 --> 00:05:00,170
That's obviously something that we are also

111
00:05:00,170 --> 00:05:02,180
going to add to the coin because later on

112
00:05:02,180 --> 00:05:06,710
we will want to maybe break a jar or kill an enemy.

113
00:05:06,710 --> 00:05:09,260
And so we want to have a bit of a delay.

114
00:05:09,260 --> 00:05:14,540
So at anytime now we are going to make this smaller

115
00:05:14,540 --> 00:05:17,420
at component the layers

116
00:05:17,420 --> 00:05:20,090
or pick up the layer. There we go.

117
00:05:20,090 --> 00:05:22,070
Time before pickup is 0.5,

118
00:05:22,070 --> 00:05:23,800
which is good enough for us.

119
00:05:23,795 --> 00:05:25,295
And then in here,

120
00:05:25,295 --> 00:05:26,695
what else do we need to do?

121
00:05:26,690 --> 00:05:28,100
We destroy the game object.

122
00:05:28,100 --> 00:05:30,430
We, instead of adding HP,

123
00:05:30,425 --> 00:05:32,545
we are going to remove this.

124
00:05:32,540 --> 00:05:35,230
And we are going to make sure in here,

125
00:05:35,230 --> 00:05:36,740
we can also remove the player

126
00:05:36,740 --> 00:05:38,680
will set it on the pickup layer.

127
00:05:38,675 --> 00:05:40,345
So pickups.

128
00:05:40,340 --> 00:05:44,980
And remember we stopped using the layer, layer.

129
00:05:44,975 --> 00:05:48,395
I mean, sorry, the player tag in order to pick up things.

130
00:05:48,395 --> 00:05:50,125
And in here we said the pickup true,

131
00:05:50,120 --> 00:05:51,680
so we don't pick up twice.

132
00:05:51,680 --> 00:05:54,950
And in here we should actually increase

133
00:05:54,950 --> 00:05:56,720
the amount of coins that we

134
00:05:56,720 --> 00:05:59,410
have and that is going to be a challenge.

135
00:05:59,405 --> 00:06:02,755
You. So add the coin and playing a sound effect.

136
00:06:02,750 --> 00:06:03,980
So first of all, create

137
00:06:03,980 --> 00:06:06,530
the level manager and add the coins to it.

138
00:06:06,530 --> 00:06:09,890
Dicey create, I meant get the level manager and the coins

139
00:06:09,890 --> 00:06:11,690
to it and play the sound effects

140
00:06:11,690 --> 00:06:13,400
when we pick up the coins,

141
00:06:13,400 --> 00:06:15,320
you can choose whatever sound the fracture like.

142
00:06:15,320 --> 00:06:17,680
Maybe you can even go and get your own,

143
00:06:17,675 --> 00:06:19,675
find some if I would then provide you

144
00:06:19,670 --> 00:06:21,710
with an so that out of the way,

145
00:06:21,710 --> 00:06:26,110
pause the video right now and go to the challenge.

146
00:06:26,105 --> 00:06:28,015
Okay, welcome back.

147
00:06:28,010 --> 00:06:29,720
So in here we are going to get

148
00:06:29,720 --> 00:06:31,760
the level manager, or sorry,

149
00:06:31,760 --> 00:06:33,820
not the level manager, the game manager,

150
00:06:33,815 --> 00:06:36,535
but the game manager is not an instance.

151
00:06:36,530 --> 00:06:38,770
So in here we're going to create

152
00:06:38,765 --> 00:06:44,455
a public static Game Manager.

153
00:06:44,450 --> 00:06:46,040
We can find the object,

154
00:06:46,040 --> 00:06:47,600
that's something we could have done,

155
00:06:47,600 --> 00:06:49,160
but because we are going to

156
00:06:49,160 --> 00:06:50,780
maybe access at multiple times,

157
00:06:50,780 --> 00:06:53,270
I believe having an instance is better.

158
00:06:53,270 --> 00:06:56,150
So in here, I'm going to set the awake

159
00:06:56,150 --> 00:06:59,840
and instance equals this.

160
00:06:59,840 --> 00:07:00,740
Save that.

161
00:07:00,740 --> 00:07:02,830
Let's remove the start and update for now.

162
00:07:02,825 --> 00:07:05,935
If we need them, we will create them later on.

163
00:07:05,930 --> 00:07:08,350
Save that back in the pickup.

164
00:07:08,345 --> 00:07:09,365
Game.

165
00:07:09,365 --> 00:07:11,315
Manager.

166
00:07:11,440 --> 00:07:19,210
Dot instance, dot, add coin or get coins, get bitcoins.

167
00:07:19,205 --> 00:07:20,665
And how much do we want?

168
00:07:20,660 --> 00:07:22,520
It's the coin amount.

169
00:07:22,520 --> 00:07:26,510
Save that, and now we want to play the audio.

170
00:07:26,510 --> 00:07:30,250
So AudioManager, you manager

171
00:07:30,245 --> 00:07:33,295
the instance that play as

172
00:07:33,290 --> 00:07:36,590
a fax and which sound effect do we want to play?

173
00:07:36,590 --> 00:07:38,290
We could create it in here.

174
00:07:38,285 --> 00:07:39,505
Yeah, sure, let's do it.

175
00:07:39,500 --> 00:07:44,780
So the sandbox to play.

176
00:07:44,780 --> 00:07:46,400
There we go.

177
00:07:46,400 --> 00:07:49,400
As a fax to play, save that.

178
00:07:49,400 --> 00:07:51,770
And back in our game.

179
00:07:51,770 --> 00:07:54,170
Let's see what we have in here.

180
00:07:54,170 --> 00:07:56,630
And the Audio Manager,

181
00:07:56,630 --> 00:07:59,060
where is it the Audio Manager?

182
00:07:59,060 --> 00:08:00,650
And what do we have

183
00:08:00,650 --> 00:08:02,720
the explosion, enemy rifles, shotguns,

184
00:08:02,720 --> 00:08:08,860
typer player getting hit, pistol shot, explosion.

185
00:08:08,855 --> 00:08:10,855
Let's add the Explosion. Sure. Why not?

186
00:08:10,850 --> 00:08:13,210
Because I can't find any common pickup.

187
00:08:13,205 --> 00:08:14,845
You can add anything that you want.

188
00:08:14,840 --> 00:08:16,790
It's just need some kind of metal.

189
00:08:16,790 --> 00:08:18,440
Actually, I think I did add

190
00:08:18,440 --> 00:08:20,450
something in here but we didn't add it.

191
00:08:20,450 --> 00:08:22,930
Anyways, let's use the explosion just for fun.

192
00:08:22,925 --> 00:08:25,195
Anyways, element two.

193
00:08:25,190 --> 00:08:29,650
So the two save that, run the game.

194
00:08:29,645 --> 00:08:32,675
And now when we get to the coin,

195
00:08:32,675 --> 00:08:37,805
we should hear nothing at all because in here,

196
00:08:37,804 --> 00:08:40,294
no, there is no error there.

197
00:08:40,295 --> 00:08:41,095
Ok?

198
00:08:41,090 --> 00:08:41,690
No.

199
00:08:41,690 --> 00:08:43,850
But didn't even destroy itself.

200
00:08:43,850 --> 00:08:45,890
So there is a problem.

201
00:08:45,890 --> 00:08:48,070
And get component.

202
00:08:48,065 --> 00:08:52,285
Pick up layer has not been picked up.

203
00:08:52,280 --> 00:08:55,220
Let's see, because this must be simple.

204
00:08:55,220 --> 00:09:00,280
Let's wait for this maybe timer 0.5.

205
00:09:00,275 --> 00:09:04,735
Nope, not working at all.

206
00:09:04,730 --> 00:09:08,530
So let's see what the problem is.

207
00:09:08,525 --> 00:09:11,035
0, okay, come back.

208
00:09:11,030 --> 00:09:15,490
So we create an On Trigger Enter.

209
00:09:15,485 --> 00:09:20,875
That's fine, but we don't have a trigger to trigger this.

210
00:09:20,870 --> 00:09:25,070
So we need to add a box collider or circular

211
00:09:25,070 --> 00:09:30,380
collider 2D and make it a trigger.

212
00:09:30,380 --> 00:09:31,970
So the circle collider,

213
00:09:31,970 --> 00:09:34,690
I believe, is extremely huge.

214
00:09:34,685 --> 00:09:36,625
No, where is it?

215
00:09:36,620 --> 00:09:40,420
Although it's exactly on the coin, That's excellent.

216
00:09:40,415 --> 00:09:42,095
Save that, run the game.

217
00:09:42,095 --> 00:09:45,275
Now we should unmute the music.

218
00:09:46,810 --> 00:09:50,090
And you could hear a faint sound of

219
00:09:50,090 --> 00:09:52,790
the explosion in the background. I could hear it.

220
00:09:52,790 --> 00:09:54,820
I hope you could have heard it.

221
00:09:54,815 --> 00:09:56,305
We go to the prefabs,

222
00:09:56,300 --> 00:10:01,300
we go to the pickups and we said the Bitcoin right here.

223
00:10:01,295 --> 00:10:02,755
So I hope you enjoy it.

224
00:10:02,750 --> 00:10:04,700
Make sure to commit your changes,

225
00:10:04,700 --> 00:10:05,900
make sure to leave a review.

226
00:10:05,900 --> 00:10:07,730
It helped me out a lot and I'll see

227
00:10:07,730 --> 00:10:10,770
you in the next video.

