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,032
What we're gonna do now is really going to have the
2
00:00:12,288 --> 00:00:13,824
Health show up
3
00:00:14,080 --> 00:00:15,104
On screen
4
00:00:15,616 --> 00:00:18,944
And this is actually a really simple thing to do
5
00:00:19,200 --> 00:00:24,576
Are you going to do is actually create a new UI element so I'm going to do is go to gameobject here
6
00:00:25,344 --> 00:00:26,368
TUI
7
00:00:27,136 --> 00:00:28,928
What should I do with you I text
8
00:00:30,208 --> 00:00:36,352
Alright so what just happened here what will
9
00:00:36,608 --> 00:00:37,632
If you zoom out
10
00:00:38,656 --> 00:00:41,728
You can see that there is this Square
11
00:00:42,240 --> 00:00:44,544
I just appeared what is this thing
12
00:00:44,800 --> 00:00:47,616
Guys this is your little canvas
13
00:00:47,872 --> 00:00:49,152
This is basically
14
00:00:49,664 --> 00:00:50,432
Right here
15
00:00:51,200 --> 00:00:51,968
It's this
16
00:00:52,224 --> 00:00:54,272
3840 x 2160
17
00:00:55,040 --> 00:00:57,600
Parks that allows us to place text
18
00:00:58,880 --> 00:00:59,392
Intuit
19
00:00:59,648 --> 00:01:01,933
So it's scaled really strangely in the scene view
20
00:01:01,935 --> 00:01:04,411
Subtitled by
-♪ online-courses.club ♪-
We compress knowledge for you!
https://t.me/joinchat/ailxpXoW3JVjYzQ1
21
00:01:04,412 --> 00:01:06,048
But in the game view
22
00:01:07,072 --> 00:01:12,704
It will snap riding the place here this is just a way that unity allows us to edit text
23
00:01:13,472 --> 00:01:19,616
Bobbing in the same scene It might feel really confusing it's just something you gotta get used to it
24
00:01:19,872 --> 00:01:20,384
That's ok
25
00:01:20,640 --> 00:01:23,200
I'm going to do is going to drag this text
26
00:01:24,224 --> 00:01:26,272
All the way the top corner appear
27
00:01:27,552 --> 00:01:28,064
We go
28
00:01:28,832 --> 00:01:30,880
Take that ok
29
00:01:31,136 --> 00:01:36,000
So pretty small so we need to be a little bit bigger so we're gonna make sure the text is selected
30
00:01:36,512 --> 00:01:39,584
The font size here and we can make it like 35
31
00:01:39,840 --> 00:01:45,728
You'll never say disappeared that's because it's bigger than the box it's surrounding the text so what you do is you just go to the rectal
32
00:01:46,240 --> 00:01:48,544
Is drag a little bit bigger than it is right there
33
00:01:49,056 --> 00:01:49,824
Ok cool
34
00:01:50,336 --> 00:01:52,384
What's make sure this text is white
35
00:01:53,920 --> 00:01:56,224
And if you go to our game window
36
00:01:56,480 --> 00:01:58,272
Skragbad at MB bigger
37
00:01:58,528 --> 00:02:02,368
Can you see the next year so this is going to be our coins
38
00:02:03,392 --> 00:02:04,672
What's the better 0
39
00:02:05,696 --> 00:02:11,840
Gregory about France right now is going to worry about the size you notice it keeps getting bigger and out of its box
40
00:02:12,352 --> 00:02:16,448
That's ok I was just fixed the horizontal overflow to overflow
41
00:02:16,960 --> 00:02:19,008
And in the overflow to overflow
42
00:02:19,264 --> 00:02:21,824
Now it will show up regardless of the box size
43
00:02:22,336 --> 00:02:26,432
But I like the box to be a Queen size 11 like it to be like this
44
00:02:27,200 --> 00:02:29,248
I just look weird I like to be nice and clean
45
00:02:29,760 --> 00:02:35,904
That I have an idea maybe how big it should be something like that so we can collect 10000 coins
46
00:02:36,416 --> 00:02:38,208
It still fits in the box
47
00:02:38,464 --> 00:02:39,232
That's great
48
00:02:40,256 --> 00:02:42,048
So we have a coins here
49
00:02:42,304 --> 00:02:44,608
And we want to test something
50
00:02:44,864 --> 00:02:47,424
Burleigh ware 3840 x 2160
51
00:02:47,936 --> 00:02:51,520
What will the text look like at 1920 by 1080
52
00:02:52,032 --> 00:02:53,312
Stick-on Nancy
53
00:02:54,080 --> 00:02:54,592
Wow
54
00:02:55,104 --> 00:02:55,872
Disappeared
55
00:02:56,640 --> 00:02:57,664
Why is that
56
00:02:57,920 --> 00:02:58,944
Where's because
57
00:02:59,200 --> 00:03:04,576
Noticed that the canvas is now a 1920 by 1080 the canvases automatically matching
58
00:03:04,832 --> 00:03:09,952
Display size of the game so watch 3840 by 2160 scales up
59
00:03:10,208 --> 00:03:11,232
Ok we can see
60
00:03:11,488 --> 00:03:12,256
The text
61
00:03:12,768 --> 00:03:15,328
But we got a 1920 by 1080 world
62
00:03:15,840 --> 00:03:16,608
It's wrong
63
00:03:16,864 --> 00:03:18,400
Now it's out of Bounce
64
00:03:18,912 --> 00:03:25,056
What this is actually really easy to fix and this was way way harder to work with them
65
00:03:25,312 --> 00:03:27,104
Scaling issues like this fixed
66
00:03:27,360 --> 00:03:33,504
About 67 years ago when unity was using something called gygy elements as opposed to
67
00:03:33,760 --> 00:03:36,064
UI elements which is a totally different system
68
00:03:36,576 --> 00:03:37,856
The UI system
69
00:03:38,112 --> 00:03:39,648
Unity users now
70
00:03:39,904 --> 00:03:43,744
As opposed to 7 years ago when I started making games or even a decade ago
71
00:03:44,256 --> 00:03:50,400
Didn't use a think I can do it so that click on the canvas and you'll see there's a canvas compony here
72
00:03:50,656 --> 00:03:52,448
And is also a canvas scaler
73
00:03:52,704 --> 00:03:56,544
What are we going to do is change this dropdown from constant pixel size
74
00:03:57,056 --> 00:03:59,616
To scale with screen size ok
75
00:04:00,128 --> 00:04:01,152
So far so good
76
00:04:01,664 --> 00:04:04,736
And we want to have a reference resolution
77
00:04:04,992 --> 00:04:06,784
We can make the reference resolution
78
00:04:07,040 --> 00:04:11,904
The biggest screen size that were going to be building this game out which is 3840
79
00:04:12,416 --> 00:04:13,696
2160
80
00:04:14,720 --> 00:04:15,488
Perfect
81
00:04:16,000 --> 00:04:22,143
And you can match the way to the heights I was going to scale based on the height or the width ok so we can do
82
00:04:22,399 --> 00:04:24,959
Hi tour where to start a change much with this fine
83
00:04:26,239 --> 00:04:30,847
You can expand you can shrink but for now it's going to worry about match with or height
84
00:04:31,103 --> 00:04:35,199
Ok so let's test it out here and see what happens if you got 1821 1080
85
00:04:35,967 --> 00:04:40,831
It's ok looks like resumed shrinkfast down there we go
86
00:04:43,135 --> 00:04:45,951
3860 almost identical
87
00:04:46,207 --> 00:04:46,975
That's great
88
00:04:47,487 --> 00:04:48,255
What about
89
00:04:48,511 --> 00:04:49,279
3 by 2
90
00:04:49,535 --> 00:04:50,559
That's all weird
91
00:04:50,815 --> 00:04:54,143
The nearest emergency are much bigger than they were
92
00:04:54,399 --> 00:04:55,423
269
93
00:04:56,191 --> 00:04:59,519
Pretty comb Argentina or summer colour padding
94
00:05:00,799 --> 00:05:03,871
Pretty good Perry mirror but when we go to 4 by 3
95
00:05:04,127 --> 00:05:07,455
Whoa what a padding there should be more snow up here
96
00:05:07,711 --> 00:05:08,991
Why is that
97
00:05:09,247 --> 00:05:10,271
Well we got a text
98
00:05:11,295 --> 00:05:12,831
You can see that we have this
99
00:05:14,111 --> 00:05:14,879
Lidl
100
00:05:15,391 --> 00:05:17,439
Map
101
00:05:17,951 --> 00:05:21,791
With God anchor preset and it's basically in forms
102
00:05:22,047 --> 00:05:24,607
The object where it should be snug
103
00:05:24,863 --> 00:05:27,167
In the canvas where should it be positioning
104
00:05:27,423 --> 00:05:30,495
What currently is trying to position in the centre we don't want that
105
00:05:30,751 --> 00:05:31,775
Wanted to be the top
106
00:05:32,031 --> 00:05:33,567
Left hand corner
107
00:05:34,335 --> 00:05:35,359
That's great
108
00:05:36,895 --> 00:05:40,479
Circumcision nothing changed will it go back to 16 by 9
109
00:05:40,991 --> 00:05:44,831
Or was better yet let's go back to 3840 x 2160
110
00:05:45,343 --> 00:05:46,111
Ok
111
00:05:46,623 --> 00:05:47,903
That looks like
112
00:05:49,439 --> 00:05:50,975
We need a move it back
113
00:05:51,743 --> 00:05:53,535
Where was salicea
114
00:05:54,559 --> 00:05:56,351
Right up here just like that
115
00:05:56,607 --> 00:05:57,375
Now
116
00:05:58,655 --> 00:05:59,935
Because we changed
117
00:06:00,447 --> 00:06:02,751
Encopresis to be the top left
118
00:06:03,007 --> 00:06:04,799
Can we position it we want it
119
00:06:05,311 --> 00:06:06,847
Now and we got a 4 by 3
120
00:06:09,407 --> 00:06:15,295
Nice and snug no matter what kind of aspect ratio in you see if you look with your free aspect
121
00:06:17,087 --> 00:06:19,391
It's nice and snuggle that tablet in corner
122
00:06:19,903 --> 00:06:21,439
With equal padding
123
00:06:21,695 --> 00:06:22,719
Or March
124
00:06:26,303 --> 00:06:28,351
I will keep it in 1925
125
00:06:28,607 --> 00:06:30,399
That was awesome
126
00:06:30,911 --> 00:06:32,703
So there is our coins ok
127
00:06:32,959 --> 00:06:35,775
Now it's update for coins with the collectible script
128
00:06:36,799 --> 00:06:38,079
Collectible
129
00:06:39,103 --> 00:06:41,151
In open up Visual Studio here
130
00:06:41,407 --> 00:06:46,271
Collectible script basically we want to add the coins collected which we have done
131
00:06:47,295 --> 00:06:53,439
We want to destroy a gameobject which we also want to do but before we destroy a gameobject what we also
132
00:06:53,695 --> 00:06:54,207
Do is
133
00:06:54,463 --> 00:06:55,487
Update
134
00:06:55,743 --> 00:06:56,511
UI
135
00:06:57,023 --> 00:06:58,559
We want you are
136
00:06:58,815 --> 00:06:59,839
Update
137
00:07:00,351 --> 00:07:02,399
In show how many coins we've collected
138
00:07:03,167 --> 00:07:07,007
Well I don't really want to do this inside of the collectible script
139
00:07:07,519 --> 00:07:10,335
The reason why is because we can't sell we will need to find
140
00:07:10,591 --> 00:07:12,383
You are right
141
00:07:12,895 --> 00:07:15,967
So I can do game object find
142
00:07:16,991 --> 00:07:18,527
Coins UI
143
00:07:19,295 --> 00:07:20,063
Dart
144
00:07:20,319 --> 00:07:24,927
Get component and get the component which is the actual text right
145
00:07:25,183 --> 00:07:28,767
And then you'd have to go that text equals
146
00:07:29,279 --> 00:07:31,583
Whenever are coins collect it is right
147
00:07:32,351 --> 00:07:33,375
Coins collected
148
00:07:33,631 --> 00:07:39,775
This is going to be a real pain we don't want to have to do this over and over and over especially for updating various UI element
149
00:07:40,287 --> 00:07:44,639
We actually rather have a function inside of new player
150
00:07:45,663 --> 00:07:48,991
We could reference by multiple game objects ok
151
00:07:49,503 --> 00:07:51,807
2 years old going to create a new function
152
00:07:53,343 --> 00:07:54,367
Update
153
00:07:54,879 --> 00:07:55,647
UI
154
00:07:56,159 --> 00:07:56,927
Elements
155
00:07:57,951 --> 00:08:04,095
Now technically wiki create a new class or script called you why and how it update their but I'm
156
00:08:04,351 --> 00:08:05,887
Having it in the new player script
157
00:08:06,143 --> 00:08:09,215
I'm going to go to call this public void
158
00:08:09,471 --> 00:08:10,751
Update UI
159
00:08:12,543 --> 00:08:13,311
Erika
160
00:08:13,823 --> 00:08:14,591
Ok
161
00:08:15,103 --> 00:08:17,407
So we're going to need a reference
162
00:08:17,663 --> 00:08:19,711
To the coins you are
163
00:08:20,223 --> 00:08:21,503
How we gonna do that
164
00:08:22,015 --> 00:08:23,551
The pseudocode would be
165
00:08:23,807 --> 00:08:25,343
Coins UI
166
00:08:25,599 --> 00:08:27,391
Text equals
167
00:08:27,647 --> 00:08:28,671
Coins collected
168
00:08:29,183 --> 00:08:29,951
Ok
169
00:08:31,487 --> 00:08:33,279
What is the coins UI
170
00:08:33,535 --> 00:08:37,631
Well right here you see we need a reference to coins you why
171
00:08:38,143 --> 00:08:44,287
Where we do that if we go up here for a variables to create a new variable and believe it or not
172
00:08:44,543 --> 00:08:48,127
Instead of floating images in bullions in strings
173
00:08:48,383 --> 00:08:51,967
You can also create a variable that is a reference to a component
174
00:08:52,479 --> 00:08:54,783
So let's go back in the unity here
175
00:08:55,039 --> 00:08:56,575
Take a look at the component
176
00:08:56,831 --> 00:08:58,879
It is on this text item
177
00:08:59,391 --> 00:09:02,719
Ok so we selected our coins text and let's be should a name it
178
00:09:02,975 --> 00:09:03,743
Coins
179
00:09:04,511 --> 00:09:05,535
Select that
180
00:09:05,791 --> 00:09:08,607
Looks like we have a UI element called text
181
00:09:09,631 --> 00:09:15,775
We want to reference that text we can actually create a variable in r script that is going to Forever reference
182
00:09:16,031 --> 00:09:17,311
That coins text
183
00:09:18,335 --> 00:09:20,127
To recreate a public
184
00:09:20,383 --> 00:09:21,919
Text
185
00:09:22,431 --> 00:09:23,455
Reference here
186
00:09:23,711 --> 00:09:26,015
I'm really cold this coins text
187
00:09:27,807 --> 00:09:33,183
So we can have integers floats we can have strings brilliant does it all lowercase
188
00:09:33,439 --> 00:09:35,743
The moment you reference a component
189
00:09:36,767 --> 00:09:38,047
Can be capitalised
190
00:09:38,815 --> 00:09:40,863
This is public text
191
00:09:41,119 --> 00:09:42,399
Coins text
192
00:09:42,911 --> 00:09:44,959
All this is a reference
193
00:09:45,727 --> 00:09:46,751
Do the coins text
194
00:09:47,519 --> 00:09:53,663
So we can reference this in multiple ways right now he has no idea
195
00:09:53,919 --> 00:09:58,527
Rich text item in it is only knows that were trying to reference a text component
196
00:09:58,783 --> 00:10:01,740
You could have 1000 text components inside of your Unity Project
197
00:10:01,741 --> 00:10:04,296
Subtitled by
-♪ online-courses.club ♪-
We compress knowledge for you!
https://t.me/joinchat/ailxpXoW3JVjYzQ1
198
00:10:04,298 --> 00:10:06,719
To which text component are we referencing
199
00:10:06,975 --> 00:10:08,511
Well there's two ways to do this
200
00:10:09,023 --> 00:10:14,655
The first way would be to go into the start function in before any of the Script run
201
00:10:15,167 --> 00:10:16,959
We can find that
202
00:10:17,215 --> 00:10:18,239
So we can go
203
00:10:18,495 --> 00:10:19,775
Coins text
204
00:10:20,031 --> 00:10:20,799
Equals
205
00:10:21,055 --> 00:10:22,079
Game object
206
00:10:22,847 --> 00:10:23,615
That's fine
207
00:10:24,383 --> 00:10:25,151
What's your name
208
00:10:26,175 --> 00:10:26,687
Coins
209
00:10:29,503 --> 00:10:31,039
Getcomponent
210
00:10:32,319 --> 00:10:33,087
Text
211
00:10:37,439 --> 00:10:39,231
Remember the syntax for
212
00:10:39,487 --> 00:10:42,303
Find is a little bit different than getcomponent
213
00:10:43,071 --> 00:10:49,215
The name of the game object in princesses and inside of quotes but forget component you can put it inside of you
214
00:10:49,471 --> 00:10:49,983
Brackets here
215
00:10:51,263 --> 00:10:51,775
Text
216
00:10:52,031 --> 00:10:54,079
And then you follow with princesses
217
00:10:54,335 --> 00:10:57,919
Honestly and I can't get into my bed is just know that Dad's tax
218
00:10:59,199 --> 00:11:01,759
That's one way if we do debug.log
219
00:11:02,015 --> 00:11:03,295
Text
220
00:11:06,367 --> 00:11:07,647
Go on unity
221
00:11:08,415 --> 00:11:09,183
Play
222
00:11:10,975 --> 00:11:15,327
And hopefully in the console window it's going to print out exactly what it is
223
00:11:15,839 --> 00:11:17,119
Ok there is right there
224
00:11:17,375 --> 00:11:18,911
Remember we have one
225
00:11:19,423 --> 00:11:21,983
I'm emo debug.log happening here
226
00:11:22,239 --> 00:11:25,311
And that's in the collectible Script so you don't need to worry about that
227
00:11:26,591 --> 00:11:32,735
Direct here below the I'm mod bug that We Created earlier you can see this new debug.log
228
00:11:33,503 --> 00:11:37,343
It says coins and then it a unity UI text component
229
00:11:37,855 --> 00:11:40,159
Looks like we have a reference
230
00:11:41,183 --> 00:11:44,767
Lower pseudocode here we can say coins text equals
231
00:11:45,279 --> 00:11:46,559
Well what do you want to be
232
00:11:46,815 --> 00:11:48,351
Coins collected
233
00:11:50,143 --> 00:11:53,983
Ok so looks like we have a red squiggly line here
234
00:11:54,239 --> 00:11:55,263
Why is that
235
00:11:56,031 --> 00:12:02,175
Well when you're trying to make it something equals something else they need to match in their variable
236
00:12:02,431 --> 00:12:06,527
Type ok so what is the variable Type 4 coins text
237
00:12:06,783 --> 00:12:09,599
What we scroll up you can see right next to it
238
00:12:09,855 --> 00:12:10,879
It's not an integer
239
00:12:11,135 --> 00:12:13,951
Where a string is actually a text component
240
00:12:14,207 --> 00:12:15,999
That's the type of variable it is
241
00:12:16,511 --> 00:12:18,047
Is a reference to a component
242
00:12:18,559 --> 00:12:21,119
So we can make a component equal
243
00:12:21,887 --> 00:12:23,935
In integer which is coins collected
244
00:12:24,447 --> 00:12:25,983
We need to make sure
245
00:12:26,239 --> 00:12:29,311
That were finding something inside of a component
246
00:12:29,567 --> 00:12:31,103
That could be an integer
247
00:12:31,615 --> 00:12:32,639
The what is that
248
00:12:32,895 --> 00:12:35,455
Well if we type coins text Dad
249
00:12:35,711 --> 00:12:40,063
We can go through a lot of different variables that are inside the component
250
00:12:40,575 --> 00:12:42,879
We actually go to the components and take a look
251
00:12:43,135 --> 00:12:44,927
It looks like we have a text field
252
00:12:45,439 --> 00:12:46,975
Inside the text component
253
00:12:47,743 --> 00:12:49,279
That could be an integer array
254
00:12:49,535 --> 00:12:51,583
Does type in coins text
255
00:12:51,839 --> 00:12:53,631
Text ok
256
00:12:53,887 --> 00:12:55,679
Eagles coins collected
257
00:12:56,447 --> 00:12:58,495
Well that still didn't work
258
00:12:59,007 --> 00:13:00,031
Why is that
259
00:13:00,543 --> 00:13:02,335
What's because the text field
260
00:13:03,103 --> 00:13:04,127
Is not an integer
261
00:13:04,639 --> 00:13:08,223
Is anything I can be anything I wanted to be right
262
00:13:08,991 --> 00:13:10,015
It's a string
263
00:13:11,039 --> 00:13:14,367
Meaning I could write Bob's your uncle
264
00:13:14,623 --> 00:13:17,183
In this text field here
265
00:13:17,951 --> 00:13:23,839
And they're 42 string right so we need to make sure that coins collected is not an integer
266
00:13:24,351 --> 00:13:25,119
A string
267
00:13:25,631 --> 00:13:29,215
We wouldn't want to change it here right I wouldn't want this to be a string
268
00:13:29,727 --> 00:13:33,055
Because then it would be an integer so how do we solve this
269
00:13:33,567 --> 00:13:37,407
What we know we want our coins collected to be an integer that's a given
270
00:13:37,919 --> 00:13:40,223
So what we can do is actually convert
271
00:13:40,735 --> 00:13:41,759
Coins collected
272
00:13:42,015 --> 00:13:45,343
To a string so that I can fit inside a coins that tech
273
00:13:45,855 --> 00:13:47,903
You all were doing is basically
274
00:13:48,415 --> 00:13:50,719
Changing 10 coins
275
00:13:50,975 --> 00:13:51,487
2
276
00:13:51,743 --> 00:13:52,255
10
277
00:13:53,023 --> 00:13:59,167
That's all were doing now we're not actually going to change the actual coins collected variable all
278
00:13:59,423 --> 00:14:00,191
Doing a saying
279
00:14:00,447 --> 00:14:03,007
Get the coin slot in variable and then change it
280
00:14:03,263 --> 00:14:06,335
To a string just for us to actually store there
281
00:14:07,103 --> 00:14:08,639
Inside of a coins text
282
00:14:08,895 --> 00:14:09,407
Field
283
00:14:10,431 --> 00:14:13,247
All we do is coins collected data to string
284
00:14:14,783 --> 00:14:15,551
Here we go
285
00:14:16,831 --> 00:14:20,159
Is it just a call a function that will take an integer
286
00:14:20,415 --> 00:14:23,487
And say you know what I want this to be a string
287
00:14:23,743 --> 00:14:25,535
That all it's doing right here
288
00:14:26,047 --> 00:14:26,815
Tell
289
00:14:27,583 --> 00:14:28,863
But it's saviour
290
00:14:29,375 --> 00:14:31,423
And see if Artex box
291
00:14:31,679 --> 00:14:32,447
Actually
292
00:14:32,703 --> 00:14:33,727
Change it out
293
00:14:34,495 --> 00:14:38,591
Let's put it 0 again this is not an integer right here
294
00:14:38,847 --> 00:14:39,871
This is a string
295
00:14:40,383 --> 00:14:41,407
Basically this
296
00:14:41,919 --> 00:14:42,431
0
297
00:14:43,199 --> 00:14:46,015
Let's just make this a 0 by default
298
00:14:46,271 --> 00:14:47,039
And hopefully
299
00:14:47,295 --> 00:14:48,575
And see what happens
300
00:14:51,903 --> 00:14:52,671
Ok
301
00:14:55,743 --> 00:14:58,559
Well nothing happened why is that will be good or player
302
00:14:59,839 --> 00:15:03,423
We have one coin here but it's not updating here what's going on
303
00:15:03,679 --> 00:15:04,959
Still not updating
304
00:15:05,727 --> 00:15:07,263
What is going on
305
00:15:07,519 --> 00:15:08,287
Well
306
00:15:08,543 --> 00:15:14,687
The reason why it's not doing anything if we actually haven't even told uniti to fire this function or call
307
00:15:14,943 --> 00:15:15,455
Dysfunction
308
00:15:16,735 --> 00:15:19,039
We need actually have it because somewhere
309
00:15:19,295 --> 00:15:22,367
Well we can call it here if we wanted to inside of a start
310
00:15:22,623 --> 00:15:26,975
The moment that unity starts let's update the UI
311
00:15:28,511 --> 00:15:29,535
It's Gonna Call
312
00:15:30,047 --> 00:15:31,583
So what if we said
313
00:15:31,839 --> 00:15:32,607
Coins
314
00:15:34,399 --> 00:15:38,751
Collected equals 200 what we said that in the start function
315
00:15:39,007 --> 00:15:40,799
And then we updated that you are
316
00:15:41,311 --> 00:15:47,455
Technically it should buy this function in set the text to be we're going to collect it is so
317
00:15:47,711 --> 00:15:49,247
Set a 200 so let's try that
318
00:15:50,783 --> 00:15:52,319
Ok cool
319
00:15:52,575 --> 00:15:55,903
Just send it to 200 so we know that the function actually works
320
00:15:56,415 --> 00:15:58,719
Updating when we collect the coins
321
00:15:59,487 --> 00:15:59,999
Well
322
00:16:01,023 --> 00:16:01,791
That's because
323
00:16:02,303 --> 00:16:03,839
We haven't actually fired it
324
00:16:04,351 --> 00:16:05,375
When we collect it
325
00:16:05,887 --> 00:16:06,399
Here
326
00:16:07,167 --> 00:16:08,959
Inside of the collectible script
327
00:16:09,215 --> 00:16:11,007
When we do the ontriggerenter
328
00:16:11,775 --> 00:16:16,127
Ok so now we know that updating the UI and calling that
329
00:16:16,383 --> 00:16:17,663
Definitely works
330
00:16:17,919 --> 00:16:19,199
Because when we hit play
331
00:16:19,711 --> 00:16:20,991
It's at the text
332
00:16:21,247 --> 00:16:22,015
200
333
00:16:22,527 --> 00:16:23,551
So good there
334
00:16:24,319 --> 00:16:26,879
But we need to call the update UI function
335
00:16:27,135 --> 00:16:28,671
From the collectible script
336
00:16:28,927 --> 00:16:30,463
Remove this like quick
337
00:16:33,535 --> 00:16:35,327
Yeah we don't need this debug anymore
338
00:16:36,607 --> 00:16:38,399
My bills clean up this as well
339
00:16:38,911 --> 00:16:40,191
Not need those comments
340
00:16:40,703 --> 00:16:42,751
Collectible here alright
341
00:16:43,007 --> 00:16:43,519
Stop
342
00:16:44,287 --> 00:16:48,127
Update you I should occur somewhere around here
343
00:16:48,383 --> 00:16:52,735
So we're going to be something similar to this line here we going to do game object
344
00:16:52,991 --> 00:16:59,135
Find player remember that function the update you a function is inside of
345
00:17:00,415 --> 00:17:01,183
Player
346
00:17:01,439 --> 00:17:03,999
Getcomponent new player
347
00:17:05,535 --> 00:17:07,071
So we're finding that component
348
00:17:07,583 --> 00:17:13,215
And then we're going to fire the functions inside of their component this is the component right new player
349
00:17:13,471 --> 00:17:17,055
Remember new player has this function in it called update why
350
00:17:18,079 --> 00:17:18,847
Tell
351
00:17:20,383 --> 00:17:21,151
Are we due
352
00:17:23,199 --> 00:17:23,967
Is upday
353
00:17:24,223 --> 00:17:24,735
UI
354
00:17:26,527 --> 00:17:30,111
What's your brief overview before I hit play Alright
355
00:17:30,879 --> 00:17:31,391
First
356
00:17:32,415 --> 00:17:34,463
We're going to find the player
357
00:17:34,719 --> 00:17:35,231
Well
358
00:17:35,999 --> 00:17:37,023
Is the player
359
00:17:37,535 --> 00:17:41,887
So this line literally just says hey unity find
360
00:17:42,143 --> 00:17:44,447
A game object with the name player
361
00:17:44,703 --> 00:17:45,983
There I am
362
00:17:46,239 --> 00:17:48,031
Find the player gameobject
363
00:17:48,543 --> 00:17:49,567
And then you say
364
00:17:49,823 --> 00:17:55,967
In addition I want you to keep going inside of the player and I also want you to find the new player component
365
00:17:56,223 --> 00:17:56,991
Attached
366
00:17:58,271 --> 00:17:59,295
To the play a game of
367
00:18:00,575 --> 00:18:05,183
Unity find the player and then he goes where is that component there it is
368
00:18:05,439 --> 00:18:07,231
And it finds the new player compose
369
00:18:07,487 --> 00:18:09,023
Attached the game
370
00:18:09,279 --> 00:18:10,815
Do you start with a gameobject
371
00:18:11,071 --> 00:18:13,119
You're looking around for the game object you find it
372
00:18:13,631 --> 00:18:14,911
And then you find a component
373
00:18:15,423 --> 00:18:16,703
And then you say
374
00:18:16,959 --> 00:18:20,287
Find the variable inside of that component
375
00:18:20,543 --> 00:18:23,103
Which is the coins collected variable here
376
00:18:24,383 --> 00:18:26,175
And then increased by 1
377
00:18:26,687 --> 00:18:27,199
Perfect
378
00:18:27,967 --> 00:18:31,551
Unity increases by 1 and then it jumps to the next line here
379
00:18:33,087 --> 00:18:34,367
What's find the player
380
00:18:35,135 --> 00:18:36,415
Find a component
381
00:18:36,671 --> 00:18:42,815
Cannot find the function and you always know something to function if it has an uppercase letter usually that's how functions are written
382
00:18:43,327 --> 00:18:44,863
So is an uppercase
383
00:18:45,119 --> 00:18:46,399
Update UI
384
00:18:47,423 --> 00:18:49,215
It looks inside of the Script
385
00:18:49,727 --> 00:18:51,007
Defines the function
386
00:18:51,263 --> 00:18:52,543
In a fire is it
387
00:18:52,799 --> 00:18:54,335
Voice text that text
388
00:18:54,591 --> 00:18:55,103
Equal
389
00:18:55,615 --> 00:18:56,639
Are coins collected
390
00:18:57,663 --> 00:19:00,479
But remember we got to convert that integer to a string
391
00:19:01,247 --> 00:19:03,295
Save it out and see what happens
392
00:19:06,367 --> 00:19:08,415
Ok so we're one great
393
00:19:10,719 --> 00:19:16,863
Do awesome 34 grey collecting coins have a game feels like a game now
394
00:19:17,119 --> 00:19:19,423
Hardest setting for collecting things right
395
00:19:19,679 --> 00:19:22,239
This is Arsenal works great
396
00:19:22,751 --> 00:19:28,895
Is one thing that I want to do and that is clean up our scripts a little bit more so we're going to do that in the next video
397
00:19:29,151 --> 00:19:35,295
So far things like pretty great
27936
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.