Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:06,656 --> 00:00:12,544
That you may know those guys that when we actually play here
2
00:00:13,312 --> 00:00:14,848
The Clare
3
00:00:15,616 --> 00:00:18,688
Loses references to a couple things
4
00:00:18,944 --> 00:00:20,480
When we actually go to the next scene
5
00:00:24,320 --> 00:00:27,136
Tell before we enter the new level or the new scene
6
00:00:27,392 --> 00:00:28,672
I've got the new player here
7
00:00:29,696 --> 00:00:35,072
And you know that we have some references here to the coins the health bar and the inventory on the radio
8
00:00:35,328 --> 00:00:37,632
How far coins in inventory item
9
00:00:38,656 --> 00:00:40,704
So because these UI elements
10
00:00:40,960 --> 00:00:44,544
Are going to destroy when we actually go to a new scene
11
00:00:44,800 --> 00:00:47,360
Because we haven't actually Mark them to not destroy
12
00:00:48,640 --> 00:00:49,664
When we enter the new scene
13
00:00:50,432 --> 00:00:53,248
We are going to lose those references ok
14
00:00:53,504 --> 00:00:59,648
Even though level 2 does include a new UI game object with all of the various items inside of it
15
00:01:00,123 --> 00:01:02,619
Subtitled by
-♪ online-courses.club ♪-
We compress knowledge for you!
https://t.me/joinchat/ailxpXoW3JVjYzQ1
16
00:01:02,620 --> 00:01:05,792
The player here is trying to find a reference to the ones that were on a last scene
17
00:01:07,072 --> 00:01:08,352
With a missing image
18
00:01:08,608 --> 00:01:10,400
Missing image in missing text
19
00:01:11,424 --> 00:01:17,568
So when we try and collect something is confused it doesn't know where I put it right where do I put the health where do I put the UI
20
00:01:18,848 --> 00:01:20,640
So what we need to do
21
00:01:20,896 --> 00:01:22,432
Is creates something called
22
00:01:22,688 --> 00:01:23,968
A game manager
23
00:01:25,248 --> 00:01:31,392
Don't wait to talk about the game manager a lot of you probably wondering when we were going to do a game manager
24
00:01:31,904 --> 00:01:36,512
I want to wait because this is the perfect example of why you need a game manager
25
00:01:36,768 --> 00:01:41,888
Game manager is a great place to store references to various UI elements
26
00:01:42,144 --> 00:01:48,288
Maybe some inventory as well some additional inventory to reply or maybe when I move all of the players inventory
27
00:01:48,544 --> 00:01:50,080
To a game manager script
28
00:01:50,336 --> 00:01:52,640
Islam things you could do with a game images script
29
00:01:52,896 --> 00:01:59,040
I'm basically a game manager a good way of thinking of it is like a backpack for the player or for the game
30
00:01:59,296 --> 00:02:03,392
So as the player is not destroyed in moves from scene to scene
31
00:02:03,904 --> 00:02:10,048
The game manager is going to follow along with him storing references to various values game objects UI
32
00:02:10,304 --> 00:02:11,072
Etc
33
00:02:11,584 --> 00:02:17,216
So basically what we want to do here is Rachel and move all of our UI elements into a new game on
34
00:02:17,984 --> 00:02:20,288
Make sure everything's deselected here
35
00:02:21,056 --> 00:02:24,128
I'm going to create an empty gameobject I'm going to call this
36
00:02:24,384 --> 00:02:25,664
Game manager
37
00:02:29,248 --> 00:02:32,064
What you want to do is just make sure that the position is zero
38
00:02:32,832 --> 00:02:35,904
By the way guys have you noticed that when you create a new game object
39
00:02:36,160 --> 00:02:37,696
And it says recttransform
40
00:02:37,952 --> 00:02:41,792
That's because when you are selected and you create an empty child
41
00:02:42,560 --> 00:02:47,168
It's actually creating in empty gameobject with a rect transform
42
00:02:47,424 --> 00:02:53,568
By default because we were inside of a UI canvas just be careful when you're creating new game objects from here
43
00:02:54,592 --> 00:02:58,944
Solicitors in game managing just make sure everything is $0 and the scale is 31
44
00:02:59,456 --> 00:03:04,320
The reason why is because we're going to drag the UI prefab and put it inside of the game manager
45
00:03:04,576 --> 00:03:05,088
Ok
46
00:03:06,368 --> 00:03:09,696
So why are we just making the UI a game manager
47
00:03:09,952 --> 00:03:14,048
What's because we can put other game objects inside of this game manager
48
00:03:14,304 --> 00:03:17,632
Any game it treated like a backpack that follows the play around
49
00:03:18,144 --> 00:03:20,448
The movie the other items may be a
50
00:03:20,704 --> 00:03:24,032
Cheat codes prefab or a main menu or a Paz menu
51
00:03:24,800 --> 00:03:27,360
Can I see you have none of those destroy
52
00:03:27,872 --> 00:03:29,920
Well you will have them inside of the game manager here
53
00:03:30,944 --> 00:03:33,248
Ok it's the next thing I want to do is just create
54
00:03:33,760 --> 00:03:35,040
Can you see shop script
55
00:03:35,552 --> 00:03:36,320
We're going to call it
56
00:03:36,832 --> 00:03:37,344
Game
57
00:03:38,368 --> 00:03:39,648
Manager what happened
58
00:03:42,464 --> 00:03:48,608
By default unity knows that game managers are important
59
00:03:48,864 --> 00:03:49,888
Create a Cooler
60
00:03:50,400 --> 00:03:51,424
I can't hear
61
00:03:51,680 --> 00:03:53,472
Hey hey this is the game manager
62
00:03:53,728 --> 00:03:59,872
There is no limitation about what you can do with the game and you can do whatever you want with the game manager in
63
00:04:00,128 --> 00:04:01,664
Play a game manager is going to be
64
00:04:02,176 --> 00:04:02,944
Different
65
00:04:03,200 --> 00:04:06,016
Turn developer you might read it totally different then I will
66
00:04:06,528 --> 00:04:08,832
Just drag this game manager
67
00:04:10,112 --> 00:04:10,880
Emergency
68
00:04:11,904 --> 00:04:15,488
And wrinkly office manager here
69
00:04:15,744 --> 00:04:21,887
And the first thing I want to do guys as we want this team manager to follow the player around wherever he goes right
70
00:04:22,143 --> 00:04:23,423
So what does that mean
71
00:04:23,935 --> 00:04:26,495
Will it put a new player in you remember what we did here
72
00:04:26,751 --> 00:04:27,775
On start
73
00:04:28,799 --> 00:04:31,871
We said don't destroy on load ok so do that
74
00:04:33,919 --> 00:04:37,759
On start don't destroy on load
75
00:04:38,527 --> 00:04:40,063
What do you not want to destroy
76
00:04:40,575 --> 00:04:41,599
This game magic
77
00:04:42,111 --> 00:04:48,255
Anytime you have a lowercase game object instead of a gameobject means you referencing this game object
78
00:04:49,279 --> 00:04:50,303
That out
79
00:04:50,815 --> 00:04:52,351
Down Under Fire
80
00:04:53,119 --> 00:04:54,143
We renamed it
81
00:04:54,399 --> 00:04:55,679
Gohenry name it
82
00:04:57,215 --> 00:04:57,983
Play Magic
83
00:05:00,031 --> 00:05:00,543
Equals
84
00:05:01,823 --> 00:05:03,871
New game manager
85
00:05:05,151 --> 00:05:07,455
You can have it whenever you want it you can name it
86
00:05:07,711 --> 00:05:11,295
The master Dee manager or original Game manager
87
00:05:11,551 --> 00:05:17,695
Or maybe even getting manager but I'm going to rename a new game manager and
88
00:05:17,951 --> 00:05:24,095
The player is renamed to new player so anytime you see the word new in front of a game object it means that it's fear
89
00:05:24,351 --> 00:05:24,863
No one
90
00:05:25,119 --> 00:05:27,935
And it's not going to destroy and load of any scenes
91
00:05:28,191 --> 00:05:28,703
Ok
92
00:05:29,215 --> 00:05:31,007
That way when we go into a new scene
93
00:05:31,519 --> 00:05:37,663
The game manager on the new scene is going to go hey there something called you gave manager and not going to be in this scene
94
00:05:37,919 --> 00:05:38,687
What will destroy itself
95
00:05:40,991 --> 00:05:44,831
Where to take this awake function and do the same thing we did
96
00:05:45,343 --> 00:05:46,111
With new player
97
00:05:46,367 --> 00:05:47,391
Does copy that
98
00:05:47,647 --> 00:05:49,183
Go back to a game manager
99
00:05:50,207 --> 00:05:53,023
A member of week happens before star
100
00:05:53,535 --> 00:05:55,583
Ok so the moment we hit play
101
00:05:56,351 --> 00:05:57,375
We're gonna run this
102
00:05:57,631 --> 00:06:01,215
If there's a game object called new game manager
103
00:06:04,031 --> 00:06:04,799
Destroying
104
00:06:07,103 --> 00:06:08,639
What if we hit play
105
00:06:08,895 --> 00:06:11,455
And we load into the very first level
106
00:06:12,223 --> 00:06:15,295
Nothing's going to happen here because there's nothing called new game manager
107
00:06:16,063 --> 00:06:17,855
Dennis going to jump to the start function here
108
00:06:18,367 --> 00:06:19,135
Anything to say
109
00:06:19,647 --> 00:06:21,695
Don't destroy me and then rename me
110
00:06:22,463 --> 00:06:25,279
Play any other game managers better in another scene
111
00:06:25,791 --> 00:06:27,839
Find your game manager in going to get this
112
00:06:28,863 --> 00:06:30,655
Team logically working with
113
00:06:31,167 --> 00:06:32,191
For the new player
114
00:06:34,495 --> 00:06:36,543
There's one more thing you want to do
115
00:06:37,055 --> 00:06:40,127
When are we going heading created Singleton for the game manager as well
116
00:06:40,383 --> 00:06:42,175
So we can reference the game manager
117
00:06:42,943 --> 00:06:44,735
Just copy this
118
00:06:45,247 --> 00:06:46,527
From the new player script
119
00:06:47,551 --> 00:06:49,087
Just paste it right here
120
00:06:50,879 --> 00:06:52,671
This changed
121
00:06:52,927 --> 00:06:53,695
The words
122
00:06:54,719 --> 00:06:55,999
So we're just going to create
123
00:06:56,255 --> 00:06:57,023
An instance
124
00:06:58,047 --> 00:06:59,071
Navigate manage
125
00:06:59,839 --> 00:07:01,119
Is Singleton instance
126
00:07:02,399 --> 00:07:04,191
You just change out the word here
127
00:07:05,471 --> 00:07:06,239
Is it
128
00:07:06,495 --> 00:07:08,287
So now look at this one
129
00:07:09,055 --> 00:07:11,615
I can reference the game manager
130
00:07:12,127 --> 00:07:13,151
Whenever I want to
131
00:07:13,407 --> 00:07:18,527
So for example in new player I could go game manager that instance whatever
132
00:07:18,783 --> 00:07:23,135
This is where we can store certain variables in certain references
133
00:07:23,391 --> 00:07:26,463
And maybe we don't want to store inside of the player ok
134
00:07:26,719 --> 00:07:28,767
What's go ahead in test this out
135
00:07:29,279 --> 00:07:33,119
Before we had play I just make sure level 1 and level 2 match
136
00:07:33,375 --> 00:07:36,703
But save level 1 and level 2 Unit 2
137
00:07:36,959 --> 00:07:38,751
Does an actually have a game manager
138
00:07:39,263 --> 00:07:41,311
Why do we need a game in level 2
139
00:07:41,567 --> 00:07:43,871
Who won the game manager just going forward
140
00:07:44,383 --> 00:07:50,527
I mean honestly other than the environment changing we really want everything to be identical to level 1 we want the same
141
00:07:51,551 --> 00:07:53,087
We want the same game manager
142
00:07:53,343 --> 00:07:56,671
We want to see new y Paz menu etc ok
143
00:07:57,951 --> 00:08:01,023
So if we hit play on level 22 actually tested out
144
00:08:01,279 --> 00:08:03,839
Where I can get the same behaviour as level one
145
00:08:04,607 --> 00:08:06,655
Level 1 in the game manager now right
146
00:08:07,423 --> 00:08:10,239
I want to do is make sure the level two matches level one
147
00:08:10,495 --> 00:08:13,055
In terms of the UI the player the game manager etc
148
00:08:13,567 --> 00:08:16,383
So what we going to do is win a drag the game manager
149
00:08:16,895 --> 00:08:18,687
Over to a prefabs folder
150
00:08:19,711 --> 00:08:20,735
Now we have
151
00:08:21,759 --> 00:08:23,551
A game manager right
152
00:08:24,063 --> 00:08:28,927
So what you would do is if you got a little to make sure you save the level one
153
00:08:29,183 --> 00:08:31,743
If you got a lot of two words going to delete the UI
154
00:08:32,511 --> 00:08:34,303
Going to drag the game manager
155
00:08:36,351 --> 00:08:39,679
Again I need to clarify as much as I possibly can hear
156
00:08:40,703 --> 00:08:43,775
We're only putting a game manager instead of level 2
157
00:08:44,031 --> 00:08:46,079
So that we can test level two
158
00:08:46,335 --> 00:08:50,175
Or if we have a saved game and you're on level 2
159
00:08:50,431 --> 00:08:56,575
If we load Amelia from the main menu what we want to make sure everything in level 2 is there if we
160
00:08:56,831 --> 00:08:57,599
Right
161
00:08:57,855 --> 00:09:00,415
Just because the game manager in the player
162
00:09:00,671 --> 00:09:03,487
Iron level 1 in will load in the level 2
163
00:09:03,743 --> 00:09:08,095
Does it mean that we don't also need a game manager in a player in level 2
164
00:09:08,351 --> 00:09:12,191
Even when we load into this scene in me Lee from the main menu
165
00:09:12,703 --> 00:09:18,847
If that doesn't make sense guys just keep following along with me I will make sense especially when we start flashing out this prototype
166
00:09:19,103 --> 00:09:20,639
In making it a full-time game
167
00:09:21,151 --> 00:09:27,039
Ok so let's actually test at level 1 and level 2 and see if the game manager follows the player around
168
00:09:28,831 --> 00:09:29,599
Alright
169
00:09:29,855 --> 00:09:35,743
First off what's a new player and new game manager have been placed inside of the don't destroy on load
170
00:09:36,767 --> 00:09:42,399
Section of a hierarchy that's great that means that these two game objects and their children
171
00:09:43,935 --> 00:09:44,959
Well pretty much
172
00:09:46,751 --> 00:09:47,775
Survive
173
00:09:48,031 --> 00:09:49,055
Is a good way of putting
174
00:09:49,823 --> 00:09:51,359
A new scene load right
175
00:09:52,127 --> 00:09:54,687
Ok so we get the key was jump on over the next level
176
00:09:55,455 --> 00:09:57,759
So if we jump into the next level
177
00:09:58,271 --> 00:09:59,551
It looks like
178
00:10:00,345 --> 00:10:04,041
Subtitled by
-♪ online-courses.club ♪-
We compress knowledge for you!
https://t.me/joinchat/ailxpXoW3JVjYzQ1
179
00:10:04,042 --> 00:10:05,695
Alright but you are works perfectly
180
00:10:06,463 --> 00:10:08,255
And when we collect items
181
00:10:10,047 --> 00:10:10,815
Rui
182
00:10:12,863 --> 00:10:14,911
Still works that's perfect
183
00:10:15,679 --> 00:10:19,519
So you may wonder is the game manager just an empty script
184
00:10:19,775 --> 00:10:23,615
Is it just an empty gameobject that stores the other game objects
185
00:10:24,127 --> 00:10:30,271
The answer is no you actually want to store variables in references and maybe some inventory
186
00:10:30,527 --> 00:10:31,295
Game manager
187
00:10:31,807 --> 00:10:35,647
Mainly to make you feel saying while you're creating your game
188
00:10:35,903 --> 00:10:38,975
Is really about organisation of you game for the long term
189
00:10:39,487 --> 00:10:42,303
Not going to change anything for the players experience
190
00:10:42,815 --> 00:10:44,095
Variables
191
00:10:44,351 --> 00:10:45,631
In the new players script
192
00:10:46,143 --> 00:10:47,423
Can we actually store
193
00:10:47,679 --> 00:10:48,703
In the game manager
194
00:10:49,471 --> 00:10:54,591
Will you notice that we have an inventory item image reference then it's just referencing the inventory item
195
00:10:54,847 --> 00:10:56,383
So that we can actually swap it out
196
00:10:56,639 --> 00:10:58,431
Only collecting inventory item
197
00:10:59,199 --> 00:11:03,551
And we also have references in the new player script for the health bar in the coins
198
00:11:04,063 --> 00:11:10,207
Really good examples of things we should be storing inside of a game manager not necessarily the news
199
00:11:10,719 --> 00:11:14,047
Tell bear with me for just a second as we going to new player
200
00:11:14,303 --> 00:11:17,119
In actually move these three variables
201
00:11:17,631 --> 00:11:18,911
Inside of the game manager
202
00:11:19,167 --> 00:11:19,679
Ok
203
00:11:20,703 --> 00:11:24,031
Take these to hear the health bar and the coins text
204
00:11:24,287 --> 00:11:25,311
When you copy those
205
00:11:26,335 --> 00:11:28,127
Pace them is over game manager
206
00:11:29,151 --> 00:11:31,455
That's about right here save those
207
00:11:32,735 --> 00:11:34,271
And what else
208
00:11:34,527 --> 00:11:36,063
Inventory item image
209
00:11:36,319 --> 00:11:37,087
Will Take That
210
00:11:37,855 --> 00:11:38,623
Save it
211
00:11:39,135 --> 00:11:41,439
And then I stand here as well
212
00:11:42,207 --> 00:11:46,815
I don't worry guys you noticed that we have the red zig zag that's because we need to go to show potential fixes
213
00:11:47,583 --> 00:11:53,215
And also his using unityengine.ui is the solution here so why
214
00:11:55,007 --> 00:11:55,775
Add
215
00:11:56,287 --> 00:11:57,823
The namespace reference appear
216
00:11:58,335 --> 00:12:01,151
That means we can now use these UI references
217
00:12:01,407 --> 00:12:01,919
Ok
218
00:12:02,431 --> 00:12:03,199
Ok
219
00:12:03,455 --> 00:12:03,967
So
220
00:12:04,223 --> 00:12:06,015
Question back in unity and take a look
221
00:12:06,271 --> 00:12:12,415
Everything is working properly it looks like and get a tonne of errors which can make you
222
00:12:12,671 --> 00:12:15,487
Play don't worry guys the solution here is pretty simple like
223
00:12:15,743 --> 00:12:19,071
It says the name health bar does not exist in the current context
224
00:12:22,655 --> 00:12:27,263
Ok so it looks like because we moved the health bar reference
225
00:12:27,775 --> 00:12:29,311
Into the game manager
226
00:12:30,079 --> 00:12:31,615
Window actually make sure
227
00:12:31,871 --> 00:12:32,895
Changing
228
00:12:33,151 --> 00:12:34,943
How we get this reference ok
229
00:12:35,455 --> 00:12:41,343
1-hour interrogate manager so how do we get it we go game manager incidents health bar
230
00:12:42,623 --> 00:12:46,207
Into all we have to do is just paste this in front of all of these
231
00:12:46,975 --> 00:12:49,279
References to the UI elements
232
00:12:49,535 --> 00:12:51,839
Because now those references are stored
233
00:12:52,863 --> 00:12:54,143
Inside of a game manager
234
00:12:54,655 --> 00:12:55,167
Ok
235
00:12:58,239 --> 00:12:58,751
Alright
236
00:12:59,519 --> 00:13:00,543
Hopefully
237
00:13:01,311 --> 00:13:02,335
Everything is cleared out
238
00:13:03,615 --> 00:13:04,383
Now
239
00:13:04,639 --> 00:13:05,407
Wigan tip Leigh
240
00:13:06,943 --> 00:13:09,503
Looks like we have some no references here
241
00:13:10,271 --> 00:13:13,343
What's happening is we actually having to find
242
00:13:13,599 --> 00:13:15,391
Inside of the new game manager
243
00:13:15,647 --> 00:13:16,927
Where all of these are
244
00:13:17,695 --> 00:13:23,839
So we move them over to the manager but we need to make sure that we tell the game manager what the reference
245
00:13:24,607 --> 00:13:27,167
Actually pretty simple just drag health bar here
246
00:13:27,935 --> 00:13:28,959
Text here
247
00:13:29,471 --> 00:13:31,007
An inventory item image
248
00:13:31,263 --> 00:13:32,287
Here
249
00:13:32,543 --> 00:13:36,127
Nearest Aldi's turned bold again that's because we just change
250
00:13:36,383 --> 00:13:37,151
St. Aspen
251
00:13:37,407 --> 00:13:38,943
Navigate to the prefab
252
00:13:39,455 --> 00:13:45,599
We want to make sure that we apply all those changes to the everyday manager prefab in every scene
253
00:13:46,111 --> 00:13:47,391
Handel's references
254
00:13:47,903 --> 00:13:50,719
Thing is that these references
255
00:13:50,975 --> 00:13:53,791
Global rights of a level two
256
00:13:55,071 --> 00:13:56,607
Can I go to the game manager here
257
00:13:57,375 --> 00:14:02,751
It's not referencing the health bar from level one is actually referencing is child
258
00:14:03,519 --> 00:14:05,567
And child and Child
259
00:14:06,847 --> 00:14:09,919
Alright so let's go level one here and we can clear up these errors
260
00:14:10,943 --> 00:14:11,711
Can you play
261
00:14:13,503 --> 00:14:14,271
Alright
262
00:14:15,295 --> 00:14:16,319
Looks like
263
00:14:17,087 --> 00:14:18,623
Everything is in working order
264
00:14:19,391 --> 00:14:21,695
Just double check here go to the next scene
265
00:14:25,023 --> 00:14:31,167
Perfect alright
20708
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.