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

2
00:00:03,510 --> 00:00:06,060
to the last video and this one

3
00:00:06,060 --> 00:00:07,980
we are going to fix all of

4
00:00:07,980 --> 00:00:11,870
these small details related to the UI display,

5
00:00:11,865 --> 00:00:14,915
related to the Bitcoin coming from level to

6
00:00:14,910 --> 00:00:18,000
level and all of the other fun stuff.

7
00:00:18,000 --> 00:00:22,840
So let's not waste any more time and let's get started.

8
00:00:23,180 --> 00:00:27,240
Oh, okay, so now we need to fix

9
00:00:27,240 --> 00:00:30,840
the problem of our enemies not finding the player.

10
00:00:30,840 --> 00:00:32,880
We also want to make sure that

11
00:00:32,880 --> 00:00:34,910
we have the game manager as

12
00:00:34,905 --> 00:00:38,135
a singleton pattern because we obviously want to

13
00:00:38,130 --> 00:00:41,760
keep our bitcoins going from level to level.

14
00:00:41,755 --> 00:00:44,975
So for that, I'm going to issue a challenge,

15
00:00:44,975 --> 00:00:46,615
and your challenge is to find

16
00:00:46,610 --> 00:00:48,430
the player and find them on.

17
00:00:48,425 --> 00:00:49,585
So first of all,

18
00:00:49,580 --> 00:00:51,350
make sure that the enemies keep

19
00:00:51,350 --> 00:00:54,040
looking for the player until we find them.

20
00:00:54,035 --> 00:00:56,935
So this will be need to be a while loop

21
00:00:56,930 --> 00:00:58,190
inside of the update and

22
00:00:58,190 --> 00:01:00,260
the enemy controller. That's a small him.

23
00:01:00,260 --> 00:01:02,960
We want to keep our Bitcoins from scene to scene.

24
00:01:02,960 --> 00:01:05,060
So make the game manager

25
00:01:05,060 --> 00:01:08,380
a singleton pattern just like we did with the layer.

26
00:01:08,375 --> 00:01:11,035
Make sure you do the same for the game manager.

27
00:01:11,030 --> 00:01:14,050
Does it appear in the hierarchy and the resident destroy?

28
00:01:14,045 --> 00:01:18,845
So remember when we made the app layer Aidan destroy,

29
00:01:18,844 --> 00:01:21,684
it appeared in the hierarchy under a certain tab,

30
00:01:21,680 --> 00:01:22,990
which is did onDestroy.

31
00:01:22,985 --> 00:01:25,375
Will the game manager also appear?

32
00:01:25,370 --> 00:01:28,280
So test it out because we need to make sure that

33
00:01:28,280 --> 00:01:32,170
the game manager isn't a child of the managers.

34
00:01:32,165 --> 00:01:34,405
So the only way to make sure that he

35
00:01:34,400 --> 00:01:36,920
does not get destroyed is to make

36
00:01:36,920 --> 00:01:39,290
sure he is not a child of

37
00:01:39,290 --> 00:01:43,760
the whole managers game objects so well that information.

38
00:01:43,760 --> 00:01:48,020
Pause the video right now and go do it alone.

39
00:01:48,019 --> 00:01:50,539
Oh, okay, welcome back.

40
00:01:50,540 --> 00:01:52,490
So first thing first

41
00:01:52,490 --> 00:01:54,770
we're going to go into the enemy controller.

42
00:01:54,770 --> 00:01:59,420
Let's scroll up to update and an update in here.

43
00:01:59,420 --> 00:02:02,020
I'm going to check that while

44
00:02:02,015 --> 00:02:08,255
the player to chase is equal to null,

45
00:02:08,255 --> 00:02:12,175
we are going to go ahead and get the player to chase

46
00:02:12,170 --> 00:02:16,220
or set dipolar to chase to be find objects of type.

47
00:02:16,220 --> 00:02:18,490
Object five, sorry.

48
00:02:18,485 --> 00:02:21,575
And it's going to be the player controller.

49
00:02:21,575 --> 00:02:23,485
And it's going to be

50
00:02:23,480 --> 00:02:26,350
v dot transform because declared to chase,

51
00:02:26,345 --> 00:02:29,155
as we remember, is a transport.

52
00:02:29,150 --> 00:02:31,880
So we access the transform after refined

53
00:02:31,880 --> 00:02:35,260
the object which has the player controller on him.

54
00:02:35,255 --> 00:02:36,665
So this should work,

55
00:02:36,665 --> 00:02:38,275
but as long as we're here,

56
00:02:38,270 --> 00:02:41,660
let's go to the where is the game manager?

57
00:02:41,659 --> 00:02:44,329
Scroll up the instance.

58
00:02:44,330 --> 00:02:49,070
And in here I'm going to find the player controller.

