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,800
Alright guys now we're to talk about one of my favourite things to add the
2
00:00:13,056 --> 00:00:14,848
And that is the enemies
3
00:00:15,104 --> 00:00:20,480
Search make a double platform here for an enemy to be able to walk on so maybe take this platform
4
00:00:20,736 --> 00:00:24,832
A nice little platform here and working at create
5
00:00:25,344 --> 00:00:26,112
An enemy
6
00:00:26,624 --> 00:00:30,464
The first thing we're going to do here is just go to our level 1 PSB
7
00:00:30,976 --> 00:00:35,328
Double click on that in let's just go ahead and create an enemy graphic
8
00:00:37,120 --> 00:00:40,448
Create a new layer here and its name this enemy
9
00:00:42,496 --> 00:00:47,104
And let's see hear about that use the rounded rectangle tool
10
00:00:47,616 --> 00:00:53,760
Maybe let's see here about 1000 pixel radius so it's really round so maybe
11
00:00:54,016 --> 00:00:55,040
Like this
12
00:00:55,296 --> 00:00:57,088
Just make it white for now
13
00:00:59,392 --> 00:01:00,397
With no stroke
14
00:01:00,399 --> 00:01:03,131
Subtitled by
-♪ online-courses.club ♪-
We compress knowledge for you!
https://t.me/joinchat/ailxpXoW3JVjYzQ1
15
00:01:03,132 --> 00:01:07,840
And what we can do is actually rasterize the shape currently is a vector ok a vector is
16
00:01:08,096 --> 00:01:14,240
Basically a math equation that creates your shape that's not actually pixel data it's more of a massacre
17
00:01:14,496 --> 00:01:17,312
So we can shift all of these shapes
18
00:01:18,592 --> 00:01:20,640
You make it look different traits
19
00:01:21,152 --> 00:01:24,480
Set a raster image Adobe Illustrator is for
20
00:01:26,016 --> 00:01:32,160
Photoshop is raster graphics better than the future before now we're going to right click on the landing rasterize layer
21
00:01:32,416 --> 00:01:34,976
And then we're going to use the rectangle selection tool
22
00:01:35,232 --> 00:01:41,376
It's little rounded bottom off
23
00:01:41,632 --> 00:01:43,680
Something like this ok that's our enemy
24
00:01:44,960 --> 00:01:47,520
What's about this PSB file
25
00:01:47,776 --> 00:01:49,312
Jump back in the Unity
26
00:01:49,824 --> 00:01:51,872
And it should show up right here
27
00:01:54,176 --> 00:01:55,200
You are
28
00:01:55,712 --> 00:01:57,504
Duchess going drag it by here
29
00:01:58,784 --> 00:02:01,856
MSP Shirley put this inside of layer
30
00:02:03,648 --> 00:02:05,696
Where is it one here
31
00:02:06,208 --> 00:02:06,720
Get
32
00:02:07,488 --> 00:02:12,352
And also this guy also need to be on later one as well
33
00:02:13,632 --> 00:02:14,656
Just clean that
34
00:02:15,424 --> 00:02:21,568
Ok so we have our enemy here
35
00:02:21,824 --> 00:02:24,640
What's a changes colour to be a little bit more threatening right baby
36
00:02:25,664 --> 00:02:27,968
When I'm full-time Game Dev pink
37
00:02:28,224 --> 00:02:29,504
There we go
38
00:02:29,760 --> 00:02:31,296
Ok so
39
00:02:31,808 --> 00:02:36,672
What the heck do we do now
40
00:02:36,928 --> 00:02:40,256
Is actually going to be a lot like the player
41
00:02:40,512 --> 00:02:42,048
Player moves
42
00:02:42,304 --> 00:02:48,192
Whether rigidbody in a capsule Collider in remember if we open up the new player script
43
00:02:48,448 --> 00:02:49,984
It extends
44
00:02:50,240 --> 00:02:52,032
2D physics object script
45
00:02:52,544 --> 00:02:54,336
So I think we can do the same
46
00:02:55,104 --> 00:02:56,128
With their enemy
47
00:02:56,384 --> 00:02:56,896
Script
48
00:02:58,432 --> 00:03:00,480
The first we need to actually just add
49
00:03:00,992 --> 00:03:02,272
A capsule Collider
50
00:03:02,528 --> 00:03:05,344
2D not the regular one but the 2D version
51
00:03:05,856 --> 00:03:07,904
That's going to ignore the z-axis
52
00:03:08,672 --> 00:03:13,792
Every double click on the enemy we consume a little bit there
53
00:03:14,048 --> 00:03:18,912
Collapsed this down here and you can see there's a small green circle there
54
00:03:19,168 --> 00:03:24,800
That's great actually nothing you just said it all remember guys we use a capsule Collider
55
00:03:25,312 --> 00:03:30,432
So I can smoothly climb up hills it doesn't get stuck on angles
56
00:03:30,944 --> 00:03:32,736
If it was a box Collider
57
00:03:34,528 --> 00:03:35,552
Judy
58
00:03:36,064 --> 00:03:41,952
Just like in real life if you imagine pushing a box up a hill it might start to Tumble in tip
59
00:03:42,208 --> 00:03:45,536
Because there's friction right here at the corner is getting car
60
00:03:45,792 --> 00:03:47,328
So we wanted to be
61
00:03:47,840 --> 00:03:49,120
Capsule Collider
62
00:03:50,400 --> 00:03:51,168
There we go
63
00:03:51,424 --> 00:03:52,704
Don't forget guys
64
00:03:53,472 --> 00:03:56,288
We also need to add a rigidbody 2D
65
00:03:58,080 --> 00:03:58,848
Collider
66
00:03:59,360 --> 00:04:03,456
Actually collides and stops the object from falling through things
67
00:04:03,712 --> 00:04:09,856
Original body makes it fall right it makes it an actual physics object that engages
68
00:04:10,112 --> 00:04:10,880
With gravity
69
00:04:11,904 --> 00:04:17,791
We can also be sure to change the constraints so that we can rotate in the Z axis
70
00:04:18,559 --> 00:04:19,839
We don't want to talk the other
71
00:04:20,095 --> 00:04:21,631
All over like this right
72
00:04:22,655 --> 00:04:27,775
The final thing we need to do here is just remember that the player had a collision detection
73
00:04:28,287 --> 00:04:31,615
Set a continuous just going to make it a little bit more effective
74
00:04:32,383 --> 00:04:34,175
At colliding with the ground
75
00:04:35,199 --> 00:04:37,247
We're not ever really wanted to go to sleep
76
00:04:38,271 --> 00:04:44,415
What's the inequality in a polite and these are necessarily required but these things are actually
77
00:04:44,671 --> 00:04:47,999
Allow the enemy to be very precise in its movement
78
00:04:49,279 --> 00:04:50,047
Ok
79
00:04:50,559 --> 00:04:53,119
Now the next step is just to create
80
00:04:53,375 --> 00:04:54,655
An enemy script
81
00:04:54,911 --> 00:04:57,727
Search click the plus I can hear c-sharp script
82
00:04:58,239 --> 00:05:00,031
Can I call this enemy
83
00:05:00,799 --> 00:05:06,943
And again guys I can't say this enough if you get errors and warnings and stuff
84
00:05:07,199 --> 00:05:13,343
The game is working don't worry about him I'm definitely gonna do a sort of spring cleaning episode where are we
85
00:05:13,599 --> 00:05:19,743
All of these aleros in Stafford trying to figure out why they showing up in that really cares there more like warnings
86
00:05:19,999 --> 00:05:26,143
So another worry about it for now I'm really jumped individual studio in start programming or enemy
87
00:05:26,911 --> 00:05:29,471
And you noticed that even as the default template
88
00:05:31,007 --> 00:05:32,543
40 subscript
89
00:05:32,799 --> 00:05:35,359
Do you know that extending to the monitor behaviour
90
00:05:35,615 --> 00:05:41,759
What is remember the new player actually extends to the physics object in a script
91
00:05:42,015 --> 00:05:44,319
Houses to have very precise movement
92
00:05:44,575 --> 00:05:50,463
That's very you need to players in enemies not necessarily a standard physics object in unity
93
00:05:51,231 --> 00:05:54,559
So we have this custom physics object script
94
00:05:55,071 --> 00:05:56,607
To that
95
00:05:57,119 --> 00:05:58,399
My enemy as well
96
00:05:58,655 --> 00:06:02,239
Because we have very similar movement to what the player is
97
00:06:02,495 --> 00:06:03,775
It's going to extend
98
00:06:04,287 --> 00:06:05,567
To a physics object
99
00:06:06,591 --> 00:06:09,663
That means we can actually just really quickly test here
100
00:06:09,919 --> 00:06:12,735
Remember a new player if we scroll down here
101
00:06:13,503 --> 00:06:15,295
We can set the target velocity
102
00:06:15,807 --> 00:06:17,343
To the horizontal into it
103
00:06:17,599 --> 00:06:19,903
So we can use a similar type
104
00:06:20,671 --> 00:06:21,439
Statement
105
00:06:21,695 --> 00:06:23,999
In the enemy so let's make it move to the right
106
00:06:24,511 --> 00:06:25,535
Target
107
00:06:26,047 --> 00:06:27,071
Velocity
108
00:06:27,583 --> 00:06:28,351
Equals
109
00:06:28,607 --> 00:06:30,655
New vector2
110
00:06:31,423 --> 00:06:33,215
SD Wan
111
00:06:33,471 --> 00:06:35,007
And then
112
00:06:35,519 --> 00:06:37,823
0 in the Y Direction is fine
113
00:06:38,335 --> 00:06:40,383
Alright so that should hopefully
114
00:06:41,151 --> 00:06:42,943
Get enemy to stop moving
115
00:06:43,455 --> 00:06:44,223
To the right
116
00:06:49,343 --> 00:06:51,647
So let's move our player
117
00:06:52,671 --> 00:06:55,231
Over here so we can actually see what happens
118
00:06:55,487 --> 00:06:56,767
The moment we hit play
119
00:07:00,863 --> 00:07:01,887
Nothing is happening
120
00:07:02,399 --> 00:07:03,935
Priory figured it out in you
121
00:07:04,703 --> 00:07:07,519
Ensure that every time you create your scripts guys
122
00:07:08,287 --> 00:07:09,567
You add your script
123
00:07:10,847 --> 00:07:11,359
2
124
00:07:11,871 --> 00:07:12,639
Prefab
125
00:07:13,919 --> 00:07:18,015
And don't forget to create a new prefab
126
00:07:19,039 --> 00:07:20,063
The enemy
127
00:07:20,831 --> 00:07:23,135
Ok now things should work at hip play
128
00:07:27,743 --> 00:07:28,511
Egos
129
00:07:29,023 --> 00:07:30,559
See how he behaves
130
00:07:34,655 --> 00:07:36,447
Any falls off
131
00:07:37,215 --> 00:07:43,103
Buildings behaving exactly how we won into that's awesome
132
00:07:43,871 --> 00:07:46,943
So what if I wanted this enemy
133
00:07:47,455 --> 00:07:48,479
To move
134
00:07:48,735 --> 00:07:52,831
La more I guess unique speed when I want to specify
135
00:07:53,343 --> 00:07:55,391
In the actual inspector over here
136
00:07:55,647 --> 00:07:58,719
What are we going to do is just like the player
137
00:07:59,231 --> 00:08:03,071
Create a serialised field I know it's going to be private
138
00:08:03,583 --> 00:08:07,167
And it's going to be a float value in a going to be max speed
139
00:08:07,935 --> 00:08:09,727
Now we can just make this
140
00:08:10,495 --> 00:08:11,775
Max speed
141
00:08:13,311 --> 00:08:15,615
And go back into unity
142
00:08:16,895 --> 00:08:21,503
And now we can set your max speed to something like an O2 maybe
143
00:08:22,015 --> 00:08:22,527
Hipley
144
00:08:25,087 --> 00:08:26,879
Ok very good
145
00:08:27,135 --> 00:08:30,207
Moves at a speed of 2 perfect
146
00:08:30,463 --> 00:08:31,999
One of the most
147
00:08:32,255 --> 00:08:38,399
Basic in rudimentary forms of enemy types in enemy movement
148
00:08:38,655 --> 00:08:42,239
Humanity is a patrolling enemy type
149
00:08:42,495 --> 00:08:48,127
So you're not in play mode here basically if you do something like this it's just
150
00:08:48,383 --> 00:08:51,199
Look for a legit seas one it's going to reverse course
151
00:08:52,735 --> 00:08:56,063
That's basically all our enemy is going to do
152
00:08:57,087 --> 00:09:02,719
Now we can definitely have a variable that says well I don't want you to avoid I just don't want you to fall
153
00:09:03,231 --> 00:09:05,791
So sometimes they could just fall off a ledge
154
00:09:06,047 --> 00:09:11,423
So maybe we can have two enemy types one that patrols and one that doesn't roll and just falls off ledges
155
00:09:11,679 --> 00:09:15,007
Also we won at 2 if it would say it's over here
156
00:09:15,263 --> 00:09:18,591
If it hits this while we wanted to reverse and get stuck
157
00:09:19,615 --> 00:09:21,663
How on Earth do we do that
158
00:09:22,431 --> 00:09:24,223
Well what are you something called
159
00:09:24,479 --> 00:09:26,015
Raycasts
160
00:09:26,271 --> 00:09:32,415
This might sound really complicated it's really nice it's not scary it sounds I know that when I first learnt about rape
161
00:09:32,671 --> 00:09:38,815
I really got scared and you guys don't need to be scared I'm going to work through it with you and hold your hand
162
00:09:39,071 --> 00:09:45,215
It's not that bad basically recast or these imaginary lasers
163
00:09:45,471 --> 00:09:48,799
Shoot from various locations of your player
164
00:09:49,055 --> 00:09:55,199
And we can choose where it shoots from what's the angle that issued from and that laser is that right
165
00:09:55,455 --> 00:09:58,271
Touches something else
166
00:09:58,527 --> 00:10:01,868
Then we can do something so it needs a condition and then we do something
167
00:10:01,869 --> 00:10:04,041
Subtitled by
-♪ online-courses.club ♪-
We compress knowledge for you!
https://t.me/joinchat/ailxpXoW3JVjYzQ1
168
00:10:04,042 --> 00:10:09,791
So in games the way that players can maybe see if they're at allege is they have a little
169
00:10:10,047 --> 00:10:12,607
Cast that happening right here
170
00:10:13,119 --> 00:10:17,215
Actually I can just draw it out for you with a shape year so let's take this shape
171
00:10:17,471 --> 00:10:21,055
Unless draw out an imaginary raycast
172
00:10:21,311 --> 00:10:23,615
To show you cannot what it's not look like
173
00:10:23,871 --> 00:10:25,151
This re cast
174
00:10:25,663 --> 00:10:26,943
You not going to be able to see it
175
00:10:27,967 --> 00:10:29,247
It's going to shoot out
176
00:10:30,015 --> 00:10:31,295
About right here
177
00:10:32,063 --> 00:10:34,879
And you could specify it's like right
178
00:10:35,391 --> 00:10:39,231
So if it shooting out at this length
179
00:10:39,487 --> 00:10:41,023
And it doesn't hear anything
180
00:10:41,791 --> 00:10:45,631
It's going to inform the enemy class the enemy script hey
181
00:10:45,887 --> 00:10:48,447
There's a lead here I need to be careful
182
00:10:48,703 --> 00:10:50,751
But if it's over here
183
00:10:51,263 --> 00:10:53,311
Hitting the ground
184
00:10:58,687 --> 00:11:03,807
Hey hey I'm not in your allege I'm going to go and keep moving ok
185
00:11:04,319 --> 00:11:08,927
It's really not that complicated in script something to show you how to do that
186
00:11:09,695 --> 00:11:11,999
Right now so really delete the ground
187
00:11:13,791 --> 00:11:16,095
And we're going to the enemy here
188
00:11:17,119 --> 00:11:19,935
In the jump into the enemy script
189
00:11:20,703 --> 00:11:21,983
Git create
190
00:11:23,263 --> 00:11:26,335
To raycast variables ok
191
00:11:26,591 --> 00:11:30,687
Create a private raycast hit
192
00:11:30,943 --> 00:11:31,711
2D
193
00:11:32,479 --> 00:11:34,783
And this is going to check for the right lead
194
00:11:35,807 --> 00:11:39,391
What's going to be called right ledge raycast
195
00:11:42,719 --> 00:11:48,863
Let's go ahead and another one private raycast hit 2D left
196
00:11:49,119 --> 00:11:50,655
Raycast
197
00:11:51,167 --> 00:11:53,215
Lowercase the c here
198
00:11:53,471 --> 00:11:57,055
Raycast hit you want to match the variable type here
199
00:11:58,591 --> 00:12:00,127
Ok
200
00:12:00,895 --> 00:12:06,783
So now we have a right ledge raycast hit and it left ledgeway cast variable
201
00:12:07,039 --> 00:12:13,183
Say that's tripped out and it's not really going to do anything right now just declaring these
202
00:12:13,439 --> 00:12:18,047
Cast hit 2DS into existence but they don't actually do anything right now
203
00:12:18,559 --> 00:12:24,703
So in a way I think this is we just created these little laser in metres these raycast e m
204
00:12:25,215 --> 00:12:31,359
And we can now use them almost like Caroline guns almost you going to shoot these rain
205
00:12:31,615 --> 00:12:35,967
Ask the various directions in check and see if we're hitting things right
206
00:12:36,223 --> 00:12:37,247
The here we go
207
00:12:37,759 --> 00:12:39,551
So let's write some pseudocode here
208
00:12:41,599 --> 00:12:42,367
Yes
209
00:12:42,623 --> 00:12:43,391
The
210
00:12:43,903 --> 00:12:45,439
Right ledge
211
00:12:45,695 --> 00:12:46,975
Raycast
212
00:12:47,231 --> 00:12:47,743
Hit
213
00:12:48,255 --> 00:12:54,399
Fires a laser that's called a laser and hits ground in front of the player
214
00:12:54,655 --> 00:12:56,191
On a rate
215
00:12:56,703 --> 00:12:59,519
We are not near a ledge
216
00:13:00,799 --> 00:13:03,359
Taxi breakers in the two lines here
217
00:13:04,127 --> 00:13:06,431
Would you do that by just doing this
218
00:13:08,479 --> 00:13:10,783
Alright so this is our pseudocode here
219
00:13:11,551 --> 00:13:15,647
So the first thing you need to do is tell the raycast
220
00:13:15,903 --> 00:13:18,975
What to do where do what's the direction
221
00:13:19,487 --> 00:13:23,071
What's rated out like this
222
00:13:24,351 --> 00:13:25,119
Equals
223
00:13:25,375 --> 00:13:26,399
Physics
224
00:13:27,167 --> 00:13:33,311
2D raycast and thinking how to write this and looking at unity document
225
00:13:33,567 --> 00:13:37,151
Switching on my other monitor and you guys should too
226
00:13:37,919 --> 00:13:38,943
New
227
00:13:39,199 --> 00:13:40,479
Electrocute
228
00:13:40,991 --> 00:13:45,599
And let's see here what is this mean well or telling the raycast
229
00:13:45,855 --> 00:13:48,159
Where to omit from
230
00:13:48,415 --> 00:13:49,951
Where we shooting it from
231
00:13:50,463 --> 00:13:54,303
Well we wanted to admit from the position of the enemy right
232
00:13:54,559 --> 00:13:59,679
So we got to do is type transformed at position x
233
00:13:59,935 --> 00:14:00,703
Karma
234
00:14:00,959 --> 00:14:01,983
Transform
235
00:14:02,239 --> 00:14:04,287
Positioned at why
236
00:14:04,799 --> 00:14:05,823
UK
237
00:14:06,079 --> 00:14:08,383
What else is going on zoom and a little bit
238
00:14:08,639 --> 00:14:09,663
Looks like we have
239
00:14:10,175 --> 00:14:11,967
Female prime minister film
240
00:14:13,247 --> 00:14:14,527
The next one
241
00:14:15,039 --> 00:14:20,671
So if you type comma the next one right here it tells you in a little call out
242
00:14:20,927 --> 00:14:23,487
But now we need to specify the direction
243
00:14:23,999 --> 00:14:28,863
A very quick way of writing the direction is vector to down
244
00:14:29,119 --> 00:14:33,215
In all down really is 0 and -1
245
00:14:33,471 --> 00:14:35,007
Settle down really is
246
00:14:36,031 --> 00:14:37,567
Vector down
247
00:14:38,591 --> 00:14:41,151
Picture to down comma
248
00:14:41,407 --> 00:14:47,551
And now we're going to do the actual distance or the size of the red cast
249
00:14:47,807 --> 00:14:48,831
What's 2
250
00:14:49,087 --> 00:14:50,367
24 now
251
00:14:51,647 --> 00:14:54,463
And that's about all we want to do for now
252
00:14:56,255 --> 00:15:00,607
So literally all we just did was we told the right lead raycast hit
253
00:15:01,119 --> 00:15:04,447
What direction what size where is going to go
254
00:15:05,215 --> 00:15:07,775
And then now that we've told it what to do
255
00:15:08,287 --> 00:15:09,823
We can check and see
256
00:15:10,079 --> 00:15:11,359
Hit anything
257
00:15:11,871 --> 00:15:12,383
Now
258
00:15:12,639 --> 00:15:14,943
I guess I can go in the unity and hit play
259
00:15:15,199 --> 00:15:17,503
Answer guys I can't see anything
260
00:15:18,015 --> 00:15:19,295
Can do that
261
00:15:21,087 --> 00:15:22,623
If you go into unity
262
00:15:23,647 --> 00:15:24,671
And it play
263
00:15:29,791 --> 00:15:32,607
You can't see anything nothing is happening right
264
00:15:33,375 --> 00:15:37,727
Because we've told the raycast to shooting a certain Direction
265
00:15:37,983 --> 00:15:44,127
It does actually show up and there's no conditions being met anyway it's not checking to see if you're hitting anything
266
00:15:44,383 --> 00:15:48,735
Are telling the radius what to do is to shoot in a certain Direction at a certain position
267
00:15:49,247 --> 00:15:52,063
So now we want to do is ladybug
268
00:15:53,087 --> 00:15:59,231
The Ray do you get some other debug.log that log I'm shooting
269
00:16:00,511 --> 00:16:03,839
Is also debug draw Ray
270
00:16:04,607 --> 00:16:07,167
Escape draw a raycast ok
271
00:16:07,423 --> 00:16:13,567
So where about to do is a little bit redundant to be honest I I cannot wish and unity had a quicker way of doing this
272
00:16:13,823 --> 00:16:19,967
This is about the only way that we can do this ok so we're going to remove this log that was just
273
00:16:20,991 --> 00:16:27,135
Debug in organ he was basically right out what we brought out here
274
00:16:27,391 --> 00:16:30,207
So debug
275
00:16:30,719 --> 00:16:32,767
New vector2
276
00:16:33,791 --> 00:16:37,119
Transform position x
277
00:16:37,887 --> 00:16:40,959
Transformed at position
278
00:16:41,727 --> 00:16:42,495
Karma
279
00:16:42,751 --> 00:16:46,079
The Direction now the thing is
280
00:16:47,615 --> 00:16:48,383
Is that
281
00:16:49,151 --> 00:16:54,783
Raycast parameters appear or different than the drawer parameters
282
00:16:55,039 --> 00:17:01,183
The drawer primers instead of a comma and then to you actually just go x x 2
283
00:17:01,439 --> 00:17:05,023
It's really weird honestly the raycast scripts
284
00:17:05,279 --> 00:17:11,423
Horsey Sharp and unity or little bit another word
285
00:17:11,679 --> 00:17:17,823
Confusing but it's ok guys again making games in 10-years I still have to reference the doctor
286
00:17:18,079 --> 00:17:19,871
Patient to make sure I know what I'm doing here
287
00:17:20,383 --> 00:17:21,407
And that's ok
288
00:17:22,175 --> 00:17:23,967
Alright so we're going to go down
289
00:17:24,223 --> 00:17:26,783
We can also specify the colour
290
00:17:27,039 --> 00:17:29,855
Colour.is blue
291
00:17:31,135 --> 00:17:32,415
Ok
292
00:17:32,671 --> 00:17:34,975
Today's should draw a ray
293
00:17:35,487 --> 00:17:38,303
Down in the sizes going to be too
294
00:17:39,071 --> 00:17:44,703
Alright would say that out in jumping unity and see if we can see this re being drawn
295
00:17:45,215 --> 00:17:51,359
Now before we actually have playlist just said our enemies movement to about point
296
00:17:51,615 --> 00:17:53,919
Just so it's moving a little bit slower so we can see it
297
00:17:54,687 --> 00:17:55,711
NIC play
298
00:17:55,967 --> 00:17:57,503
Where is ra
299
00:17:59,551 --> 00:18:03,903
It's being drawn from the centre that transform deposition at x
300
00:18:04,159 --> 00:18:05,951
Transformed application that why
301
00:18:07,487 --> 00:18:11,327
Back tattoos down going down in the direction of down
302
00:18:12,095 --> 00:18:14,143
Is it a size or length
303
00:18:14,399 --> 00:18:15,935
A 2 units
304
00:18:17,215 --> 00:18:18,239
That's perfect
305
00:18:18,751 --> 00:18:22,335
So this is going to check and see if it's basically a laser
306
00:18:22,847 --> 00:18:25,151
It's going to check and see if you're hitting the ground
307
00:18:25,407 --> 00:18:31,551
Currently we don't have any conditions will have an if statement to check and see if we actually touching anything right now all week
308
00:18:31,807 --> 00:18:34,879
Is a raycast being shot towards the ground
309
00:18:35,391 --> 00:18:36,671
Always below the enemy
310
00:18:37,951 --> 00:18:42,303
It's also been debunked it's been drawn to the same view
311
00:18:42,815 --> 00:18:48,191
Now you may wonder how is this going to detect if there's a Ledge to my right
312
00:18:48,703 --> 00:18:52,031
Well are we going to do is go to a script here
313
00:18:53,055 --> 00:18:55,871
I'm actually just shift it to the right a little bit
314
00:18:56,383 --> 00:18:59,967
No not necessarily at the exact exposition centre
315
00:19:00,479 --> 00:19:03,039
To the enemy but let's do Plus
316
00:19:03,295 --> 00:19:03,807
1
317
00:19:06,111 --> 00:19:08,415
Anytime you make an adjustment
318
00:19:09,439 --> 00:19:11,231
When you're casting your Ray
319
00:19:11,487 --> 00:19:17,631
You also make the Adjustment when you're drawing it as well again pretty returned it I cannot lie
320
00:19:19,167 --> 00:19:24,287
About the only solution I've ever found so let's go ahead in
321
00:19:24,799 --> 00:19:25,567
Play
322
00:19:26,335 --> 00:19:28,127
Embassy now
323
00:19:30,175 --> 00:19:33,503
Laser it's almost like a camera on a car something
324
00:19:33,759 --> 00:19:35,039
That can detect
325
00:19:35,551 --> 00:19:36,319
Where
326
00:19:36,575 --> 00:19:37,343
The enemy
327
00:19:37,855 --> 00:19:39,903
Is init a close to a lead tray
328
00:19:40,415 --> 00:19:43,231
I can warn the enemy and tell them to reverse course
329
00:19:43,743 --> 00:19:45,279
So let's make this point to
330
00:19:46,047 --> 00:19:52,191
And you can see now that as it approaches the ledge we can actually check and see if it's touching anything I'm not
331
00:19:52,447 --> 00:19:57,823
Anything reverse course and change its direction in move in the other way ok
332
00:19:58,335 --> 00:20:00,639
So keen on little more control
333
00:20:00,895 --> 00:20:02,943
4anime here well
334
00:20:03,199 --> 00:20:04,735
Having one here
335
00:20:04,991 --> 00:20:09,343
What's maybe have a variable called raycast offset
336
00:20:09,855 --> 00:20:10,879
X
337
00:20:11,135 --> 00:20:17,279
That doesn't exist right we need actually that is appear to be serialised so I can
338
00:20:17,535 --> 00:20:18,815
Get the inspector
339
00:20:19,071 --> 00:20:20,607
I do want to be private
340
00:20:21,631 --> 00:20:24,447
And I wanted to be a vector 2
341
00:20:24,959 --> 00:20:27,775
Whittaker l cast after
342
00:20:29,823 --> 00:20:32,127
Raycast offset that x
343
00:20:32,639 --> 00:20:37,247
Is replacing what we had there which was a wine to make sure we do it in the debug area as well
344
00:20:38,783 --> 00:20:40,319
And also
345
00:20:40,575 --> 00:20:43,391
What we have control over at the length
346
00:20:43,903 --> 00:20:45,183
Other recast as well
347
00:20:46,719 --> 00:20:50,815
So when are we going to create a new serializefield it's definitely private
348
00:20:51,071 --> 00:20:54,911
Can be a float in a Justin Bieber raycast link
349
00:20:58,751 --> 00:21:04,895
Default 20 I definitely don't want 20 so let's have a default of 2 and we can
350
00:21:05,151 --> 00:21:06,431
Change it in the unity editor
351
00:21:06,687 --> 00:21:07,711
If we see fit
352
00:21:08,479 --> 00:21:09,247
Alright
353
00:21:09,503 --> 00:21:15,391
And how about we add that raycast offset to the trains from that position at y as well
354
00:21:17,696 --> 00:21:18,720
Here we go
355
00:21:20,256 --> 00:21:22,048
Anyone here as well
356
00:21:23,328 --> 00:21:25,376
Alright so what are we just do that guys
357
00:21:25,632 --> 00:21:26,144
Well
358
00:21:26,912 --> 00:21:33,056
We created a new vector to variable that's basically and X and Y value right so curly
359
00:21:33,312 --> 00:21:39,456
Play fault it's really 200 but we can actually just that in the inspector in unity
360
00:21:39,712 --> 00:21:45,856
Play and we've added that to the transformed position that xx so we can have a little bit of an
361
00:21:46,112 --> 00:21:46,624
Set
362
00:21:46,880 --> 00:21:47,904
In the extraction
363
00:21:48,416 --> 00:21:50,464
Nasser in the y-direction
364
00:21:51,488 --> 00:21:56,608
We also have control over the length in that forget about that raycast length
365
00:21:56,864 --> 00:21:57,632
There we go
366
00:21:58,912 --> 00:22:00,704
And also
367
00:22:01,728 --> 00:22:02,752
This as well
368
00:22:03,008 --> 00:22:03,776
A Catholic
369
00:22:04,288 --> 00:22:06,848
And now we have control over the length
370
00:22:07,104 --> 00:22:12,224
And also the offset of the raycast when we go into a unity editor
371
00:22:12,480 --> 00:22:18,624
Why do we want controller with this well because some enemies might be a little bit more precise than other enemies
372
00:22:18,880 --> 00:22:25,024
You had a really fast anime that can run in search of Sprinter crawl across the rooftops tray
373
00:22:25,280 --> 00:22:31,424
Definitely want that recast to be much more offset maybe over here so that he could maybe
374
00:22:31,680 --> 00:22:35,008
He's going to approach an edge because he's moving so fast right
375
00:22:35,776 --> 00:22:41,664
So what we want to do here is just change a raycast offset to be about 1 here
376
00:22:42,688 --> 00:22:47,296
Unless you a raycast length of 2 here and let's be sure we override
377
00:22:48,064 --> 00:22:49,088
The enemy prefab
378
00:22:51,136 --> 00:22:53,184
Alright to play
379
00:22:56,512 --> 00:22:58,048
We have that recast
380
00:22:58,304 --> 00:23:02,144
Appearing to the right here in look even at runtime we can change
381
00:23:02,656 --> 00:23:06,752
How far we want it to be raped wanted to be really close maybe something like that
382
00:23:07,008 --> 00:23:09,056
He gets right up to the edge
383
00:23:09,312 --> 00:23:11,360
Or maybe super far away rain
384
00:23:11,616 --> 00:23:17,760
No change the length so that maybe we want our enemy to be able to fall down a size like this
385
00:23:18,016 --> 00:23:23,904
But we definitely don't want to be falling all the way down so that's why you would make the raycast length like that
386
00:23:25,952 --> 00:23:28,000
So the last thing you want to do here for
387
00:23:28,512 --> 00:23:33,376
Creating these lejwe Cassie's just create a left one as well
388
00:23:33,888 --> 00:23:36,704
So I'm going to do is just copy this
389
00:23:37,216 --> 00:23:39,264
In all we had a newest just
390
00:23:40,032 --> 00:23:41,824
Change it to the word left
391
00:23:42,592 --> 00:23:44,896
And then invite those numbers right
392
00:23:45,664 --> 00:23:48,480
So this is not going to be right now Drake ass is going to be
393
00:23:48,992 --> 00:23:51,040
Left lead raycast
394
00:23:51,552 --> 00:23:56,928
What's it going to make this - so the expositions of the centre
395
00:23:57,184 --> 00:24:00,768
Also - the raycast offset
396
00:24:01,280 --> 00:24:07,168
No because left is only a horizontal value we don't need to do anything with the why
397
00:24:08,192 --> 00:24:09,984
And
398
00:24:10,240 --> 00:24:14,848
Just be sure we change the debug is well here so - here
399
00:24:17,408 --> 00:24:21,760
And when we just change the colour to be oh no green
400
00:24:22,016 --> 00:24:23,552
So they can see the two of us
401
00:24:24,320 --> 00:24:25,600
Ok
402
00:24:25,856 --> 00:24:27,648
That's really all we need to do
403
00:24:28,160 --> 00:24:29,440
To create those rays
404
00:24:29,952 --> 00:24:30,976
Play here
405
00:24:33,792 --> 00:24:39,424
So now we have these raise these lasers that are going to detect and tell the enemy
406
00:24:39,936 --> 00:24:41,472
Where they are in the world
407
00:24:41,984 --> 00:24:45,056
Am I approaching a Ledge let's beat them up here
408
00:24:45,312 --> 00:24:51,456
I'm approaching a Ledge crap turnaround right that's what I'm going to do and that's not actually scripted guys and
409
00:24:51,712 --> 00:24:52,480
Just changing it
410
00:24:52,992 --> 00:24:58,112
Right now but if you touches the air she's going to need a reverse and then as he moves over here
411
00:24:59,392 --> 00:25:01,696
Turn around
412
00:25:02,464 --> 00:25:05,792
That's what we want to do and we're going to do that
413
00:25:06,304 --> 00:25:07,328
I checking
414
00:25:07,840 --> 00:25:08,864
Using if
415
00:25:09,120 --> 00:25:13,984
So checking to see if he's raycaster actually touching the ground
416
00:25:14,496 --> 00:25:16,800
Is actually not that challenging all
417
00:25:17,312 --> 00:25:19,360
Oliver is going to a script here
418
00:25:19,616 --> 00:25:20,640
And
419
00:25:20,896 --> 00:25:25,760
What's cleaner somebody's comments here in just make it say check for right ledge
420
00:25:27,040 --> 00:25:27,808
The end
421
00:25:28,832 --> 00:25:31,136
Check for last leg
422
00:25:32,672 --> 00:25:38,816
One of the reasons why I don't like riding Raker script is because they usually really long
423
00:25:39,072 --> 00:25:41,632
Any require me to zoom out so I'm actually going to
424
00:25:42,400 --> 00:25:44,704
Stream down the size of the Right window there
425
00:25:45,472 --> 00:25:47,008
We can see a little bit better here
426
00:25:47,520 --> 00:25:48,288
Ok
427
00:25:48,800 --> 00:25:50,336
So are we going to do here
428
00:25:50,848 --> 00:25:52,128
We're just going to check
429
00:25:52,384 --> 00:25:53,152
To see
430
00:25:53,408 --> 00:25:56,224
What the right ledge raycast hit
431
00:25:56,480 --> 00:26:00,832
Collider is see when you create a raycast
432
00:26:01,600 --> 00:26:02,624
Hit to die
433
00:26:03,392 --> 00:26:07,488
It immediately will store information inside of this variable
434
00:26:09,280 --> 00:26:14,144
One thing that stored in the information is weather is hitting a Collider ok
435
00:26:14,400 --> 00:26:16,960
Some of the things we can type it if
436
00:26:19,264 --> 00:26:24,640
Right ledge raycast hit centre there.com Rider
437
00:26:25,664 --> 00:26:27,712
If it equals nothing
438
00:26:29,248 --> 00:26:30,272
Well then
439
00:26:30,528 --> 00:26:34,368
Oh man write a letter tray there's nothing below me on my right
440
00:26:35,392 --> 00:26:36,672
I'm going to be back
441
00:26:38,464 --> 00:26:41,792
Crap I'm
442
00:26:42,048 --> 00:26:44,608
Close to a right
443
00:26:44,864 --> 00:26:45,632
Ledge
444
00:26:47,936 --> 00:26:49,472
Decibel metre works
445
00:26:51,008 --> 00:26:53,312
The nearest that I like to test things out
446
00:26:53,568 --> 00:26:55,360
Very often when I'm running scripts
447
00:26:56,640 --> 00:27:02,272
That helps me to avoid getting confused increase the max speed here
448
00:27:02,528 --> 00:27:03,552
And
449
00:27:05,088 --> 00:27:06,112
Nothing is happening
450
00:27:06,624 --> 00:27:08,672
Well the reason why
451
00:27:09,440 --> 00:27:11,744
Is not actually telling us
452
00:27:12,768 --> 00:27:17,120
There's nothing to his right is because there is actually something to his right
453
00:27:17,376 --> 00:27:18,656
And it's something invisible
454
00:27:19,424 --> 00:27:20,960
What is he actually touching
455
00:27:21,472 --> 00:27:24,800
What's go ahead in create an Elsa
456
00:27:25,056 --> 00:27:25,824
Else
457
00:27:27,616 --> 00:27:30,432
Debug.log I'm
458
00:27:30,944 --> 00:27:32,224
Touching
459
00:27:32,480 --> 00:27:34,272
Space Plus
460
00:27:35,808 --> 00:27:41,952
Debug Outlook that is right ledge raycast hit Collider
461
00:27:42,208 --> 00:27:43,488
Object
462
00:27:44,000 --> 00:27:48,864
So what is this a statement doing it saying if I'm not touching anything
463
00:27:50,400 --> 00:27:52,448
We'll get that to the council
464
00:27:53,216 --> 00:27:53,984
Else
465
00:27:54,240 --> 00:27:56,032
If I am touching something
466
00:27:56,288 --> 00:28:01,152
If my Collider is not knowledge actually something then I'm getting debug
467
00:28:01,408 --> 00:28:02,432
I'm touching
468
00:28:02,944 --> 00:28:08,064
What that something is so it's see what we're actually touching to get a better idea
469
00:28:08,320 --> 00:28:12,160
This is why you want to use debug.log a lot when you're making your game
470
00:28:12,672 --> 00:28:16,256
Helps you know those invisible things that you're touching
471
00:28:16,512 --> 00:28:18,048
Oh my goodness luck
472
00:28:18,560 --> 00:28:19,328
What is a
473
00:28:20,096 --> 00:28:22,400
Attaching a polygon camera can finally
474
00:28:22,656 --> 00:28:23,936
What is that
475
00:28:24,192 --> 00:28:25,728
Diaz remember
476
00:28:25,984 --> 00:28:28,288
We have a polygon camera can finally
477
00:28:28,800 --> 00:28:30,080
Wayback
478
00:28:30,336 --> 00:28:32,128
Earlier in the series
479
00:28:33,408 --> 00:28:34,944
And that is actually
480
00:28:35,712 --> 00:28:37,248
This trigger zone
481
00:28:37,504 --> 00:28:40,064
Tell the camera to stop at certain areas
482
00:28:40,320 --> 00:28:41,344
Sorry anime
483
00:28:42,112 --> 00:28:45,440
Is raycasts or interacting with that
484
00:28:45,696 --> 00:28:47,232
That's really weird
485
00:28:47,488 --> 00:28:49,792
Well the way that we are actually going to fix that
486
00:28:50,048 --> 00:28:54,912
Where should you use these things called layers appear in my anime
487
00:28:55,680 --> 00:28:57,216
Can I have this layer
488
00:28:57,984 --> 00:28:59,008
Drop down here
489
00:28:59,264 --> 00:29:02,592
And you know this we have a few layers we have default
490
00:29:03,104 --> 00:29:04,640
Transparent FX
491
00:29:04,896 --> 00:29:06,432
Ignore raycast
492
00:29:06,688 --> 00:29:07,456
Water
493
00:29:07,712 --> 00:29:08,480
NUI
494
00:29:09,248 --> 00:29:14,624
What we can do is actually set the polygon camera Collider to ignore raycast
495
00:29:16,160 --> 00:29:17,440
Now it's a play
496
00:29:18,720 --> 00:29:20,000
Ok great
497
00:29:20,768 --> 00:29:23,072
It looks like he's just touching the ground
498
00:29:23,584 --> 00:29:25,120
He's not actually touching
499
00:29:25,376 --> 00:29:26,400
Anything else
500
00:29:27,168 --> 00:29:27,936
Perfect
501
00:29:29,216 --> 00:29:34,080
Selfie going to enemy here in increases speed just a little bit
502
00:29:34,336 --> 00:29:37,408
Just have to wait for the sun to set
503
00:29:37,920 --> 00:29:38,944
There we go
504
00:29:39,200 --> 00:29:43,296
The nearest that is still touching the ground sticking out picking up picking up
505
00:29:43,808 --> 00:29:46,112
And as he gets to the right here
506
00:29:46,624 --> 00:29:48,160
If it stops
507
00:29:49,696 --> 00:29:52,256
He knows he's close to the ledge
508
00:29:53,536 --> 00:29:56,352
Perfect that's exactly what we wanted it to be
509
00:29:56,864 --> 00:29:59,168
So now that we know this condition works
510
00:29:59,424 --> 00:30:00,448
We can actually
511
00:30:00,704 --> 00:30:01,728
Change
512
00:30:02,240 --> 00:30:03,520
The direction
513
00:30:03,776 --> 00:30:04,800
The enemy
514
00:30:05,312 --> 00:30:09,664
How exactly are we going to change the direction of the enemy
515
00:30:10,176 --> 00:30:12,736
Well we got to do is actually just multiply
516
00:30:13,504 --> 00:30:14,528
Speed
517
00:30:15,552 --> 00:30:16,832
X
518
00:30:17,856 --> 00:30:19,392
A direction variable
519
00:30:19,648 --> 00:30:22,208
That doesn't exist yet sort create that
520
00:30:22,976 --> 00:30:26,560
We don't need this to be serialised because you don't need to see it in the inspector
521
00:30:26,816 --> 00:30:31,936
And if given integers you going to be 1 or -1 right so private integer
522
00:30:32,704 --> 00:30:33,728
Direction
523
00:30:35,520 --> 00:30:38,080
Because we don't have it default 21
524
00:30:40,128 --> 00:30:44,224
If it then he's going to start out at basically
525
00:30:44,480 --> 00:30:46,272
0 and he won't even move
526
00:30:47,040 --> 00:30:49,856
So if he actually is getting close to the ledge
527
00:30:50,112 --> 00:30:52,672
What we're going to do as we're going to set a direction
528
00:30:53,696 --> 00:30:54,720
To -1
529
00:30:55,232 --> 00:30:58,048
What is the recast does it take something to the right
530
00:30:58,560 --> 00:31:01,120
Where is not going to do anything we can keep this feedback here
531
00:31:01,632 --> 00:31:04,192
Let's see if he switches directions
532
00:31:04,704 --> 00:31:06,240
The momentary approaches
533
00:31:06,496 --> 00:31:07,776
In all area
534
00:31:08,032 --> 00:31:10,080
Meaning there's nothing to his right
535
00:31:12,384 --> 00:31:18,272
Set max speed to one year because it's driving me crazy
536
00:31:21,088 --> 00:31:22,112
Perfect
537
00:31:22,368 --> 00:31:28,512
Works great so we just need to get it to work for the left lead as well so how we got to do is just copy
538
00:31:28,768 --> 00:31:29,536
Play a cold here
539
00:31:30,304 --> 00:31:31,584
Place it
540
00:31:32,096 --> 00:31:35,936
And we'll set the direction to one if the left ledge
541
00:31:36,192 --> 00:31:37,216
Raycast
542
00:31:37,472 --> 00:31:38,240
Is stuffing
543
00:31:39,520 --> 00:31:42,080
Save it out here and
544
00:31:42,848 --> 00:31:43,616
Take a look
545
00:31:47,200 --> 00:31:50,784
Looks like we have a no reference here it's causing some issues
546
00:31:51,040 --> 00:31:57,184
And no references basically there is no reference to an object there's nothing set so we double
547
00:31:57,440 --> 00:32:00,000
And it looks like it's saying I'm touching
548
00:32:00,512 --> 00:32:05,632
It looks like I need to change this out to be left ledge raycast hit
549
00:32:06,144 --> 00:32:07,680
Atlas take a look here
550
00:32:08,704 --> 00:32:09,728
What's that his
551
00:32:09,984 --> 00:32:11,264
Max Speed 2
552
00:32:11,776 --> 00:32:13,312
Exeter to here
553
00:32:13,568 --> 00:32:14,848
And a supply
554
00:32:15,360 --> 00:32:17,920
So I can speed it up to get an idea what's going on
555
00:32:19,968 --> 00:32:21,760
Ok ok
556
00:32:29,440 --> 00:32:30,720
Did you guys catch what happened
557
00:32:31,744 --> 00:32:34,304
Teresian why he didn't turn around
558
00:32:34,560 --> 00:32:35,840
Is because
559
00:32:36,352 --> 00:32:38,656
This raycast is taller
560
00:32:39,680 --> 00:32:40,960
Ennis Leisure
561
00:32:41,472 --> 00:32:43,264
So he's just going to keep going down
562
00:32:44,544 --> 00:32:46,592
Because I recast high
563
00:32:46,848 --> 00:32:48,896
Etc long right
564
00:32:49,152 --> 00:32:55,296
So are we going to do is actually just set a recast height or Discovery cast link
565
00:32:56,320 --> 00:32:57,088
1
566
00:32:58,112 --> 00:32:59,392
Now let's try it
567
00:33:03,232 --> 00:33:06,304
Ok so like it's shorter than the actual lead here
568
00:33:06,560 --> 00:33:08,864
So he should turn around there we go
569
00:33:09,888 --> 00:33:11,936
Awesome that's great
570
00:33:13,216 --> 00:33:19,360
Is working just fine I like it ok so now we need to do
571
00:33:19,616 --> 00:33:23,968
Talk about what if he hits walls right if he has a wall is he going to turn around
572
00:33:24,480 --> 00:33:28,832
Actually no let's have a check it we put him
573
00:33:29,088 --> 00:33:30,368
Right here
574
00:33:30,880 --> 00:33:32,416
Tennis move to player
575
00:33:34,464 --> 00:33:36,512
What's going to happen when he touches a war
576
00:33:39,072 --> 00:33:40,608
He gets stuck
577
00:33:41,376 --> 00:33:42,912
So what if we wanted
578
00:33:43,424 --> 00:33:46,496
The enemy to reverse its Direction when it hits
579
00:33:47,008 --> 00:33:47,776
What's
580
00:33:48,288 --> 00:33:50,336
What is actually very similar
581
00:33:50,848 --> 00:33:51,872
A few changes
582
00:33:52,128 --> 00:33:54,432
To what we made for the ledges
583
00:33:55,200 --> 00:33:59,808
Open up the enemy c-sharp script and all going to do is create a new private
584
00:34:02,368 --> 00:34:03,392
Broadcasted
585
00:34:04,928 --> 00:34:07,488
Everyday call this right wall
586
00:34:07,744 --> 00:34:08,768
Raycast
587
00:34:09,280 --> 00:34:13,376
Unless it's going copy there in Crete
588
00:34:14,400 --> 00:34:15,936
Difference between DS
589
00:34:16,192 --> 00:34:22,336
Any leads the right and left wall raycasts actually just going to
590
00:34:22,592 --> 00:34:25,920
Send a raycast out from the centre of our enemy to the right
591
00:34:26,176 --> 00:34:27,456
And also to the left
592
00:34:27,968 --> 00:34:28,992
Check for walls
593
00:34:30,272 --> 00:34:31,552
It's behind
594
00:34:31,808 --> 00:34:32,832
Set up
595
00:34:34,624 --> 00:34:38,976
Steven comments here check for right wall
596
00:34:39,744 --> 00:34:43,584
A very similar code to what we see here
597
00:34:43,840 --> 00:34:47,424
Gonna be right wall raycast hit
598
00:34:48,192 --> 00:34:49,472
Equals
599
00:34:49,984 --> 00:34:51,008
Physics
600
00:34:53,056 --> 00:34:54,336
Recast
601
00:34:55,360 --> 00:34:57,152
New vector2
602
00:34:58,176 --> 00:35:03,296
Transformed at positions but in this case we're going to do smack DAB in the centre
603
00:35:03,552 --> 00:35:04,576
This gameobject
604
00:35:04,832 --> 00:35:07,904
Transformed that position that's why
605
00:35:10,720 --> 00:35:16,352
The comma instead of Vector to down we're going to do vector to the right
606
00:35:17,632 --> 00:35:19,680
NN raycast length
607
00:35:19,936 --> 00:35:20,704
It's fine
608
00:35:21,472 --> 00:35:23,776
Please be sure to debug
609
00:35:24,288 --> 00:35:27,360
The real as well so we're going to copy this actually just paste it
610
00:35:28,640 --> 00:35:31,968
In so all this is going to be is directly from the centre
611
00:35:32,480 --> 00:35:34,016
X and Y
612
00:35:34,784 --> 00:35:36,320
Vectra Tudor right
613
00:35:36,576 --> 00:35:38,368
X x 2 regex length
614
00:35:38,624 --> 00:35:44,768
Just you and I know what's you are so red for right ok so that's going to check for
615
00:35:46,304 --> 00:35:49,632
Double check in see if that Ray is actually being drawn
616
00:35:51,424 --> 00:35:56,800
Ok looks like we can do this so it's being drawn from the centre of enemy
617
00:35:57,056 --> 00:36:01,408
In this rate is going to be used to check if we touch or right what
618
00:36:03,712 --> 00:36:08,064
Alright so let's just ride out the condition yes
619
00:36:08,576 --> 00:36:11,392
Write wall raycast hit
620
00:36:11,648 --> 00:36:12,928
Dark lighter
621
00:36:13,184 --> 00:36:17,024
Does not equal meaning if it is touching something
622
00:36:17,280 --> 00:36:19,840
Dennis debug.log
623
00:36:20,352 --> 00:36:23,680
I'm touching a wall on my right
624
00:36:24,704 --> 00:36:30,848
NN what are actual Collider is so right leg break cast hit the
625
00:36:33,152 --> 00:36:35,712
In the game are checked that back later is on
626
00:36:36,480 --> 00:36:37,504
We can save it
627
00:36:38,016 --> 00:36:39,296
Back in the Unity
628
00:36:39,808 --> 00:36:43,904
In a Future episode guys we're going to clear up all these alerts so don't worry about it for now
629
00:36:44,416 --> 00:36:45,440
Play
630
00:36:48,000 --> 00:36:48,768
Ok
631
00:36:49,536 --> 00:36:50,560
That's great
632
00:36:54,400 --> 00:36:54,912
So
633
00:36:56,192 --> 00:36:57,984
He's going to
634
00:36:59,776 --> 00:37:01,056
Just look for
635
00:37:02,336 --> 00:37:03,104
Wars
636
00:37:03,616 --> 00:37:04,640
That's great
637
00:37:05,920 --> 00:37:06,432
Ok
638
00:37:08,480 --> 00:37:11,040
So he's touching walls and his right
639
00:37:11,808 --> 00:37:16,928
And so now we can go ahead and just set the direction to equal -1
640
00:37:18,464 --> 00:37:20,000
Australia see what happens
641
00:37:22,816 --> 00:37:25,888
It looks like it's behaving in a way that we don't want
642
00:37:26,656 --> 00:37:30,240
Let's see what's wrong here looks like I used
643
00:37:30,496 --> 00:37:35,360
The wrong raycast so he needs to be right wall raycast hit
644
00:37:35,616 --> 00:37:41,760
And also in the debug here right ball raycast hit that
645
00:37:42,016 --> 00:37:46,624
Relations you smarter than me
646
00:37:46,880 --> 00:37:48,160
Artist need
647
00:37:48,672 --> 00:37:49,696
Semicolon
648
00:37:50,976 --> 00:37:52,512
And now hopefully
649
00:37:53,536 --> 00:37:54,560
What's the what's going on
650
00:37:56,864 --> 00:37:57,632
Play
651
00:38:02,240 --> 00:38:03,776
Ok so
652
00:38:04,288 --> 00:38:05,568
We have a wonderful
653
00:38:05,824 --> 00:38:07,104
Here
654
00:38:07,616 --> 00:38:08,384
And
655
00:38:08,896 --> 00:38:12,224
Langley Priory part of it again congratulations you smarter than me
656
00:38:12,992 --> 00:38:14,272
And honestly guys
657
00:38:14,528 --> 00:38:20,672
I need this is gonna happen and I wanted to show you how we can fix stuff like this so you never said a raycast is
658
00:38:22,208 --> 00:38:24,768
Omitted from the centre of our enemy here right
659
00:38:25,280 --> 00:38:27,072
That means that it's touching
660
00:38:27,584 --> 00:38:29,376
The anime so touching itself
661
00:38:29,888 --> 00:38:36,032
We really don't want that so the way that we can solve this is actually through a thing called
662
00:38:36,288 --> 00:38:42,432
Ok now in this project there are two different kinds of layers ok in my hair
663
00:38:42,688 --> 00:38:44,736
We just created players here
664
00:38:44,992 --> 00:38:51,136
Anita parallax layers don't worry about these kinds of basically away for me and you
665
00:38:51,392 --> 00:38:55,744
Very is parallax layers ok that's one kind of layer
666
00:38:56,000 --> 00:39:02,144
The other kind of layer were going to talk about it over here some of you may have seen this word they're here
667
00:39:02,912 --> 00:39:09,056
We can actually create new layers ok new layer just go with me for
668
00:39:10,336 --> 00:39:12,896
Let's call this the enemy player
669
00:39:13,664 --> 00:39:18,272
Recording about layers we can actually have certain objects
670
00:39:18,784 --> 00:39:20,064
Better in a certain layer
671
00:39:21,088 --> 00:39:22,112
Ignore
672
00:39:22,624 --> 00:39:24,672
Other layers ok
673
00:39:25,440 --> 00:39:28,768
So we can actually set the layer 4anime.to
674
00:39:29,280 --> 00:39:30,048
Enemy
675
00:39:31,328 --> 00:39:32,096
And then
676
00:39:32,352 --> 00:39:33,120
What we can do
677
00:39:33,632 --> 00:39:35,936
Is we actually can go into the Script
678
00:39:36,960 --> 00:39:39,520
Until our raycast
679
00:39:40,544 --> 00:39:41,568
To ignore
680
00:39:42,080 --> 00:39:43,360
Specifically
681
00:39:44,128 --> 00:39:46,176
So we can do that is just go comma
682
00:39:46,944 --> 00:39:47,968
Recast
683
00:39:48,480 --> 00:39:49,504
Layer mask
684
00:39:49,760 --> 00:39:52,064
Set variable doesn't exist yet
685
00:39:52,832 --> 00:39:54,368
We got a creative up here
686
00:39:54,624 --> 00:39:58,464
In so we'll see realise this the silliest serializefield
687
00:39:58,976 --> 00:40:00,768
It's going to be a private
688
00:40:01,536 --> 00:40:02,816
Layer mask
689
00:40:03,584 --> 00:40:06,656
Is going to be called raycast layer mask
690
00:40:07,936 --> 00:40:08,448
So
691
00:40:08,960 --> 00:40:15,104
All this means we've added this new parameter here and it's just a parameter for the physics2d raycast
692
00:40:15,616 --> 00:40:18,432
It allows for us to have a layer mask ok
693
00:40:19,200 --> 00:40:20,992
Does go back into unity
694
00:40:21,248 --> 00:40:23,040
When you see it appear here
695
00:40:24,832 --> 00:40:25,600
There is
696
00:40:26,368 --> 00:40:29,696
And that start with everything ok
697
00:40:30,208 --> 00:40:35,584
We want everything to be selected here we want this layermask to interact with everything ok
698
00:40:36,352 --> 00:40:42,496
Well we definitely want it to ignore objects that are on the ignore raycast layer and that includes the polygon
699
00:40:42,752 --> 00:40:43,520
Camera
700
00:40:43,776 --> 00:40:47,616
Collide remember we had this year and we said it to ignore raycast
701
00:40:47,872 --> 00:40:50,432
So we definitely want our raycast to ignore that
702
00:40:52,992 --> 00:40:56,064
And we also wanted to ignore itself the enemy
703
00:40:57,856 --> 00:40:58,880
Play here
704
00:41:01,952 --> 00:41:04,256
So now it's not going to touch itself
705
00:41:05,280 --> 00:41:10,400
We definitely don't like our enemies touching themselves ok so
706
00:41:10,912 --> 00:41:15,264
It's just go ahead and copy all of this and paste it
707
00:41:15,520 --> 00:41:17,824
Where to check for a left wall ok
708
00:41:18,080 --> 00:41:20,896
So there's gonna be left wall brick acid
709
00:41:21,664 --> 00:41:22,944
Just going to put that
710
00:41:23,712 --> 00:41:29,856
In here and here and also going to
711
00:41:30,112 --> 00:41:31,648
Vector to that left
712
00:41:32,672 --> 00:41:38,816
And trying to think of anything else you're a doctor that left in order
713
00:41:40,352 --> 00:41:41,888
I think that's everything guys
714
00:41:43,168 --> 00:41:44,448
The colour is
715
00:41:45,216 --> 00:41:47,264
Different colour purple
716
00:41:47,520 --> 00:41:48,288
Is there a purple
717
00:41:48,800 --> 00:41:54,431
Purple magenta
718
00:41:54,943 --> 00:41:56,479
Take a look
719
00:41:56,735 --> 00:41:57,759
One final thing
720
00:41:58,015 --> 00:41:59,551
I'm touching a wall on my
721
00:42:00,063 --> 00:42:02,111
Left here we go
722
00:42:02,623 --> 00:42:03,391
Supply
723
00:42:05,183 --> 00:42:06,975
Is touching a woman's right
724
00:42:07,487 --> 00:42:11,071
Now if we change his speed to mega to
725
00:42:12,607 --> 00:42:14,911
I'm touching a wall on my left
726
00:42:15,423 --> 00:42:16,191
Awesome
727
00:42:16,959 --> 00:42:17,983
Are we going to hear it
728
00:42:18,239 --> 00:42:22,591
Remove the door and just change the direction to be well if you touch a right wall
729
00:42:22,847 --> 00:42:24,127
Siri -1
730
00:42:24,639 --> 00:42:28,223
And then if you're such as a level the direction is going to be
731
00:42:28,479 --> 00:42:29,759
Positive one
732
00:42:35,903 --> 00:42:36,671
Perfect
733
00:42:36,927 --> 00:42:37,951
Now he's stuck
734
00:42:38,207 --> 00:42:41,023
Define throw him up here
735
00:42:41,279 --> 00:42:44,607
Great so we can't fall over ledges he also avoid
736
00:42:44,863 --> 00:42:45,631
Player
737
00:42:46,143 --> 00:42:48,959
I really want that because we want him to actually
738
00:42:49,727 --> 00:42:52,031
Put the player in engage with the player
739
00:42:52,287 --> 00:42:54,079
So why is he avoiding the player
740
00:42:54,591 --> 00:42:56,895
What is because he thinks the player is a wall
741
00:42:57,663 --> 00:43:01,247
That means we need to set the player to be ignored
742
00:43:01,503 --> 00:43:02,527
By that recast
743
00:43:03,295 --> 00:43:09,439
So is there anything on our list here that allows us to ignore the player while the player is on the default
744
00:43:09,695 --> 00:43:11,487
I just show you really quick
745
00:43:12,255 --> 00:43:18,399
The players on the default layer in a guys I cannot stress this enough these layers here
746
00:43:18,655 --> 00:43:19,679
Have nothing to do
747
00:43:20,447 --> 00:43:22,239
With these layers here ok
748
00:43:22,751 --> 00:43:28,895
These layers are just a way for us to have parallax layers and we can name these honestly whatever we want we can call
749
00:43:29,151 --> 00:43:35,039
Parallax one right so that's really what these layers here is it just game objects
750
00:43:35,295 --> 00:43:36,319
Where is
751
00:43:37,343 --> 00:43:38,623
Recite the player here
752
00:43:39,903 --> 00:43:41,951
This layer in the inspector
753
00:43:42,207 --> 00:43:48,351
Basically helps us ignore other game objects that are on that layer so just keep that in mind
754
00:43:48,607 --> 00:43:49,887
Two kinds of layers here
755
00:43:52,703 --> 00:43:53,215
So
756
00:43:54,239 --> 00:43:57,311
Curly the player is set to the 0
757
00:43:57,567 --> 00:43:59,615
Maya which is called the default layer
758
00:44:00,639 --> 00:44:03,967
What alarmed gameobjects are actually on the default layer as well
759
00:44:05,503 --> 00:44:07,039
So we really don't want
760
00:44:07,551 --> 00:44:09,343
The enemies re cast
761
00:44:09,599 --> 00:44:10,879
To just ignore
762
00:44:11,647 --> 00:44:12,927
The default are doing
763
00:44:14,207 --> 00:44:15,999
So what we can do is actually just
764
00:44:16,511 --> 00:44:17,791
Create a new layer
765
00:44:18,815 --> 00:44:20,095
Call it player
766
00:44:21,375 --> 00:44:22,655
And then set the layer
767
00:44:22,911 --> 00:44:23,935
For the player
768
00:44:24,191 --> 00:44:24,959
Player
769
00:44:26,239 --> 00:44:29,055
So now the player is on the layer player
770
00:44:29,823 --> 00:44:32,127
It's all we got to do is go to enemy here
771
00:44:32,895 --> 00:44:34,175
Just make sure
772
00:44:34,687 --> 00:44:36,735
He's hacking interact with himself
773
00:44:37,247 --> 00:44:38,783
Is that alright with the player
774
00:44:39,551 --> 00:44:41,855
Worthy ignore raycast layer
775
00:44:42,367 --> 00:44:43,391
Play
776
00:44:45,439 --> 00:44:46,719
So far so good
777
00:44:50,815 --> 00:44:51,839
Dragon appear
778
00:44:52,351 --> 00:44:55,935
So he now will chase after the player
779
00:44:57,983 --> 00:45:00,799
Alright in hit the player and her two player that's great
780
00:45:01,823 --> 00:45:02,591
Alright
781
00:45:02,847 --> 00:45:06,175
So now we have our enemy able to pretty much
782
00:45:07,455 --> 00:45:08,735
Ignore ledges
783
00:45:09,247 --> 00:45:10,271
And also
784
00:45:10,527 --> 00:45:16,671
Eleanor was now case I just made a break so far
785
00:45:16,927 --> 00:45:22,815
He is looking pretty good alright guys so not we have the enemy able to sort of Patrol around the level
786
00:45:23,327 --> 00:45:26,399
We now need a race and code that will actually hurt the player
787
00:45:26,911 --> 00:45:30,751
So let's chapita enemy script in what's writing pseudocode
788
00:45:31,775 --> 00:45:33,823
Let's see hear something like
789
00:45:35,359 --> 00:45:36,895
If I collide
790
00:45:37,663 --> 00:45:40,479
With the player
791
00:45:41,247 --> 00:45:46,367
Supplier meaning his health is going to
792
00:45:46,879 --> 00:45:49,439
Decrease
793
00:45:49,951 --> 00:45:54,047
And then we also need to update the UI
794
00:45:55,327 --> 00:45:57,631
Ok so how is actually do this
795
00:45:57,887 --> 00:46:04,031
Well if we go to a collectible script just for reference memory have this ontriggerenter2d function here we also
796
00:46:04,287 --> 00:46:06,079
Is there any Gate as well
797
00:46:06,335 --> 00:46:12,479
Well we can't really use that on the enemy because the enemy isn't a trigger is it
798
00:46:12,735 --> 00:46:13,503
A Collider
799
00:46:14,271 --> 00:46:15,039
Take a look
800
00:46:15,807 --> 00:46:21,951
Preselector enemy here you can see that the capsule Collider is Trigger a set of false memory a trigger is meant to
801
00:46:22,207 --> 00:46:28,351
Passed through the enemy is a solid entity right so we need to use a different function
802
00:46:28,607 --> 00:46:30,399
It's very very similar
803
00:46:30,655 --> 00:46:34,495
To the ontriggerenter function used in r collectible script
804
00:46:34,751 --> 00:46:37,823
And also our Gate script into
805
00:46:38,079 --> 00:46:38,847
Chrome
806
00:46:39,103 --> 00:46:44,479
Images Google Unity on collision enter 2D
807
00:46:48,575 --> 00:46:54,719
So because we are blaming here we're just going to literally copy and paste this
808
00:46:54,975 --> 00:46:56,255
So let's see here
809
00:46:56,511 --> 00:47:02,655
That's great right there I just copy that oncollisionenter2d right
810
00:47:02,911 --> 00:47:04,447
Nails for us to check
811
00:47:04,959 --> 00:47:06,239
If we collided
812
00:47:06,495 --> 00:47:08,287
With something else ok
813
00:47:09,311 --> 00:47:11,871
So let's just go to your enemy scripture
814
00:47:12,127 --> 00:47:13,663
Studying
815
00:47:14,175 --> 00:47:16,735
Remove this debug here
816
00:47:17,247 --> 00:47:21,087
Are we going to do is your guys if you guys just smart enough to know this now
817
00:47:21,343 --> 00:47:23,391
If we consume in here and go if
818
00:47:24,159 --> 00:47:24,927
Call
819
00:47:25,951 --> 00:47:32,095
That's the very one name here in the collectible it's collision and as a collider2d variable type
820
00:47:33,119 --> 00:47:35,423
Enemy script a collision
821
00:47:35,679 --> 00:47:37,471
2D variable type
822
00:47:37,727 --> 00:47:38,495
Honestly
823
00:47:39,007 --> 00:47:44,639
I'm not a huge fan of the language because it's very similar verbiage so
824
00:47:44,895 --> 00:47:50,783
Oh no just have Google handy here alright so if call dart game object
825
00:47:51,295 --> 00:47:52,319
Equals
826
00:47:53,855 --> 00:47:56,415
Remember what we can use year the incidence
827
00:47:56,671 --> 00:47:57,695
Pattaya
828
00:47:58,207 --> 00:48:01,023
So if it equals the Instance of the player
829
00:48:02,047 --> 00:48:04,607
When are we just debug.log
830
00:48:05,887 --> 00:48:07,679
The player
831
00:48:08,959 --> 00:48:09,983
Semicolon
832
00:48:10,239 --> 00:48:11,263
Play they're out
833
00:48:11,519 --> 00:48:12,799
You're back in the universe here
834
00:48:14,335 --> 00:48:20,479
And let's see what's going on again guys
835
00:48:20,735 --> 00:48:26,879
In fact if you want to just buy them for now what do that
836
00:48:27,135 --> 00:48:33,279
For the course with making games
837
00:48:33,535 --> 00:48:35,583
There we go
838
00:48:35,839 --> 00:48:37,375
We hurt the player
839
00:48:37,631 --> 00:48:38,655
Perfect
840
00:48:39,167 --> 00:48:43,263
Ok so let's go ahead in decrease the players health
841
00:48:43,775 --> 00:48:47,103
Every time we get hurt so currently our house is it 50
842
00:48:47,615 --> 00:48:53,247
So let's just jump into a new player script to use dragon over to hear my clothes out the gate script in the collectible script
843
00:48:54,015 --> 00:48:55,807
So it's just simply do this
844
00:48:56,063 --> 00:48:56,831
New player
845
00:48:57,343 --> 00:48:58,623
The Instance
846
00:48:59,647 --> 00:49:00,671
Health
847
00:49:01,695 --> 00:49:03,231
- equals
848
00:49:05,023 --> 00:49:06,047
An end
849
00:49:06,303 --> 00:49:09,119
New player that instance
850
00:49:09,375 --> 00:49:10,655
Update UI
851
00:49:13,215 --> 00:49:15,519
Decrease the house by 1
852
00:49:15,775 --> 00:49:21,151
And then we're going to update that UI meaning the health bar is going to reflect the actual health
853
00:49:21,663 --> 00:49:23,455
Save it and see what happens
854
00:49:27,295 --> 00:49:29,087
Shrink down is a little bit there we go
855
00:49:29,855 --> 00:49:30,623
Jealous
856
00:49:31,135 --> 00:49:32,927
Keep an eye on the Health over here
857
00:49:33,183 --> 00:49:33,951
The player
858
00:49:34,719 --> 00:49:35,743
And
859
00:49:36,255 --> 00:49:38,559
Right there we go
860
00:49:38,815 --> 00:49:40,351
Are we getting hurt pretty good here
861
00:49:41,887 --> 00:49:42,655
Awesome
862
00:49:44,959 --> 00:49:45,727
Ok
863
00:49:45,983 --> 00:49:48,031
So that's hurting us a lot actually
864
00:49:48,799 --> 00:49:50,335
Exactly what we white
865
00:49:51,103 --> 00:49:57,247
Angel far is also updating and it's perfect keep an eye on it we could that slowly shrinking down
866
00:49:58,015 --> 00:50:00,575
Something we can do here is actually
867
00:50:01,855 --> 00:50:03,903
What if you don't want to decrease by 1
868
00:50:04,159 --> 00:50:05,695
What is a decreased by
869
00:50:05,951 --> 00:50:07,999
A custom value so maybe
870
00:50:08,511 --> 00:50:09,791
Power
871
00:50:11,071 --> 00:50:14,655
A Better World is probably attack power ok
872
00:50:15,935 --> 00:50:18,751
The variable does not exist so we need to create it up here
873
00:50:20,287 --> 00:50:21,823
Just put it right here
874
00:50:22,591 --> 00:50:23,871
We're going to see realise it
875
00:50:26,431 --> 00:50:27,199
Private
876
00:50:29,247 --> 00:50:30,271
Where's my container joke
877
00:50:30,783 --> 00:50:36,927
Ninja makes more sense when I going to have like 2.5 being the Ripper I think maybe a value of 10 is
878
00:50:37,183 --> 00:50:37,695
Better option
879
00:50:37,951 --> 00:50:38,975
Integer
880
00:50:39,487 --> 00:50:40,767
Attack
881
00:50:41,023 --> 00:50:41,791
Power
882
00:50:42,815 --> 00:50:46,399
And will speak to the default of 10 that we can definitely change it if you want
883
00:50:46,655 --> 00:50:48,191
Unity here
884
00:50:49,983 --> 00:50:52,287
My Selector enemy here
885
00:50:52,799 --> 00:50:55,359
Now we can actually tweet the attack power
886
00:50:55,615 --> 00:51:00,223
So if we wanted to have let's see here one enemy that attacks a value of 10
887
00:51:00,735 --> 00:51:02,527
In another anime that attacks
888
00:51:02,783 --> 00:51:05,343
Add value of I don't know
889
00:51:05,855 --> 00:51:10,719
50 we can make this with Michael is scary alright maybe bacon
890
00:51:10,975 --> 00:51:11,999
Vibrant
891
00:51:13,023 --> 00:51:14,559
Louis Marlow
892
00:51:15,071 --> 00:51:17,375
Big and maybe make it too
893
00:51:17,887 --> 00:51:23,775
Big enemy type here now that can hurt the player a lot more
894
00:51:24,287 --> 00:51:25,823
Play
895
00:51:26,335 --> 00:51:27,359
What's a player
896
00:51:32,991 --> 00:51:39,135
Little buggy bear the Ricoh system isn't really meant for these Gia
897
00:51:39,391 --> 00:51:45,535
Enemy types but you get the point you're so if I get her here so I went down by 10
898
00:51:45,791 --> 00:51:50,399
Went down by 50 right-hand dead now
899
00:51:51,423 --> 00:51:53,471
Enemies are now attacking the player
900
00:51:53,983 --> 00:51:55,775
Really simple really straightforward
901
00:51:56,031 --> 00:51:58,847
They can be great have an indication
902
00:51:59,103 --> 00:52:00,127
That we're getting hurt
903
00:52:00,639 --> 00:52:03,967
We're going to be doing that when we actually create animations
904
00:52:04,223 --> 00:52:05,247
For this game
905
00:52:05,503 --> 00:52:09,343
And that's going to be during the animation portion of this tutorial
906
00:52:09,599 --> 00:52:15,743
Just yet
65476
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.