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:11,520
Alright so now we can go ahead
2
00:00:11,776 --> 00:00:14,848
Jump into a new player script that we created
3
00:00:15,872 --> 00:00:18,432
Actually start doing some code
4
00:00:18,944 --> 00:00:20,480
Allow player to move
5
00:00:21,248 --> 00:00:25,344
The first thing I want to do is actually extend the new player
6
00:00:25,600 --> 00:00:27,648
Night necessarily to the monobehaviour
7
00:00:28,160 --> 00:00:29,696
Actually first
8
00:00:29,952 --> 00:00:31,744
2D physics object
9
00:00:32,000 --> 00:00:32,512
Script
10
00:00:33,280 --> 00:00:34,048
Created
11
00:00:34,560 --> 00:00:36,096
I'm going to be doing a lot of this
12
00:00:36,352 --> 00:00:40,704
In his game kit actually I think the only time that week's standard to anything
13
00:00:40,960 --> 00:00:46,336
Are new players actually an extended a physics object because we wanted to have it love properties
14
00:00:46,592 --> 00:00:48,640
The physics object script
15
00:00:49,152 --> 00:00:49,920
Create
16
00:00:50,688 --> 00:00:52,480
In that case a gravity modifier
17
00:00:52,736 --> 00:00:54,016
That is specific
18
00:00:54,272 --> 00:00:55,552
Two physics objects
19
00:00:56,320 --> 00:01:01,293
I really want to use rigidbody gravity because our physics logic gravity is going to be much more specific
20
00:01:01,295 --> 00:01:03,643
Subtitled by
-♪ online-courses.club ♪-
We compress knowledge for you!
https://t.me/joinchat/ailxpXoW3JVjYzQ1
21
00:01:03,644 --> 00:01:05,792
To our 2D platformer and give us a little bit more control
22
00:01:06,560 --> 00:01:12,704
That's all we're going to do here we're just going to extend to physics object now it's a physics object
23
00:01:12,960 --> 00:01:16,288
Extends to the Mario Javier so the new player script
24
00:01:16,544 --> 00:01:21,152
Actually does extend to the monobehaviour through the physics object
25
00:01:21,408 --> 00:01:23,200
Space Leeds
26
00:01:23,456 --> 00:01:25,504
Current Script if you will
27
00:01:26,016 --> 00:01:29,856
Was Aladdin properties that allow it to move in a very specific way
28
00:01:30,112 --> 00:01:36,256
Stop we had Sophia jump back in the unity even though we have our gravity scale on the
29
00:01:36,512 --> 00:01:37,536
0
30
00:01:38,304 --> 00:01:41,888
A new player script because it extends to the physics object
31
00:01:42,400 --> 00:01:43,424
Actually gonna fall
32
00:01:43,680 --> 00:01:45,984
Because the physics object has its own gravity
33
00:01:46,240 --> 00:01:47,776
Independent of the rigid part
34
00:01:49,056 --> 00:01:51,104
IPlayer is now falling
35
00:01:51,616 --> 00:01:55,456
In order to get iPlayer to move we actually need to manipulate
36
00:01:55,712 --> 00:01:57,504
Property in the physics object
37
00:01:58,528 --> 00:02:00,576
Or a variable in the physics subject
38
00:02:00,832 --> 00:02:01,344
Cold
39
00:02:02,112 --> 00:02:03,136
Velocity
40
00:02:03,904 --> 00:02:10,048
Without getting too much in the weeds here the target velocity is actually going to change the velocity of the physics object
41
00:02:10,304 --> 00:02:11,584
And moving around
42
00:02:12,096 --> 00:02:13,888
Tesco two new player here
43
00:02:14,144 --> 00:02:17,728
You know that if we actually type in Target velocity
44
00:02:19,264 --> 00:02:23,104
Automatically recommended a variable called Turkey velocity
45
00:02:23,360 --> 00:02:25,920
We haven't actually declared as variable or
46
00:02:26,176 --> 00:02:29,248
This variable anywhere in the new player script
47
00:02:29,760 --> 00:02:35,904
That's because it's a variable associated again with the physics object which were extending two so we can actually use it and
48
00:02:36,672 --> 00:02:39,232
So we can say target velocity equals
49
00:02:39,488 --> 00:02:40,512
Say
50
00:02:41,280 --> 00:02:41,792
1
51
00:02:43,072 --> 00:02:49,216
Why do we have a red zig zag underneath this love we have a Rover it says cannot implicitly convert type
52
00:02:49,472 --> 00:02:49,984
Integer
53
00:02:50,240 --> 00:02:52,032
To Unity vector2
54
00:02:52,544 --> 00:02:58,432
Well what I mean is Target velocity is a vector to meaning it's an X in a y
55
00:02:58,944 --> 00:03:05,088
Vector3 if I just three has a Z axis of acta2 is just x in y
56
00:03:05,344 --> 00:03:11,488
Go to a line 2D games because we don't need a change of Vectra 3 and you can go to the physics object to actually see
57
00:03:12,512 --> 00:03:13,536
Score of the top here
58
00:03:14,816 --> 00:03:17,888
Travelocity is declared in it's a vector 2
59
00:03:20,448 --> 00:03:22,752
Send this to a new vector to
60
00:03:23,520 --> 00:03:25,312
Sophie Collet new vegetarian
61
00:03:25,568 --> 00:03:28,384
I see one and then 0
62
00:03:28,640 --> 00:03:31,200
You say that out what happens inside of Unity
63
00:03:31,456 --> 00:03:32,224
Take a look
64
00:03:32,736 --> 00:03:33,760
Play
65
00:03:36,064 --> 00:03:38,112
Man united players moving to the right
66
00:03:38,624 --> 00:03:41,184
Survey of 1 and then Falls have to map
67
00:03:42,208 --> 00:03:45,024
Just like we did in the previous tutorials
68
00:03:45,280 --> 00:03:48,864
What we just said this to our actual input values
69
00:03:49,120 --> 00:03:51,680
We can do new vector2
70
00:03:53,216 --> 00:03:54,752
Input.get access
71
00:03:55,776 --> 00:03:56,800
Horizontal
72
00:03:58,848 --> 00:04:02,688
The why we don't want it to be moving in the Y Direction currently
73
00:04:03,456 --> 00:04:04,992
Do it for now
74
00:04:05,504 --> 00:04:06,528
Bus driver sound
75
00:04:13,952 --> 00:04:16,512
Perfect do we move our player
76
00:04:17,024 --> 00:04:18,303
The left and right
77
00:04:21,887 --> 00:04:26,495
Let's be sure that we can actually change how fast the player is actually moving
78
00:04:26,751 --> 00:04:28,543
What we can do is actually
79
00:04:29,311 --> 00:04:30,335
New variant
80
00:04:30,847 --> 00:04:33,407
Mummy share them is a serialised variable
81
00:04:33,919 --> 00:04:38,015
N18 sure that it's a private for now it's going to be a float
82
00:04:38,527 --> 00:04:40,063
Max speed
83
00:04:41,599 --> 00:04:43,391
Buy the Falklands make it 1
84
00:04:43,903 --> 00:04:45,183
7 unity
85
00:04:47,231 --> 00:04:48,511
Soccer player here
86
00:04:50,559 --> 00:04:53,119
You can see here that we have 3 properties
87
00:04:53,375 --> 00:04:54,655
Popped up
88
00:04:54,911 --> 00:04:55,935
Component
89
00:04:56,191 --> 00:04:59,519
These two are associated with the
90
00:04:59,775 --> 00:05:02,591
Standard behaviour script which is the
91
00:05:03,103 --> 00:05:03,871
Physics object
92
00:05:04,127 --> 00:05:05,919
Make a worry about these at all
93
00:05:06,175 --> 00:05:12,319
What is the max speed we going to change this to 3 if you want to make it a little bit faster the plane
94
00:05:16,415 --> 00:05:18,975
It's a little bit slow when we speed up a little bit
95
00:05:21,535 --> 00:05:24,095
So why are we not getting an effect
96
00:05:24,607 --> 00:05:25,375
Our player
97
00:05:26,911 --> 00:05:29,727
If you guessed it that means you're learning
98
00:05:29,983 --> 00:05:34,591
And you're actually better than me we need to multiply
99
00:05:34,847 --> 00:05:36,895
X max speed
100
00:05:37,663 --> 00:05:40,735
Are horizontal axis value the float value
101
00:05:41,247 --> 00:05:43,807
When we press the left or right button
102
00:05:44,319 --> 00:05:47,391
Is there a x x 2 speed it so if you press the right button
103
00:05:48,671 --> 00:05:51,743
Goes to 1 we x x max speed which
104
00:05:51,999 --> 00:05:56,607
Is wine here but if we go to Unity editor is actually three so it's going to be 3
105
00:05:56,863 --> 00:05:58,399
Unless to be -3
106
00:05:58,911 --> 00:06:00,447
Play and try again
107
00:06:02,751 --> 00:06:03,519
Here we go
108
00:06:04,287 --> 00:06:05,311
It is
109
00:06:05,567 --> 00:06:07,103
Moving left and right
110
00:06:07,359 --> 00:06:08,383
That looks great
111
00:06:09,919 --> 00:06:11,711
If you follow along in the
112
00:06:11,967 --> 00:06:13,247
Unity basics
113
00:06:13,503 --> 00:06:14,783
Portion of this tutorial
114
00:06:15,039 --> 00:06:16,063
You may be wondering
115
00:06:16,575 --> 00:06:22,719
Thomas we actually at the x x x deltatime anytime were moving an object
116
00:06:22,975 --> 00:06:28,095
The answer is yes so we should go to our target velocity here
117
00:06:28,607 --> 00:06:34,751
Are we actually iterating anything in this script in the single line by Italy I mean
118
00:06:35,263 --> 00:06:36,799
Increasing any value
119
00:06:37,567 --> 00:06:39,871
We increasing at a specific frame rate
120
00:06:40,383 --> 00:06:44,223
Actually no we're not using any sort of plus equals here
121
00:06:44,735 --> 00:06:48,319
Are we doing a setting a value target velocity
122
00:06:49,343 --> 00:06:50,367
To another value
123
00:06:51,135 --> 00:06:55,231
What is Target velocity actually doing if you go to the physics magic script
124
00:06:55,487 --> 00:06:56,511
Velocity
125
00:06:56,767 --> 00:07:01,631
Type in Target velocity by pressing ctrl f
126
00:07:02,143 --> 00:07:06,239
Search where it's been used in physics Optics script
127
00:07:06,495 --> 00:07:12,639
You can see them velocity actually matches our target velocity here and was some clever maths when I can only get
128
00:07:12,895 --> 00:07:15,711
When you can notice that a delta position has been created
129
00:07:15,967 --> 00:07:17,759
And that is being multiplied
130
00:07:18,527 --> 00:07:20,319
X x delta time
131
00:07:21,087 --> 00:07:27,231
Tell this may look a little bit confusing don't worry about it too much but just know that we are actually
132
00:07:27,487 --> 00:07:30,303
Multiplying x x deltatime
133
00:07:30,559 --> 00:07:33,887
And we don't really need to worry about doing it right here
134
00:07:34,143 --> 00:07:35,423
Because again
135
00:07:35,679 --> 00:07:38,239
It's actually been calculated right here
136
00:07:39,007 --> 00:07:40,799
So where do you want to play a to jump
137
00:07:41,311 --> 00:07:47,455
What if we go into our new player skript universe we use target velocity when moving the player to the
138
00:07:47,711 --> 00:07:48,735
Play in left
139
00:07:48,991 --> 00:07:55,135
But I getting too much in the weeds here if you go to the physics object script you noticed that target velocity
140
00:07:55,391 --> 00:08:01,535
Informs what the actual velocity in the x-direction is velocity is part of the
141
00:08:02,047 --> 00:08:08,191
Velocity in the x-direction it's not really part of the equation for velocity in the y-direction
142
00:08:08,959 --> 00:08:10,751
So we can actually just manipulate
143
00:08:11,007 --> 00:08:12,543
The lottery itself
144
00:08:13,567 --> 00:08:15,103
To create a jump
145
00:08:15,615 --> 00:08:21,759
Because velocity is a very well that new player actually can manipulate
146
00:08:22,015 --> 00:08:25,599
Why we can say equals 10
147
00:08:26,111 --> 00:08:27,135
See what happens
148
00:08:31,743 --> 00:08:33,791
Stop he flies up in the air
149
00:08:34,559 --> 00:08:38,655
He's just flying
150
00:08:39,423 --> 00:08:41,215
That's great so
151
00:08:41,471 --> 00:08:47,615
Is doing well we need to do kind of the reason why he's lying because again
152
00:08:47,871 --> 00:08:52,223
Update so velocity that why is constantly set to 10
153
00:08:52,479 --> 00:08:58,623
Meaning his velocity is constant 10 and it's projecting him up but it's almost as if fuel is being
154
00:08:58,879 --> 00:09:02,207
Rejected from his feet and is flying into the atmosphere
155
00:09:02,463 --> 00:09:08,607
So you don't want to ask me that white always be 10 so what are we going to do here
156
00:09:08,863 --> 00:09:09,887
Create a condition
157
00:09:10,911 --> 00:09:14,495
And let's write some pseudo code here if the player
158
00:09:15,519 --> 00:09:16,287
Prices
159
00:09:17,823 --> 00:09:18,335
Jump
160
00:09:22,943 --> 00:09:24,479
Set the velocity
161
00:09:25,503 --> 00:09:26,015
2
162
00:09:27,551 --> 00:09:28,575
A jump
163
00:09:28,831 --> 00:09:32,671
Power value which in this case is 10
164
00:09:33,183 --> 00:09:39,327
So again guys is your comments any time you see these two little / here there's a comments
165
00:09:39,839 --> 00:09:42,143
So what is the jump
166
00:09:42,655 --> 00:09:43,935
Input value
167
00:09:44,191 --> 00:09:48,287
Are we going on unity here and we go back to our project settings
168
00:09:49,055 --> 00:09:50,079
You can see that
169
00:09:50,335 --> 00:09:51,359
Because these down
170
00:09:51,615 --> 00:09:52,639
You can see that jump
171
00:09:53,407 --> 00:09:54,431
Is actually
172
00:09:55,711 --> 00:09:56,991
Fighting type
173
00:09:58,015 --> 00:10:00,972
So when I can use get access to actually going to use get button
174
00:10:00,973 --> 00:10:03,912
Subtitled by
-♪ online-courses.club ♪-
We compress knowledge for you!
https://t.me/joinchat/ailxpXoW3JVjYzQ1
175
00:10:03,913 --> 00:10:05,951
So we can type it like this
176
00:10:06,719 --> 00:10:07,487
Input
177
00:10:07,999 --> 00:10:10,047
Get button down
178
00:10:13,631 --> 00:10:14,399
Jump
179
00:10:16,959 --> 00:10:19,775
Make sure you use your curly brackets here
180
00:10:24,383 --> 00:10:26,687
Is going to set up velocity that's why
181
00:10:27,199 --> 00:10:27,711
The 10
182
00:10:31,295 --> 00:10:32,319
Play here
183
00:10:32,831 --> 00:10:33,855
What happens
184
00:10:35,903 --> 00:10:36,927
Alright
185
00:10:37,439 --> 00:10:38,975
That we've got a jump here
186
00:10:40,255 --> 00:10:44,095
That's wonderful a question that popped into your head
187
00:10:44,351 --> 00:10:45,631
And if it did
188
00:10:45,887 --> 00:10:46,911
Granule
189
00:10:47,167 --> 00:10:51,775
Penneys why is it the weekend manipulate the Y value of the velocity
190
00:10:52,031 --> 00:10:58,175
We are meant to be like the Y value of a transform so transform that position
191
00:10:58,431 --> 00:10:59,199
Why
192
00:10:59,455 --> 00:11:00,479
Equals 10
193
00:11:00,991 --> 00:11:02,527
Why is that
194
00:11:03,039 --> 00:11:06,879
Well it's because as you can see here we cannot modify
195
00:11:07,135 --> 00:11:09,951
Return value of transform deposition
196
00:11:10,207 --> 00:11:12,255
Because it's not a variable
197
00:11:12,767 --> 00:11:15,071
This is a vector 2
198
00:11:15,327 --> 00:11:16,607
And it's a variable
199
00:11:17,119 --> 00:11:20,191
Transfer deposition is an actually a variable
200
00:11:20,447 --> 00:11:26,591
In order to do that you actually remember you have to do new vector3 and then you have to type it
201
00:11:26,847 --> 00:11:27,359
This way
202
00:11:28,383 --> 00:11:29,407
Something like that
203
00:11:30,175 --> 00:11:34,271
Can I tell you modify a transformer value in a transfer value can be
204
00:11:34,527 --> 00:11:36,831
Position rotation scale
205
00:11:37,599 --> 00:11:43,743
But we can manipulate the Y value in the X value and Z value of a vector 3
206
00:11:43,999 --> 00:11:48,863
Variable or a vector to variable so just keep that in mind as you're working on your game
207
00:11:49,631 --> 00:11:51,679
Do you know this we can actually double jump
208
00:11:52,191 --> 00:11:58,079
Wait now
209
00:11:58,335 --> 00:12:04,479
And that might be cool in a jumper game
210
00:12:04,735 --> 00:12:07,551
Purposes we only need one jump
211
00:12:08,063 --> 00:12:09,855
So how exactly do we do that
212
00:12:10,367 --> 00:12:13,183
Well there's a beautiful wonderful
213
00:12:13,439 --> 00:12:15,487
Convenient variable
214
00:12:15,999 --> 00:12:19,071
In the physics object Script if you press ctrl f
215
00:12:19,583 --> 00:12:21,631
To find a variable
216
00:12:21,887 --> 00:12:23,423
It's called grounded
217
00:12:24,191 --> 00:12:28,287
And like I said the physics object script is a very complicated one
218
00:12:28,543 --> 00:12:34,687
And one of the reasons why I use it so often is because the grounded variable is a very important
219
00:12:34,943 --> 00:12:37,759
And it uses all is weird Matthew
220
00:12:38,527 --> 00:12:44,671
To calculate where they were actually grounded meaning are we touching the ground or have we left
221
00:12:44,927 --> 00:12:49,535
Round is a very simple very boards a bullying in 80 the true or false
222
00:12:50,303 --> 00:12:51,327
So we got to do is
223
00:12:51,583 --> 00:12:53,887
Create an additional condition here
224
00:12:54,143 --> 00:12:57,215
In what you do that is you use the end sign
225
00:12:57,471 --> 00:13:00,287
Not once but twice as just the syntax
226
00:13:01,055 --> 00:13:04,127
So if the player presses jump
227
00:13:04,639 --> 00:13:05,407
And
228
00:13:05,663 --> 00:13:06,943
We are grounded
229
00:13:08,735 --> 00:13:11,039
Set the alarm 30 so are you doing
230
00:13:11,807 --> 00:13:12,575
Grounded
231
00:13:14,879 --> 00:13:16,927
Is set to wait when is it
232
00:13:17,439 --> 00:13:17,951
True
233
00:13:18,463 --> 00:13:21,535
Soliciting weird syntax here let me try and explain
234
00:13:22,047 --> 00:13:27,167
Anytime we want to use the word end or the sign and just used two of them and
235
00:13:28,447 --> 00:13:34,591
Anytime you want actually check to see if a value is true or false you can use to equal sign
236
00:13:34,847 --> 00:13:38,175
Not one we try and use one and save it
237
00:13:38,431 --> 00:13:39,967
Jump in unity
238
00:13:40,479 --> 00:13:41,759
Should get him there here
239
00:13:43,039 --> 00:13:44,319
The left hand sign
240
00:13:44,575 --> 00:13:46,623
An assignment must be a variable
241
00:13:46,879 --> 00:13:47,647
Property
242
00:13:47,903 --> 00:13:48,927
Orient Exeter
243
00:13:49,183 --> 00:13:51,487
Did you see the universe can I confused
244
00:13:51,743 --> 00:13:56,351
Doesn't really understand what we're trying to do here trying to set a value
245
00:13:56,863 --> 00:14:03,007
You can set a value outside of a condition so for example we've set the last 30 to 10 with the ick
246
00:14:03,263 --> 00:14:06,591
Well I'm really setting a value in this condition are we
247
00:14:06,847 --> 00:14:08,639
Actually checking the value
248
00:14:09,151 --> 00:14:10,687
That's why you use
249
00:14:10,943 --> 00:14:12,735
2 equals signs
250
00:14:13,503 --> 00:14:16,575
Anytime you're inside of the printer sees of a condition
251
00:14:16,831 --> 00:14:20,159
Anytime you really checking to see what a value is
252
00:14:20,671 --> 00:14:22,463
Can you use two equal signs
253
00:14:22,719 --> 00:14:28,863
You going to be using two equal signs of the time when you're scripting in your eyes going to be using
254
00:14:29,119 --> 00:14:32,191
Do anal signs all the time when you're scripting
255
00:14:33,215 --> 00:14:34,239
Let it play
256
00:14:36,799 --> 00:14:38,591
So because of the ground is here
257
00:14:38,847 --> 00:14:44,223
Until we're grounded again
258
00:14:44,479 --> 00:14:45,759
Curly kale
259
00:14:47,551 --> 00:14:48,575
Perfect
260
00:14:49,343 --> 00:14:50,879
Alright that was easy
261
00:14:51,391 --> 00:14:57,535
Now sometimes you want to clean up code after you've written it and it works and you know works in fact the out are you there
262
00:14:57,791 --> 00:15:00,095
Best to clean up your code after you know it works
263
00:15:00,607 --> 00:15:04,703
Why no we can probably actually just remove all of this
264
00:15:05,471 --> 00:15:11,615
In by the fault unity understands that if we say and grounded really saying is in grounded
265
00:15:11,871 --> 00:15:12,639
Equals true
266
00:15:13,151 --> 00:15:15,711
If you wanted to check and see if it was false
267
00:15:15,967 --> 00:15:17,759
We either do it this way
268
00:15:18,271 --> 00:15:19,807
If granted = false
269
00:15:22,111 --> 00:15:23,647
We can do it this way
270
00:15:23,903 --> 00:15:25,183
We could remove this
271
00:15:25,439 --> 00:15:27,743
And use an exclamation mark at the beginning
272
00:15:27,999 --> 00:15:29,535
What's another way of writing
273
00:15:29,791 --> 00:15:31,071
Equals Force
274
00:15:31,839 --> 00:15:33,887
Because we want to check to see if it's true
275
00:15:34,655 --> 00:15:35,679
All we do is there
276
00:15:36,959 --> 00:15:38,495
We press the jump button
277
00:15:38,751 --> 00:15:39,519
And
278
00:15:40,287 --> 00:15:41,567
We are grounded
279
00:15:42,335 --> 00:15:44,383
Lottery is going to be 10
280
00:15:45,407 --> 00:15:48,479
Just double check make sure the back code clean up
281
00:15:48,735 --> 00:15:49,759
Actually works
282
00:15:51,551 --> 00:15:52,575
Awesome
283
00:15:53,343 --> 00:15:54,111
Very good
284
00:15:58,207 --> 00:15:59,231
Everything works
285
00:15:59,999 --> 00:16:02,047
And we can be girl with the next section
20994
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.