59
00:02:49,070 --> 00:02:51,080
And it plays now, okay,

60
00:02:51,080 --> 00:02:53,030
So player controller, it's right here.

61
00:02:53,030 --> 00:02:54,230
I'm going to copy

62
00:02:54,230 --> 00:02:57,050
exact same code and

63
00:02:57,050 --> 00:03:00,130
paste it in here and remove this instance.

64
00:03:00,125 --> 00:03:03,895
Save that. So now we have a singleton pattern.

65
00:03:03,890 --> 00:03:07,580
We check if there is an instance, we destroy it.

66
00:03:07,580 --> 00:03:09,500
If the instance is different than null,

67
00:03:09,500 --> 00:03:12,700
we destroyed and we set a new instance.

68
00:03:12,695 --> 00:03:13,975
We save all of that.

69
00:03:13,970 --> 00:03:16,020
Let's go back into our game

70
00:03:16,020 --> 00:03:18,160
and let's see what we need to do in here.

71
00:03:18,160 --> 00:03:20,380
So the first thing we need to do is we

72
00:03:20,380 --> 00:03:23,160
need to open up the game manager in here,

73
00:03:23,155 --> 00:03:27,235
and we need to remove the game manager out of here.

74
00:03:27,235 --> 00:03:29,715
No, it will not allow me that we see in the

75
00:03:29,710 --> 00:03:32,730
prefab if I already have the gain managers.

76
00:03:32,725 --> 00:03:34,605
So Manager, the game manager.

77
00:03:34,600 --> 00:03:36,980
So I'm going to open the managers

78
00:03:36,984 --> 00:03:39,674
and I'm going to remove the game manager.

79
00:03:39,670 --> 00:03:41,290
So this will remove the game manager

80
00:03:41,290 --> 00:03:43,530
from all other scenes.

81
00:03:43,525 --> 00:03:45,805
And I'm going to make sure that I

82
00:03:45,805 --> 00:03:48,645
just have the game manager in here.

83
00:03:48,640 --> 00:03:50,560
So no other managers,

84
00:03:50,560 --> 00:03:52,080
one, sorry for that.

85
00:03:52,075 --> 00:03:54,765
We need the game manager only in the scene.

86
00:03:54,760 --> 00:03:56,140
So now we have the game manager,

87
00:03:56,140 --> 00:03:57,340
we have 0 but coins.

88
00:03:57,340 --> 00:03:58,650
Let's save all of that.

89
00:03:58,650 --> 00:04:01,010
Make this just a little bit bigger.

90
00:04:01,010 --> 00:04:03,020
Let's run it again.

91
00:04:03,020 --> 00:04:05,660
And let's see what happens.

92
00:04:05,660 --> 00:04:07,820
So we pick up the weapon,

93
00:04:07,820 --> 00:04:09,340
becomes a bit coins,

94
00:04:09,335 --> 00:04:11,105
we get hit once.

95
00:04:11,105 --> 00:04:13,895
Let's go to the next level.

96
00:04:13,895 --> 00:04:16,355
Let's see, we go to the next level.

97
00:04:16,355 --> 00:04:19,255
And there we go, We are on the new level and we can

98
00:04:19,250 --> 00:04:22,370
see that for some reason,

99
00:04:22,370 --> 00:04:24,160
do we have the enemies following?

100
00:04:24,155 --> 00:04:25,585
Nope, they are not following.

101
00:04:25,580 --> 00:04:26,860
There is something wrong.

102
00:04:26,855 --> 00:04:29,065
And as you can see, obviously the bitcoins

103
00:04:29,060 --> 00:04:31,420
and the health have not been updated.

104
00:04:31,415 --> 00:04:35,215
And that's because if we look on the player,

105
00:04:35,210 --> 00:04:39,190
if we look on the don't destroy the game manager,

106
00:04:39,185 --> 00:04:40,795
the Bitcoins also haven't been.

107
00:04:40,790 --> 00:04:42,410
So if we look on the player,

108
00:04:42,410 --> 00:04:44,690
you'll notice that his health is 490,

109
00:04:44,690 --> 00:04:47,230
but it's not being sent right here.

110
00:04:47,225 --> 00:04:50,045
Why? Because we only update,

111
00:04:50,045 --> 00:04:52,255
let me see, and the player health manager,

112
00:04:52,250 --> 00:04:55,250
we only update the player health once

113
00:04:55,250 --> 00:04:58,430
we get hit and not when we actually start.

114
00:04:58,430 --> 00:04:59,870
So we'll need to fix that also.

115
00:04:59,870 --> 00:05:01,190
But before we do that,

116
00:05:01,190 --> 00:05:02,870
there is something that is

117
00:05:02,870 --> 00:05:05,240
not quite right with the MS towards.

118
00:05:05,240 --> 00:05:07,310
So I'm going to pause the game right

119
00:05:07,310 --> 00:05:09,830
here and let's see what the problem is.

120
00:05:09,830 --> 00:05:11,890
So you can see that each one of

121
00:05:11,885 --> 00:05:15,135
our enemies is not being able to find us.

122
00:05:15,130 --> 00:05:16,450
So I'm going to double-click.

123
00:05:16,445 --> 00:05:19,385
And the problem is with the player Chase right here.

124
00:05:19,385 --> 00:05:22,095
So let's see what we are going to do about that.

125
00:05:22,095 --> 00:05:25,215
Oh, okay, so I went through

126
00:05:25,210 --> 00:05:28,420
a couple of things and finally found the solution.

127
00:05:28,420 --> 00:05:30,510
So the problem in here was,

128
00:05:30,505 --> 00:05:31,795
and it's very simple,

129
00:05:31,795 --> 00:05:33,465
we just need to move

130
00:05:33,460 --> 00:05:37,120
this while loop up here over all of this.

131
00:05:37,120 --> 00:05:38,440
And we might want to

132
00:05:38,440 --> 00:05:40,480
extract this into some kind of method.

133
00:05:40,480 --> 00:05:43,030
So I'm going to call this method

134
00:05:43,030 --> 00:05:48,040
finding player or making sure we have the player.

135
00:05:48,040 --> 00:05:50,110
So why do we move it up here?

136
00:05:50,110 --> 00:05:52,750
Well, because if we try to call

137
00:05:52,750 --> 00:05:56,040
the moving towards, save that.

138
00:05:56,035 --> 00:05:59,925
So what's the whole problem in the whole problem and

139
00:05:59,920 --> 00:06:03,220
the whole thing that is causing this is when we

140
00:06:03,220 --> 00:06:06,580
go to a new level before the layer,

141
00:06:06,580 --> 00:06:09,370
which is the one that doesn't get destroyed,

142
00:06:09,370 --> 00:06:11,020
gets to the next level.

143
00:06:11,020 --> 00:06:13,510
The enemies already have a target,

144
00:06:13,510 --> 00:06:15,360
which was the previous player.

145
00:06:15,355 --> 00:06:17,175
So once we destroy him,

146
00:06:17,170 --> 00:06:19,150
we can no longer find him.

147
00:06:19,150 --> 00:06:20,860
So if we try that,

148
00:06:20,860 --> 00:06:22,890
say we wanted them to the new level,

149
00:06:22,885 --> 00:06:25,485
we have all the players chase set

150
00:06:25,480 --> 00:06:28,230
right here in the start and then we destroy him.

151
00:06:28,225 --> 00:06:30,105
And then we try to chase

152
00:06:30,100 --> 00:06:32,470
the player or move towards the player,

153
00:06:32,470 --> 00:06:34,600
and that's where the error was coming from.

154
00:06:34,600 --> 00:06:37,330
So right here we are trying to chase the player.

155
00:06:37,330 --> 00:06:39,510
And once there is an error in here,

156
00:06:39,505 --> 00:06:41,305
nothing under this works.

157
00:06:41,305 --> 00:06:43,735
The update stops, everything stops.

158
00:06:43,735 --> 00:06:47,165
So that's why we need to be having the finding player.

159
00:06:47,160 --> 00:06:51,410
First thing we do an update before we continue on,

160
00:06:51,410 --> 00:06:53,000
while we might just need

161
00:06:53,000 --> 00:06:54,820
the if statement in here, I believe,

162
00:06:54,815 --> 00:06:56,435
but let's keep it as well,

163
00:06:56,435 --> 00:06:58,555
just in case it takes a bit of five.

164
00:06:58,550 --> 00:07:00,160
So with that out of the way,

165
00:07:00,155 --> 00:07:02,545
if now we run the game,

166
00:07:02,540 --> 00:07:06,840
we should see that when we go to the next level.

167
00:07:07,810 --> 00:07:10,730
There we go, we have no errors.

168
00:07:10,730 --> 00:07:12,500
We open this up and there we go.

169
00:07:12,500 --> 00:07:14,090
The cowardly enemies are

170
00:07:14,090 --> 00:07:16,240
running away and they are shooting at.

171
00:07:16,235 --> 00:07:18,065
So what that out of the way,

172
00:07:18,065 --> 00:07:20,035
next thing we need to do is obviously we

173
00:07:20,030 --> 00:07:22,400
need to update the player UI.

174
00:07:22,400 --> 00:07:25,610
So I'm going to go into the UI Manager.

175
00:07:25,610 --> 00:07:27,440
We stop the game. Yep, we did.

176
00:07:27,440 --> 00:07:29,360
Back in the UI Manager.

177
00:07:29,360 --> 00:07:32,510
Here I'm going to create a method that is going to be

178
00:07:32,510 --> 00:07:38,290
the public void update layer UI.

179
00:07:38,285 --> 00:07:40,915
And we are going to do a couple of things in here.

180
00:07:40,910 --> 00:07:43,370
So the first thing we're going to do is we're

181
00:07:43,370 --> 00:07:46,540
going to create a player health handler.

182
00:07:46,535 --> 00:07:49,175
Deep layer health colored,

183
00:07:49,175 --> 00:07:51,395
and it's going to be equal to null.

184
00:07:51,395 --> 00:07:52,975
And you'll see why in just a bit,

185
00:07:52,970 --> 00:07:55,150
because we are going to create

186
00:07:55,145 --> 00:07:59,435
a while loop that will check for the player health.

187
00:07:59,435 --> 00:08:01,165
And while it's null,

188
00:08:01,160 --> 00:08:03,380
we are going to keep looking for

189
00:08:03,380 --> 00:08:08,570
the player health to be equal to find objects of type.

190
00:08:08,570 --> 00:08:12,820
And it's going to be the layer health handler.

191
00:08:12,815 --> 00:08:14,555
And once we find that,

192
00:08:14,555 --> 00:08:16,415
we can exit the while loop.

193
00:08:16,415 --> 00:08:17,905
And then in here we are going

194
00:08:17,900 --> 00:08:19,460
to go ahead and first of all

195
00:08:19,460 --> 00:08:22,490
get the health slider dot max value.

196
00:08:22,490 --> 00:08:24,650
And it's going to be equal to the player

197
00:08:24,650 --> 00:08:28,370
health dot get max value.

198
00:08:28,370 --> 00:08:31,010
So obviously we need to create some kind of way to

199
00:08:31,010 --> 00:08:34,150
access the max out on the player health handler.

200
00:08:34,145 --> 00:08:36,085
What do we have any year, Okay,

201
00:08:36,080 --> 00:08:37,900
so they are serialized field.

202
00:08:37,895 --> 00:08:42,595
Let's go ahead and create a public and

203
00:08:42,590 --> 00:08:51,990
get layer max health.

204
00:08:52,600 --> 00:09:00,970
And we're just going to return V-max.

205
00:09:00,965 --> 00:09:02,215
Have not.

206
00:09:02,210 --> 00:09:03,590
We already have one of those.

207
00:09:03,590 --> 00:09:04,840
No, we don't.

208
00:09:04,835 --> 00:09:07,345
Let's go ahead and create the good layer,

209
00:09:07,340 --> 00:09:10,630
current health also, as long as we're here.

210
00:09:10,625 --> 00:09:16,005
So the current health and what else do we need from here?

211
00:09:16,005 --> 00:09:18,125
We might need the,

212
00:09:18,125 --> 00:09:20,225
Nope, I think that's all that we need.

213
00:09:20,225 --> 00:09:23,975
So now we can get max health.

214
00:09:23,975 --> 00:09:25,645
And then we'll need to set

215
00:09:25,640 --> 00:09:30,080
the health slider dot value to be equal to

216
00:09:30,080 --> 00:09:36,920
the layer health dot get current health. Save that.

217
00:09:36,920 --> 00:09:38,060
What else do we need to do?

218
00:09:38,060 --> 00:09:42,470
We also need to find a way to update our text.

219
00:09:42,470 --> 00:09:46,010
So I'm going to say the, what was it called?

220
00:09:46,010 --> 00:09:49,100
The Health text, was it called the health tech step?

221
00:09:49,100 --> 00:09:51,020
There we go, and it's public also.

222
00:09:51,020 --> 00:09:52,160
Great.

223
00:09:52,160 --> 00:09:54,440
So scroll down here.

224
00:09:54,440 --> 00:09:58,840
So the health, health flexed dot

225
00:09:58,835 --> 00:10:06,005
text will be equal to the player health dot get current.

226
00:10:06,000 --> 00:10:08,320
The current health.

227
00:10:08,320 --> 00:10:13,290
And it's plus the slash.

228
00:10:13,285 --> 00:10:16,245
And was the max health.

229
00:10:16,240 --> 00:10:20,210
So Player health dot GetMax self.

230
00:10:20,400 --> 00:10:23,320
There we go. So everything is set,

231
00:10:23,320 --> 00:10:25,690
but I'm going to do something in here.

232
00:10:25,690 --> 00:10:29,140
And that's right, a debug dot log.

233
00:10:29,140 --> 00:10:36,500
And I just want to keep track of the same acts Health.

234
00:10:37,740 --> 00:10:41,160
And let me just get this one.

235
00:10:41,155 --> 00:10:44,295
And this will make sense in just a bit.

236
00:10:44,290 --> 00:10:47,600
So upset this one in here.

237
00:10:51,630 --> 00:10:54,090
And you'll see why in just a bit.

238
00:10:54,085 --> 00:10:55,765
So I'm going to save all of that.

239
00:10:55,765 --> 00:10:57,865
I'm going to go back into Unity.

240
00:10:57,865 --> 00:10:59,785
I'm going to run the game.

241
00:10:59,785 --> 00:11:03,045
I'm going to pick apartment becomes the Bitcoins.

242
00:11:03,040 --> 00:11:04,110
Get hit.

243
00:11:04,105 --> 00:11:07,005
Please get it. Okay, So there we go.

244
00:11:07,000 --> 00:11:08,760
Go through the world,

245
00:11:08,755 --> 00:11:11,535
go through the portal, go to the next level,

246
00:11:11,530 --> 00:11:13,510
and you can see that it's 100 in here,

247
00:11:13,510 --> 00:11:17,340
even though if I press on the layer, it's for 90.

248
00:11:17,335 --> 00:11:19,855
So what do you think is the problem?

249
00:11:19,855 --> 00:11:21,285
I'm just going to give you a couple

250
00:11:21,280 --> 00:11:23,310
of seconds to think about it.

251
00:11:23,305 --> 00:11:28,105
The problem was and I'll tell you what the problem is.

252
00:11:28,105 --> 00:11:32,715
First of all, we need to update player health.

253
00:11:32,715 --> 00:11:37,175
So update the layer health or player UI.

254
00:11:37,175 --> 00:11:39,415
Now let's go ahead and test it out.

255
00:11:39,410 --> 00:11:42,010
Maybe you saw it in the debugger.

256
00:11:42,005 --> 00:11:44,605
I just noticed that we didn't even call them methods.

257
00:11:44,600 --> 00:11:46,130
So there you go. Debug works,

258
00:11:46,130 --> 00:11:47,810
I'm going to get it.

259
00:11:47,810 --> 00:11:49,490
Go through the larval,

260
00:11:49,490 --> 00:11:51,400
go through the portal.

261
00:11:51,395 --> 00:11:53,155
And what's the health?

262
00:11:53,150 --> 00:11:58,180
So the max health is 50 and the current health is 0.

263
00:11:58,175 --> 00:12:00,975
What do you think is the problem?

264
00:12:00,979 --> 00:12:02,599
Well, the problem is

265
00:12:02,600 --> 00:12:04,450
just like we said in the previous video,

266
00:12:04,445 --> 00:12:06,385
we already had a player in

267
00:12:06,380 --> 00:12:08,720
the scene and that player was destroyed.

268
00:12:08,720 --> 00:12:12,640
So once we want to set this house bar and the tax,

269
00:12:12,635 --> 00:12:15,625
they are being set based on the old player.

270
00:12:15,620 --> 00:12:17,840
So in order to set the new player,

271
00:12:17,840 --> 00:12:19,700
what do you think we should do?

272
00:12:19,700 --> 00:12:22,550
While there are many solutions to this problem,

273
00:12:22,550 --> 00:12:25,480
but I found that the best one is to just have

274
00:12:25,475 --> 00:12:28,555
a simple way of converting this

275
00:12:28,550 --> 00:12:32,270
from a public voice to a public art and numerator.

276
00:12:32,270 --> 00:12:37,830
And then we are going to yield return.

277
00:12:38,050 --> 00:12:42,340
New. Wait four seconds.

278
00:12:42,335 --> 00:12:44,905
And let's just wait 0.1 and

279
00:12:44,900 --> 00:12:47,440
it will be the time while the,

280
00:12:47,435 --> 00:12:49,345
don't forget, we have a fainting image

281
00:12:49,340 --> 00:12:50,360
that we've turned off just

282
00:12:50,360 --> 00:12:53,620
for the sake of speeding the process of testing out.

283
00:12:53,615 --> 00:12:57,325
So now what will happen is we will wait 0.1

284
00:12:57,320 --> 00:12:59,270
seconds and during that time

285
00:12:59,270 --> 00:13:01,130
the older player will be destroyed,

286
00:13:01,130 --> 00:13:02,980
the new player will be found,

287
00:13:02,975 --> 00:13:06,005
and we will immediately get our update.

288
00:13:06,005 --> 00:13:08,555
So in here, instead of updates player,

289
00:13:08,555 --> 00:13:11,905
I'm going to start a co-routine,

290
00:13:11,900 --> 00:13:14,920
which is going to be the update layer health you.

291
00:13:14,915 --> 00:13:18,485
I save that back into our game.

292
00:13:18,485 --> 00:13:24,295
We run the game. We get it.

293
00:13:24,290 --> 00:13:29,930
We go out, we go through this one, and there we go.

294
00:13:29,930 --> 00:13:31,600
We can see that our health has been

295
00:13:31,595 --> 00:13:33,505
updated and it's very seamless.

296
00:13:33,500 --> 00:13:34,610
So there we go,

297
00:13:34,610 --> 00:13:37,880
We can see everything is working perfectly fine.

298
00:13:37,880 --> 00:13:39,860
And first of all, we also have the Bitcoins,

299
00:13:39,860 --> 00:13:42,340
so we need to fix that also in here.

300
00:13:42,335 --> 00:13:44,815
And what we also want to do is we want to make

301
00:13:44,810 --> 00:13:47,480
sure that we spawned in the proper position.

302
00:13:47,480 --> 00:13:50,420
So currently, respond right next to the portal,

303
00:13:50,420 --> 00:13:51,470
which is not helpful.

304
00:13:51,470 --> 00:13:53,060
Our goal is to get to

305
00:13:53,060 --> 00:13:55,760
that portal and not just spawn in there.

306
00:13:55,760 --> 00:13:57,460
So I'm going to,

307
00:13:57,455 --> 00:13:58,835
first of all in here,

308
00:13:58,835 --> 00:14:00,055
Let's see what we need to do.

309
00:14:00,050 --> 00:14:03,590
So we need to do we have the Bitcoin text,

310
00:14:03,590 --> 00:14:06,130
the BTC effects. There we go.

311
00:14:06,125 --> 00:14:14,455
So BTC text, the text is equal to find or no,

312
00:14:14,450 --> 00:14:19,550
we have the game manager, the on instance.

313
00:14:19,550 --> 00:14:23,510
Get, but continous. We go,

314
00:14:23,510 --> 00:14:24,830
I believe this one returns

315
00:14:24,830 --> 00:14:27,350
the bitcoins all know this as Bitcoin.

316
00:14:27,350 --> 00:14:31,210
So if I go to the game manager to have,

317
00:14:31,205 --> 00:14:32,645
get current Bitcoin, so I

318
00:14:32,645 --> 00:14:36,275
can get current Bitcoin, save that.

319
00:14:36,275 --> 00:14:39,415
And this should be working except for it's not

320
00:14:39,410 --> 00:14:41,690
because you cannot implicitly

321
00:14:41,690 --> 00:14:43,520
convert the type and two strings.

322
00:14:43,520 --> 00:14:45,910
So the two string,

323
00:14:45,905 --> 00:14:49,015
this converts anything play string, save that.

324
00:14:49,010 --> 00:14:53,720
Let's test this out a little bit from the game.

325
00:14:53,720 --> 00:14:59,390
And now we pick up a coin and we go to the next level.

326
00:14:59,390 --> 00:15:01,670
Okay, so now we should see we

327
00:15:01,670 --> 00:15:03,370
have in here ten, there we go.

328
00:15:03,365 --> 00:15:05,965
It takes time, but it will not be noticeable,

329
00:15:05,960 --> 00:15:08,090
especially once we have the fate image,

330
00:15:08,090 --> 00:15:11,690
but now we need to spawn the player at a certain point.

331
00:15:11,690 --> 00:15:13,730
So I'm going to go into

332
00:15:13,730 --> 00:15:15,470
the level manager and I'm going to

333
00:15:15,470 --> 00:15:17,710
do this at the level manager.

334
00:15:17,705 --> 00:15:21,865
And I'm going to scroll down in here.

335
00:15:21,860 --> 00:15:24,340
And I'm going to create a new method.

336
00:15:24,335 --> 00:15:26,435
So under here we are going to create

337
00:15:26,435 --> 00:15:29,405
a new method which is a public void and

338
00:15:29,405 --> 00:15:36,595
its spot layer and point and input player in point,

339
00:15:36,590 --> 00:15:41,270
we are going to get the player controller dot instance,

340
00:15:41,270 --> 00:15:45,910
dot not instantiate, dot dance,

341
00:15:45,905 --> 00:15:47,185
play a bullet controller.

342
00:15:47,180 --> 00:15:52,300
Okay, So layer controller instance.

343
00:15:52,295 --> 00:15:54,595
And we're going to use

344
00:15:54,590 --> 00:15:56,840
the dot transform position

345
00:15:56,840 --> 00:15:58,910
and it's going to be equal to some kind

346
00:15:58,910 --> 00:16:06,770
of spawn point, the position.

347
00:16:06,770 --> 00:16:09,410
And now I'm going to copy this and

348
00:16:09,410 --> 00:16:12,720
create a serialized field up here.

349
00:16:13,270 --> 00:16:19,030
Of the transform and it's going to be the spawn point.

350
00:16:19,025 --> 00:16:21,685
Scroll down and see how that looks. Yep, there we go.

351
00:16:21,680 --> 00:16:23,990
So what happens in here is we put the player on

352
00:16:23,990 --> 00:16:26,690
the point from the start.

353
00:16:26,690 --> 00:16:29,730
Where does it start?

354
00:16:30,010 --> 00:16:34,820
In here we are going to put layer point.

355
00:16:34,820 --> 00:16:36,220
We save all of that.

356
00:16:36,215 --> 00:16:37,705
And what happens in here is as

357
00:16:37,700 --> 00:16:39,440
soon as the level manager starts,

358
00:16:39,440 --> 00:16:41,470
remember it's not a ton destroyer,

359
00:16:41,465 --> 00:16:44,395
it's not a single combat on the player controller

360
00:16:44,390 --> 00:16:46,520
dot instance dot position is

361
00:16:46,520 --> 00:16:48,770
put immediately on the spot point.

362
00:16:48,770 --> 00:16:50,390
So back in here,

363
00:16:50,390 --> 00:16:52,840
we already have these palm points.

364
00:16:52,835 --> 00:16:56,885
We are spawn points 1.

365
00:16:56,885 --> 00:17:00,865
So I'm going to create a new in here and it's going

366
00:17:00,860 --> 00:17:06,310
to be layer on spawn.

367
00:17:06,305 --> 00:17:09,005
And where is it and the scene.

368
00:17:09,005 --> 00:17:11,945
Let's see, and it's going to be about here.

369
00:17:11,945 --> 00:17:14,605
Save that if we go to another level,

370
00:17:14,600 --> 00:17:17,420
we can actually go ahead and override this.

371
00:17:17,420 --> 00:17:19,690
So in the manager override

372
00:17:19,685 --> 00:17:22,045
and you can choose what do you want to override?

373
00:17:22,040 --> 00:17:23,800
Keep in mind, we don't want to

374
00:17:23,795 --> 00:17:25,675
overwrite the spawn points because

375
00:17:25,670 --> 00:17:27,590
for every single level

376
00:17:27,590 --> 00:17:29,630
there will be a different spawn point.

377
00:17:29,630 --> 00:17:33,020
So I'm going to apply override

378
00:17:33,020 --> 00:17:36,320
the prefab manager's level manager,

379
00:17:36,320 --> 00:17:39,790
maybe also apply overwrite prefer manager.

380
00:17:39,785 --> 00:17:40,835
There we go.

381
00:17:40,835 --> 00:17:44,725
And here the player spawn points.

382
00:17:44,720 --> 00:17:46,700
Let's go ahead and

383
00:17:46,700 --> 00:17:50,120
also apply the prefab to the whole prefer.

384
00:17:50,120 --> 00:17:52,600
Okay, great. So make sure you don't apply.

385
00:17:52,595 --> 00:17:54,545
All, save all of that.

386
00:17:54,545 --> 00:17:57,665
And now I'm going to run the game.

387
00:17:57,850 --> 00:18:02,480
I'm going to go into a new level.

388
00:18:02,480 --> 00:18:05,180
And we should. Nope, we didn't.

389
00:18:05,180 --> 00:18:10,370
That's because because we oh, okay.

390
00:18:10,370 --> 00:18:11,020
Okay. Okay.

391
00:18:11,015 --> 00:18:14,795
So the problem is here and 11 manager,

392
00:18:14,795 --> 00:18:17,125
what's the problem in here?

393
00:18:17,120 --> 00:18:18,920
If we scroll up to them,

394
00:18:18,920 --> 00:18:25,420
we spawn point and the level manager.

395
00:18:25,415 --> 00:18:28,765
What seems to be the problem?

396
00:18:28,760 --> 00:18:31,270
Also, there we go, It's in here.

397
00:18:31,265 --> 00:18:33,895
We need to set it. And now we need to go to

398
00:18:33,890 --> 00:18:38,790
the level managers and apply the changes to.

399
00:18:46,860 --> 00:18:50,300
So now when we run,

400
00:18:51,330 --> 00:18:56,050
we should see if we go to the next level.

401
00:18:56,050 --> 00:18:57,940
No, it's still not working.

402
00:18:57,940 --> 00:18:59,140
So what's the problem?

403
00:18:59,140 --> 00:19:02,260
The variable has not been assigned.

404
00:19:02,260 --> 00:19:09,230
So I think there is something not rapidly set right here.

405
00:19:20,610 --> 00:19:25,060
So apply to prefab level manager.

406
00:19:25,064 --> 00:19:28,234
And what else is the problem?

407
00:19:28,235 --> 00:19:30,685
So I think in the other level,

408
00:19:30,680 --> 00:19:34,090
the spawn point isn't getting properly set.

409
00:19:34,085 --> 00:19:36,205
So I'm trying to apply the changes.

410
00:19:36,200 --> 00:19:37,720
Maybe this time it will work.

411
00:19:37,715 --> 00:19:39,595
Nope, it still doesn't because if we

412
00:19:39,590 --> 00:19:41,650
go to the manager's level manager,

413
00:19:41,645 --> 00:19:44,315
player spawn point on the level manager,

414
00:19:44,315 --> 00:19:45,685
it is not even set.

415
00:19:45,680 --> 00:19:48,740
So what do you think of a problem in here is,

416
00:19:48,740 --> 00:19:50,780
I think we made some kind of mistake

417
00:19:50,780 --> 00:19:52,910
because everything in here has been reset.

418
00:19:52,910 --> 00:19:55,610
So you can see right here that these are not being set.

419
00:19:55,610 --> 00:19:57,590
So I'm going to apply all for now.

420
00:19:57,590 --> 00:20:00,220
This is not the best idea,

421
00:20:00,215 --> 00:20:02,105
but let's not worry about that for now.

422
00:20:02,105 --> 00:20:04,765
I'm going to go to the next level and make sure that

423
00:20:04,760 --> 00:20:07,840
we finally spawn on the proper point.

424
00:20:07,835 --> 00:20:10,345
But right now we will have also spawning.

425
00:20:10,340 --> 00:20:11,930
And here, as you can see,

426
00:20:11,930 --> 00:20:13,580
but we don't want that because

427
00:20:13,580 --> 00:20:15,320
each level will have its own enemies,

428
00:20:15,320 --> 00:20:17,210
will have its own levels, sorry,

429
00:20:17,210 --> 00:20:19,150
waves, and so on and so forth.

430
00:20:19,145 --> 00:20:21,355
But as you can see, everything works.

431
00:20:21,350 --> 00:20:24,350
The only problem still in our game is

432
00:20:24,350 --> 00:20:27,560
the fact that when we go to the door,

433
00:20:27,560 --> 00:20:30,130
this pops up that first time and when we open it,

434
00:20:30,125 --> 00:20:31,315
when we go away,

435
00:20:31,310 --> 00:20:32,890
it does not go.

436
00:20:32,885 --> 00:20:34,525
I mean, the words do not appear

437
00:20:34,520 --> 00:20:37,130
again and the door does not close again.

438
00:20:37,130 --> 00:20:39,640
Why? Because in the room

439
00:20:39,635 --> 00:20:42,095
that you've created and this was a mistake by me.

440
00:20:42,095 --> 00:20:43,475
We turn off the door.

441
00:20:43,475 --> 00:20:44,785
So we turn off the door,

442
00:20:44,780 --> 00:20:47,720
but the text display is always on the door.

443
00:20:47,720 --> 00:20:51,730
So I'm going to leave this as a final challenge to you.

444
00:20:51,725 --> 00:20:54,205
Do outside of the realm of the scores.

445
00:20:54,200 --> 00:20:55,970
All that you need to do is

446
00:20:55,970 --> 00:20:58,370
remove this text displayed from

447
00:20:58,370 --> 00:21:02,950
the door and put it on the portal right here,

448
00:21:02,945 --> 00:21:05,155
and then move it right here.

449
00:21:05,150 --> 00:21:08,600
So the Canvas will need to be knocked on the door,

450
00:21:08,600 --> 00:21:11,840
it will have to be on the portal and you'll need to

451
00:21:11,840 --> 00:21:15,250
turn off the door on and off based on the text,

452
00:21:15,245 --> 00:21:17,345
there will be a bit of changes to the code.

453
00:21:17,345 --> 00:21:19,495
But I think at this point,

454
00:21:19,490 --> 00:21:22,520
you have become such a good game developer at a,

455
00:21:22,520 --> 00:21:25,670
such a high level with all the long,

456
00:21:25,670 --> 00:21:27,890
long videos that I've taught you through.

457
00:21:27,890 --> 00:21:29,900
I hope you enjoyed this video.

458
00:21:29,900 --> 00:21:31,730
I hope you enjoyed this whole course.

459
00:21:31,730 --> 00:21:33,170
I hope you learned a lot.

460
00:21:33,170 --> 00:21:35,940
I hope you enjoy the journey and the process.

461
00:21:35,944 --> 00:21:39,234
And I hope you weren't too angry when I made mistakes.

462
00:21:39,235 --> 00:21:40,525
I hope you are liking

463
00:21:40,520 --> 00:21:43,210
the transparency that I'm showing you.

464
00:21:43,205 --> 00:21:44,485
And if you haven't already,

465
00:21:44,480 --> 00:21:45,920
of course, leave me a review,

466
00:21:45,920 --> 00:21:47,940
make sure you join the discord

467
00:21:47,944 --> 00:21:50,134
and I'll see you

468
00:21:50,135 --> 00:21:53,185
maybe not in the next video because this one,

469
00:21:53,180 --> 00:21:54,520
this is the last one.

470
00:21:54,515 --> 00:21:56,665
Maybe someday in the future,

471
00:21:56,660 --> 00:21:57,820
we will keep in touch.

472
00:21:57,815 --> 00:22:01,735
No worries about that. Thank you so much for watching.

473
00:22:01,730 --> 00:22:03,630
Goodbye.

