Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,256 --> 00:00:02,816
A problem that we have is that
2
00:00:03,072 --> 00:00:09,216
Our enemies in our game will spawn outside of the walls which obviously is not
3
00:00:09,472 --> 00:00:11,008
Deal because then well
4
00:00:12,288 --> 00:00:13,824
And this
5
00:00:14,080 --> 00:00:14,592
Is wrong
6
00:00:14,848 --> 00:00:15,360
So
7
00:00:16,896 --> 00:00:19,456
And luckily I think the fix is going to be
8
00:00:19,712 --> 00:00:20,736
Free simple
9
00:00:20,992 --> 00:00:26,368
So let's go to our enemy manager and open up that script
10
00:00:26,624 --> 00:00:28,160
And are my manager
11
00:00:28,416 --> 00:00:29,952
Is responsible for
12
00:00:30,208 --> 00:00:30,976
Spawning
13
00:00:31,232 --> 00:00:31,744
Anna
14
00:00:32,256 --> 00:00:38,400
Now what we are doing to determine response position of the enemy is there a centrally just getting a randomly
15
00:00:38,656 --> 00:00:39,936
Updated unit vector
16
00:00:40,192 --> 00:00:43,008
Then we are multiplying that by the spawn radius of an atom
17
00:00:43,264 --> 00:00:44,032
The player position
18
00:00:44,288 --> 00:00:46,336
Of course the problem being that
19
00:00:46,592 --> 00:00:50,176
If we are pointing in Direction that goes past a wall
20
00:00:50,432 --> 00:00:52,480
Then the enemy will spy outside the war
21
00:00:53,760 --> 00:00:55,040
There is a fix that
22
00:00:55,296 --> 00:00:58,112
I think is going to work really well on the situation
23
00:00:58,368 --> 00:01:00,781
And is essentially that we're going to do a raycast
24
00:01:00,783 --> 00:01:03,131
Subtitled by
online-courses.club
We compress knowledge for you!
25
00:01:03,132 --> 00:01:02,208
Determine
26
00:01:02,464 --> 00:01:03,232
If this one
27
00:01:03,488 --> 00:01:04,000
Is valid
28
00:01:04,256 --> 00:01:08,608
It's going to be a little bit tricky because we still want the enemies to spawn off screen
29
00:01:09,120 --> 00:01:12,192
So we need to figure out what we gonna do when we
30
00:01:12,448 --> 00:01:13,216
Counter
31
00:01:13,728 --> 00:01:14,240
Collision
32
00:01:14,496 --> 00:01:17,568
And Eric as essentially online along
33
00:01:17,824 --> 00:01:18,592
You check for
34
00:01:18,848 --> 00:01:19,360
Collisions
35
00:01:19,872 --> 00:01:23,200
So we can pick a start position in end position
36
00:01:23,456 --> 00:01:24,224
And we can
37
00:01:24,480 --> 00:01:25,248
Godot
38
00:01:25,504 --> 00:01:27,808
Is there any terrain collision
39
00:01:28,064 --> 00:01:30,112
On this line between them
40
00:01:30,368 --> 00:01:30,880
2 points
41
00:01:31,136 --> 00:01:32,160
If there is a collision
42
00:01:32,672 --> 00:01:35,744
Then what we're going to do is we're going to change the direction
43
00:01:36,256 --> 00:01:37,792
That the enemy is going to spawn
44
00:01:38,048 --> 00:01:40,608
And what we'll do is we'll check it up to 4 time
45
00:01:41,632 --> 00:01:42,400
Rotate
46
00:01:42,656 --> 00:01:44,960
The direction by 90 degrees
47
00:01:45,216 --> 00:01:47,520
Every time until we find an empty space
48
00:01:47,776 --> 00:01:48,544
If that doesn't
49
00:01:48,800 --> 00:01:52,384
Seem super clear yet don't worry it should be a little bit more clear as we get into
50
00:01:52,640 --> 00:01:53,152
So
51
00:01:53,408 --> 00:01:58,528
One thing I'm going to do is I'm going to create a new function that is designed solely for the purpose
52
00:01:58,784 --> 00:02:00,320
Getting a spawn position
53
00:02:00,832 --> 00:02:01,856
Someone who creates a new
54
00:02:02,112 --> 00:02:05,440
Function below the ready method and I'm going to call it
55
00:02:05,696 --> 00:02:06,208
Get
56
00:02:06,464 --> 00:02:06,976
Spawn
57
00:02:07,488 --> 00:02:08,000
Position
58
00:02:10,048 --> 00:02:12,864
And what I'm going to do is I'm going to
59
00:02:13,376 --> 00:02:15,168
Grab this line here
60
00:02:15,424 --> 00:02:16,960
Is this tree line swear
61
00:02:17,216 --> 00:02:17,984
Getting the player
62
00:02:18,496 --> 00:02:20,288
I'm going to copy and paste that up here
63
00:02:20,544 --> 00:02:24,128
Now instead of returning just nothing out of this function
64
00:02:24,384 --> 00:02:25,920
All you want to do is we want to return
65
00:02:26,176 --> 00:02:26,688
Instead
66
00:02:26,944 --> 00:02:28,736
Vectra 2.0
67
00:02:28,992 --> 00:02:31,296
So we gonna play position is going to return
68
00:02:32,832 --> 00:02:33,856
As the position
69
00:02:34,112 --> 00:02:36,160
Should be fine because
70
00:02:36,416 --> 00:02:40,512
We are returning early out of this on timer timer anyway if the player doesn't
71
00:02:40,768 --> 00:02:44,352
So theoretically we shouldn't even get to this point but it doesn't hurt to be ale
72
00:02:45,376 --> 00:02:45,888
Ok
73
00:02:46,144 --> 00:02:46,656
So
74
00:02:46,912 --> 00:02:51,520
Next I'm going to take these two lines and on time or time out the random Direction
75
00:02:51,776 --> 00:02:52,800
In response
76
00:02:53,056 --> 00:02:54,592
I'm going to cut those out
77
00:02:55,104 --> 00:02:55,872
And pay stores
78
00:02:58,176 --> 00:03:02,272
And then in the on time or time out let's go ahead and just replace those lines
79
00:03:02,528 --> 00:03:03,552
We cut by doing
80
00:03:04,064 --> 00:03:09,440
We can replace this actually down here so on this earring line and my back and I what position is it going to sponsor edition
81
00:03:09,696 --> 00:03:12,000
Wishes change that sponsors is near to
82
00:03:12,512 --> 00:03:13,536
Get sponsored
83
00:03:13,792 --> 00:03:14,304
The weekend
84
00:03:14,560 --> 00:03:15,840
Call the function right there
85
00:03:16,096 --> 00:03:17,120
My
86
00:03:17,632 --> 00:03:18,400
And that should
87
00:03:18,656 --> 00:03:19,680
Work just
88
00:03:19,936 --> 00:03:20,448
Ok
89
00:03:20,960 --> 00:03:25,056
So up here if we want this to be functionally the same as what we had before
90
00:03:25,312 --> 00:03:26,848
We can go ahead and return
91
00:03:28,640 --> 00:03:29,920
Spawn underscore
92
00:03:30,176 --> 00:03:31,456
Position out of this funk
93
00:03:31,968 --> 00:03:33,248
So that's going to
94
00:03:33,760 --> 00:03:35,552
Essentially be functionally the same
95
00:03:35,808 --> 00:03:37,600
Where does going to return the position at so
96
00:03:37,856 --> 00:03:42,720
In this part of the function is where we went to actually manipulate the direction if it's not
97
00:03:42,976 --> 00:03:43,488
Appropriate
98
00:03:43,744 --> 00:03:45,536
Where can I want to do a reiki
99
00:03:45,792 --> 00:03:47,072
Check as a man
100
00:03:47,328 --> 00:03:49,632
Earlier in the where we can do that is we actually
101
00:03:49,888 --> 00:03:51,168
Query what is called
102
00:03:51,680 --> 00:03:52,448
The
103
00:03:52,704 --> 00:03:53,728
Space state
104
00:03:53,984 --> 00:03:56,032
An essentially that is the current
105
00:03:56,288 --> 00:03:58,848
8 of the physics objects in the game
106
00:03:59,104 --> 00:04:00,640
Against which we can
107
00:04:01,152 --> 00:04:02,944
Run various checks
108
00:04:03,712 --> 00:04:05,760
In the way that we can retrieve that is
109
00:04:06,016 --> 00:04:06,784
I'm going to write
110
00:04:07,296 --> 00:04:07,808
Get
111
00:04:08,064 --> 00:04:08,576
3
112
00:04:08,832 --> 00:04:09,344
Start
113
00:04:09,600 --> 00:04:10,112
Route
114
00:04:10,880 --> 00:04:11,904
Start work
115
00:04:12,160 --> 00:04:13,440
Underscore 2D
116
00:04:14,976 --> 00:04:15,744
Space
117
00:04:16,256 --> 00:04:20,863
And this is going to be our 2D physics Direct space state is what it's called
118
00:04:21,119 --> 00:04:22,399
And we can do is we can actually
119
00:04:22,655 --> 00:04:24,703
Intersect Ray against
120
00:04:25,471 --> 00:04:25,983
State
121
00:04:27,263 --> 00:04:28,799
And what is intersex
122
00:04:29,055 --> 00:04:33,663
Require as argument while we can open up a documentation and look for intersect
123
00:04:34,175 --> 00:04:35,455
Underscore Ray
124
00:04:35,711 --> 00:04:37,503
Find the definition Henry
125
00:04:37,759 --> 00:04:38,271
Physics
126
00:04:38,527 --> 00:04:39,039
Nextbase
127
00:04:39,551 --> 00:04:41,343
Open that
128
00:04:41,599 --> 00:04:44,159
And we can see that this takes a physics
129
00:04:44,415 --> 00:04:44,927
Aquarium
130
00:04:45,695 --> 00:04:46,207
2D
131
00:04:46,719 --> 00:04:47,743
So let's go and collect
132
00:04:48,255 --> 00:04:50,559
This is an object that we need to
133
00:04:50,815 --> 00:04:52,863
And we need to
134
00:04:53,119 --> 00:04:54,143
Created with
135
00:04:54,399 --> 00:04:55,167
Argument list
136
00:04:55,423 --> 00:04:57,471
Here now this is going a little bit off
137
00:04:57,727 --> 00:04:58,495
My screen here
138
00:04:58,751 --> 00:05:01,311
So we're going to have a from which is affected
139
00:05:01,823 --> 00:05:03,103
A tool which is another
140
00:05:03,871 --> 00:05:05,919
And then a collision mask which is
141
00:05:06,175 --> 00:05:10,783
The same exact thing that we see in our editor over changing the layer and
142
00:05:11,295 --> 00:05:12,831
We are going to be mostly using
143
00:05:13,087 --> 00:05:13,855
Is first three
144
00:05:14,623 --> 00:05:16,671
So let's go back to my manager
145
00:05:17,695 --> 00:05:18,975
Let's just
146
00:05:19,231 --> 00:05:20,767
Above this line
147
00:05:21,279 --> 00:05:22,559
Create a new variable called
148
00:05:23,839 --> 00:05:24,351
Query
149
00:05:24,863 --> 00:05:25,375
Perimeter
150
00:05:26,911 --> 00:05:28,447
I'm going to say physics
151
00:05:28,959 --> 00:05:29,471
Ray
152
00:05:31,007 --> 00:05:33,567
Studio.com cos that's the method
153
00:05:33,823 --> 00:05:34,847
That we were just
154
00:05:35,871 --> 00:05:39,199
In our front position is going to be player.dat global position
155
00:05:39,455 --> 00:05:40,735
Set a start position
156
00:05:40,991 --> 00:05:43,295
And the position is going to be this random
157
00:05:43,551 --> 00:05:44,575
Sometimes spawn rate
158
00:05:45,087 --> 00:05:47,135
So we actually had the stored as sponsors
159
00:05:48,159 --> 00:05:49,695
So I'm going to do if I'm actually just go
160
00:05:49,951 --> 00:05:50,719
Did you copy these
161
00:05:50,975 --> 00:05:52,767
Or rather cut these lines
162
00:05:53,023 --> 00:05:53,791
That we just
163
00:05:54,047 --> 00:05:55,839
I'm going to go ahead and move those on
164
00:05:56,863 --> 00:05:57,375
Ok
165
00:05:57,631 --> 00:05:59,167
So you're cold you look like this
166
00:05:59,423 --> 00:06:02,495
And for the second argument here we're going to pass in spawn position
167
00:06:02,751 --> 00:06:04,287
And then our
168
00:06:04,543 --> 00:06:05,311
Leia
169
00:06:05,567 --> 00:06:09,663
Or our mask ready that we want to check against it's going to be the same so if I open up
170
00:06:09,919 --> 00:06:10,943
Play adjust reel
171
00:06:11,455 --> 00:06:13,503
We have in the inspector here
172
00:06:13,759 --> 00:06:15,295
Nicola and occlusion
173
00:06:16,831 --> 00:06:18,367
You can actually hover over
174
00:06:18,623 --> 00:06:19,903
The mask and I will tell you
175
00:06:20,159 --> 00:06:20,671
B
176
00:06:21,183 --> 00:06:21,951
The thing about
177
00:06:22,207 --> 00:06:23,231
Doing the rear car
178
00:06:23,487 --> 00:06:23,999
Collision
179
00:06:24,255 --> 00:06:26,303
Code is actually need to pass in
180
00:06:26,559 --> 00:06:28,095
The bit value already
181
00:06:28,351 --> 00:06:30,655
Int value that corresponds to the b
182
00:06:31,679 --> 00:06:32,191
The mask
183
00:06:32,703 --> 00:06:36,543
So b 0 as a value of 1 which you can see
184
00:06:36,799 --> 00:06:37,823
In the toilet
185
00:06:38,079 --> 00:06:39,871
When you hover over the terrain Valley
186
00:06:40,127 --> 00:06:41,663
That's the value that were going
187
00:06:42,431 --> 00:06:43,711
So we can write
188
00:06:43,967 --> 00:06:44,735
One in there
189
00:06:44,991 --> 00:06:46,271
That's going to collide with
190
00:06:46,527 --> 00:06:48,319
The train Leia
191
00:06:48,575 --> 00:06:50,367
Now another thing that you can do is
192
00:06:50,623 --> 00:06:51,903
You can actually use
193
00:06:52,159 --> 00:06:52,671
Shift
194
00:06:53,183 --> 00:06:53,695
You want
195
00:06:53,951 --> 00:06:54,463
So
196
00:06:54,719 --> 00:06:56,255
I can say one
197
00:06:56,511 --> 00:06:57,023
Shift
198
00:06:57,279 --> 00:06:58,559
Over 0
199
00:06:59,071 --> 00:07:01,887
If you're not familiar with bitwise operators
200
00:07:02,143 --> 00:07:03,935
Essentially this is just saying
201
00:07:04,191 --> 00:07:04,703
Take
202
00:07:04,959 --> 00:07:05,727
1
203
00:07:05,983 --> 00:07:09,823
Which under the hood has a bit value of 1
204
00:07:10,079 --> 00:07:12,895
And shift that bit over
205
00:07:13,151 --> 00:07:13,919
This many people
206
00:07:14,431 --> 00:07:20,063
And the reason is that useful in terms of the terrain is let's say that I had my terrain
207
00:07:21,087 --> 00:07:21,599
Set
208
00:07:21,855 --> 00:07:22,623
24
209
00:07:23,135 --> 00:07:25,183
Right let's do something little bit
210
00:07:25,439 --> 00:07:25,951
Differ
211
00:07:26,463 --> 00:07:27,231
Let's say 2
212
00:07:27,999 --> 00:07:29,791
So if my lair was too
213
00:07:30,047 --> 00:07:30,559
I would
214
00:07:30,815 --> 00:07:32,863
Type out manually this value
215
00:07:33,375 --> 00:07:36,191
524288
216
00:07:37,471 --> 00:07:38,239
That's not
217
00:07:38,751 --> 00:07:39,519
Really that
218
00:07:39,775 --> 00:07:40,799
Comfortable to wear
219
00:07:41,055 --> 00:07:42,079
Encode Manor
220
00:07:42,591 --> 00:07:44,639
I could do if I could take one
221
00:07:44,895 --> 00:07:45,919
And since this is
222
00:07:46,175 --> 00:07:49,247
B 19 I could shift it 19 bit
223
00:07:49,503 --> 00:07:50,271
And that will
224
00:07:50,527 --> 00:07:51,039
Create
225
00:07:51,295 --> 00:07:52,319
That same Val
226
00:07:52,831 --> 00:07:55,391
So if I had my mask set to let one
227
00:07:55,903 --> 00:07:57,439
I could simply do one
228
00:07:57,695 --> 00:07:59,743
Bit shifted 19 plate
229
00:08:00,255 --> 00:08:02,815
And that you can easily sort of reference
230
00:08:03,071 --> 00:08:04,095
Your mask
231
00:08:04,351 --> 00:08:04,863
Code
232
00:08:05,119 --> 00:08:07,167
With bitwise operators but fortunate
233
00:08:07,423 --> 00:08:09,215
We're simply using
234
00:08:09,471 --> 00:08:10,751
The first bit
235
00:08:11,007 --> 00:08:13,311
As our terrain layer so it
236
00:08:14,847 --> 00:08:18,943
If that's not superclear I'm encouraged you to go ahead
237
00:08:19,199 --> 00:08:19,967
And do some research
238
00:08:20,223 --> 00:08:21,247
Bitwise operator
239
00:08:21,503 --> 00:08:23,039
It's a very handy tool to know
240
00:08:23,295 --> 00:08:25,087
But we'll dropped
241
00:08:25,599 --> 00:08:26,111
Cancer
242
00:08:26,367 --> 00:08:28,671
Therefore now and continue on with our
243
00:08:28,927 --> 00:08:29,951
Ray intercept
244
00:08:30,463 --> 00:08:32,255
So now that we've got are query parameters
245
00:08:32,511 --> 00:08:33,023
Constructed
246
00:08:33,279 --> 00:08:34,559
We can pass those in
247
00:08:34,815 --> 00:08:35,327
The Intern
248
00:08:37,119 --> 00:08:38,399
And we want to store the
249
00:08:38,655 --> 00:08:39,679
So we're going to say virus
250
00:08:40,703 --> 00:08:41,471
Get 3
251
00:08:41,983 --> 00:08:42,495
All that
252
00:08:43,007 --> 00:08:47,103
Another question is what happens if we don't have a recall
253
00:08:47,615 --> 00:08:50,943
If you don't have a rear collision what will happen is result will be now
254
00:08:51,199 --> 00:08:52,479
So we can see if result is
255
00:08:53,503 --> 00:08:55,807
Then that means I just read a comment
256
00:08:56,063 --> 00:08:56,575
Pound
257
00:08:56,831 --> 00:08:57,343
We
258
00:08:57,599 --> 00:08:58,367
Arkley
259
00:08:59,135 --> 00:08:59,647
Else
260
00:09:00,671 --> 00:09:01,951
We have a car
261
00:09:03,743 --> 00:09:05,791
I'm going to write pass in here
262
00:09:06,303 --> 00:09:06,815
This is not
263
00:09:07,071 --> 00:09:07,583
Complaining
264
00:09:08,607 --> 00:09:11,423
That's just a quick of gdscript you've seen as use passe
265
00:09:11,679 --> 00:09:15,007
The Times basically every block of indentation
266
00:09:15,263 --> 00:09:16,031
Need to have
267
00:09:16,287 --> 00:09:17,311
Some sort
268
00:09:17,823 --> 00:09:22,175
Statement or a line of code and passes just basically a placeholder that says
269
00:09:22,687 --> 00:09:24,223
We are doing anything here yet
270
00:09:24,479 --> 00:09:26,271
But we do want to maintain
271
00:09:26,527 --> 00:09:27,039
The inde
272
00:09:27,807 --> 00:09:29,343
We want to maintain the Blacks
273
00:09:29,599 --> 00:09:31,391
Ok so if I was articles
274
00:09:31,647 --> 00:09:34,207
Let's do this just for testing purpose
275
00:09:34,463 --> 00:09:37,279
If the result is no we're going to go ahead and
276
00:09:37,535 --> 00:09:38,303
Return
277
00:09:38,559 --> 00:09:40,095
Spawn underscore position
278
00:09:40,607 --> 00:09:44,959
And if it's not know which is return the player that the whole position this is not
279
00:09:45,983 --> 00:09:48,031
This is not the final behaviour that we're going to watch
280
00:09:48,799 --> 00:09:50,079
Can you remove the return
281
00:09:50,335 --> 00:09:51,103
At the end here
282
00:09:51,871 --> 00:09:58,015
Is the data final functionality that we want but this is going to make it really clear when there was a train collision because the answer is going to
283
00:09:58,271 --> 00:09:59,039
Ride on top of the player
284
00:09:59,295 --> 00:10:01,228
So let's just run this to make sure that we've done everything correct
285
00:10:01,229 --> 00:10:03,400
Subtitled by
online-courses.club
We compress knowledge for you!
286
00:10:03,401 --> 00:10:05,695
And you can see that already got an anime couple of animals that just spawn on top
287
00:10:06,463 --> 00:10:09,023
Tyres always returning a collision in why is that
288
00:10:09,279 --> 00:10:10,303
That's because
289
00:10:10,559 --> 00:10:13,375
If you read the documentation for intersect you can see that
290
00:10:13,631 --> 00:10:15,935
It says at the end if the radar not intersect
291
00:10:16,191 --> 00:10:17,215
Empty
292
00:10:18,495 --> 00:10:21,055
So this is why reading the documentation is really important
293
00:10:21,311 --> 00:10:23,871
I made the assumption that it would return
294
00:10:24,127 --> 00:10:25,663
Noel if the result
295
00:10:25,919 --> 00:10:26,943
Did not return
296
00:10:27,199 --> 00:10:27,711
Collision
297
00:10:27,967 --> 00:10:28,991
But that's not actually true
298
00:10:29,247 --> 00:10:29,759
Return
299
00:10:30,271 --> 00:10:31,039
Auntie dictionary
300
00:10:31,295 --> 00:10:35,135
Different than no write an empty dictionary actually nom
301
00:10:35,391 --> 00:10:36,415
It just doesn't have anything
302
00:10:36,671 --> 00:10:38,975
We need to do a slightly different check which is a
303
00:10:39,231 --> 00:10:41,535
Result.is underscore
304
00:10:42,047 --> 00:10:44,607
So this is the way that you can check if a dictionary has
305
00:10:44,863 --> 00:10:45,375
Cheese
306
00:10:45,631 --> 00:10:46,655
And
307
00:10:47,167 --> 00:10:47,935
That means letters
308
00:10:48,191 --> 00:10:52,287
North no collision and we can transport position so let's run again
309
00:10:52,543 --> 00:10:55,359
We can see now that hopefully some enemies are going to
310
00:10:55,615 --> 00:10:56,895
Spawning outside of the
311
00:10:57,151 --> 00:11:00,223
Game window and then if I get closer to a wall
312
00:11:00,479 --> 00:11:02,015
You can see now all of a sudden
313
00:11:02,527 --> 00:11:03,807
Enemy spawning on top
314
00:11:04,319 --> 00:11:06,367
As soon as I move into the middle of the screen
315
00:11:06,623 --> 00:11:10,463
That should no longer be happening because we are far enough away from all the wall
316
00:11:11,231 --> 00:11:12,767
So what are we going to do about
317
00:11:15,583 --> 00:11:21,727
In the first part of this lesson that we're going to do if we encounter a collision is a basically just going to rotate
318
00:11:21,983 --> 00:11:24,287
The direction that were looking at
319
00:11:24,543 --> 00:11:26,591
Or that we're looking to spawn the enemy
320
00:11:26,847 --> 00:11:28,895
Rotated by 90 degrees
321
00:11:29,407 --> 00:11:30,943
Sofa demonstration purposes
322
00:11:31,199 --> 00:11:33,247
Here is a corner of my map
323
00:11:33,759 --> 00:11:36,319
Right and then let's say that here is my Play
324
00:11:36,575 --> 00:11:38,879
If I'm choosing to spawn an enemy
325
00:11:39,391 --> 00:11:39,903
In
326
00:11:40,159 --> 00:11:40,927
Let's say
327
00:11:41,183 --> 00:11:42,207
Distraction
328
00:11:42,463 --> 00:11:43,999
And that ends up at the college
329
00:11:44,511 --> 00:11:45,023
If I
330
00:11:45,279 --> 00:11:47,071
Rotated by 9 degrees
331
00:11:47,327 --> 00:11:49,375
It's going to end up looking like this
332
00:11:50,911 --> 00:11:56,031
But I can rotate it by 90 degrees again and like this this is going to end up being empty space
333
00:11:56,543 --> 00:11:58,335
And this 9 degrees is
334
00:11:58,847 --> 00:11:59,359
Collision
335
00:11:59,615 --> 00:12:01,663
So the idea is because our room is a
336
00:12:01,919 --> 00:12:04,479
Tangle it should be the case that no matter what
337
00:12:04,735 --> 00:12:07,551
Corner or wall I end up going to
338
00:12:08,063 --> 00:12:09,087
Have two players here
339
00:12:09,343 --> 00:12:11,391
No matter what direction gets chosen
340
00:12:11,903 --> 00:12:12,927
Like something like that
341
00:12:13,183 --> 00:12:15,999
There will always be a 90 degree in cream
342
00:12:16,511 --> 00:12:18,303
That ends up being clear
343
00:12:18,559 --> 00:12:19,583
Of any colours
344
00:12:20,095 --> 00:12:21,119
I hope that makes sense
345
00:12:21,375 --> 00:12:22,655
Let's go ahead and implement that
346
00:12:23,935 --> 00:12:27,007
In the way that were going to do that is were going to use a 4
347
00:12:27,519 --> 00:12:28,543
Now what is a fool
348
00:12:28,799 --> 00:12:29,311
Afford
349
00:12:29,823 --> 00:12:31,359
Essentially Lazarus
350
00:12:31,615 --> 00:12:35,199
Iterate a specified number of times either over
351
00:12:35,455 --> 00:12:37,247
A specific number of
352
00:12:37,503 --> 00:12:40,575
Elements or a variable number of elements in a
353
00:12:40,831 --> 00:12:41,343
Play some Erasure
354
00:12:41,599 --> 00:12:43,135
And how are you this is
355
00:12:43,391 --> 00:12:44,671
So there are four
356
00:12:44,927 --> 00:12:45,695
90-degree
357
00:12:45,951 --> 00:12:47,231
Instruments that we can do it right
358
00:12:47,487 --> 00:12:50,303
There's the first direction in an iterator by 9
359
00:12:50,559 --> 00:12:51,583
And is rotated by 9
360
00:12:51,839 --> 00:12:53,119
Is 30 by 90 again
361
00:12:53,631 --> 00:12:55,423
So what we going to do is this a 4
362
00:12:55,679 --> 00:12:56,959
I in
363
00:12:57,471 --> 00:12:57,983
4
364
00:12:59,263 --> 00:13:01,055
Now the thing to note is
365
00:13:01,311 --> 00:13:03,615
This is going to increment I
366
00:13:04,127 --> 00:13:05,151
Going to start at zero
367
00:13:05,663 --> 00:13:08,991
When is gonna incremented by 1 every time before Luke and
368
00:13:09,503 --> 00:13:13,599
So when we first run code in this block where this passes
369
00:13:13,855 --> 00:13:15,135
I will be 0
370
00:13:15,391 --> 00:13:16,415
It will run again
371
00:13:16,671 --> 00:13:17,695
I will be one
372
00:13:17,951 --> 00:13:20,767
Anything to note is that this is not
373
00:13:21,023 --> 00:13:21,535
Include
374
00:13:22,047 --> 00:13:23,071
So4
375
00:13:23,327 --> 00:13:24,607
I will never be fair
376
00:13:25,119 --> 00:13:27,167
I will only be a maximum of
377
00:13:27,423 --> 00:13:27,935
3
378
00:13:28,191 --> 00:13:30,495
So that's just something to be aware of when you're using a form
379
00:13:30,751 --> 00:13:33,567
Like this and what we're gonna do is we're gonna move
380
00:13:34,079 --> 00:13:35,103
Holidays code
381
00:13:35,359 --> 00:13:36,895
Except for this
382
00:13:37,151 --> 00:13:37,663
Black
383
00:13:37,919 --> 00:13:38,687
Into
384
00:13:38,943 --> 00:13:41,503
That for loop and make sure everything is properly and
385
00:13:42,015 --> 00:13:43,039
This is what it should look
386
00:13:43,551 --> 00:13:49,695
We're going to declare spawn position above the for-loop so let's go ahead and declare a variable
387
00:13:49,951 --> 00:13:50,463
1 position
388
00:13:51,231 --> 00:13:53,023
And let's just said it to
389
00:13:53,535 --> 00:13:57,887
Player that global position next week doesn't matter live that's actually said it to them
390
00:13:58,911 --> 00:14:00,191
Just so that it initially
391
00:14:00,703 --> 00:14:01,471
2A
392
00:14:01,727 --> 00:14:02,239
Vector
393
00:14:02,495 --> 00:14:03,775
Ok so good to Dad's
394
00:14:04,543 --> 00:14:10,687
Now we're just having a beer and that's fine let's get rid of this via because we can't read it there a variable but we can we
395
00:14:10,943 --> 00:14:12,479
Sign do it in a totally doing here
396
00:14:13,759 --> 00:14:15,295
And we can actually break up
397
00:14:15,551 --> 00:14:16,063
This
398
00:14:16,319 --> 00:14:18,111
If else block so let's
399
00:14:18,367 --> 00:14:19,391
Delete the else
400
00:14:19,647 --> 00:14:21,695
Let's take this if result is my
401
00:14:21,951 --> 00:14:23,231
Invented by 1
402
00:14:23,487 --> 00:14:27,071
An Audi Galway because were in the correct context here
403
00:14:27,327 --> 00:14:28,607
And I want to remove this car
404
00:14:30,143 --> 00:14:36,287
So the thing about 4 so you can return early out of them as well so if your return in a for loop and let's say it's only
405
00:14:36,543 --> 00:14:38,591
The first iteration to actually stop
406
00:14:39,103 --> 00:14:43,711
So we can return early so that we don't have to go through all the loops if the first
407
00:14:43,967 --> 00:14:45,247
So I can spawn position
408
00:14:45,759 --> 00:14:46,271
Is
409
00:14:46,527 --> 00:14:47,039
Valley
410
00:14:48,319 --> 00:14:52,159
Then we're gonna do is we're also going to move the random direction out of this for
411
00:14:52,415 --> 00:14:53,439
Just above
412
00:14:53,951 --> 00:14:57,023
Initialise the random direction to a random
413
00:14:58,047 --> 00:15:01,119
Ok so what we left with is we are left with this look
414
00:15:02,655 --> 00:15:06,751
The final thing that we want to do is we want to put an else after this if result is
415
00:15:07,007 --> 00:15:07,519
MD
416
00:15:08,799 --> 00:15:10,335
And this is the part where we
417
00:15:10,591 --> 00:15:11,871
To change
418
00:15:12,127 --> 00:15:12,639
The
419
00:15:12,895 --> 00:15:13,663
Angle
420
00:15:13,919 --> 00:15:15,199
Of the random diary
421
00:15:15,711 --> 00:15:17,759
So we can say random Direction
422
00:15:18,271 --> 00:15:19,295
Is equal to
423
00:15:19,551 --> 00:15:21,343
Random Direction rotate
424
00:15:21,855 --> 00:15:24,927
And hour angle in here is going to be in
425
00:15:25,183 --> 00:15:25,695
Radiance
426
00:15:26,207 --> 00:15:28,255
So just to make it easy we can do
427
00:15:31,327 --> 00:15:33,631
To read which is a function that will
428
00:15:33,887 --> 00:15:35,167
Degrees in converted to radians
429
00:15:35,423 --> 00:15:36,191
How much pudding
430
00:15:37,727 --> 00:15:39,775
So re-assigning a random Direction
431
00:15:40,031 --> 00:15:42,591
To the random Direction but rotated by 9
432
00:15:43,359 --> 00:15:46,687
And then the loop is going to restart if this else block
433
00:15:46,943 --> 00:15:47,455
Wasn't
434
00:15:47,967 --> 00:15:49,759
Now the last thing we need to do is
435
00:15:50,015 --> 00:15:51,295
Outside of a form
436
00:15:51,551 --> 00:15:53,855
We just need to return our sponsor
437
00:15:55,391 --> 00:15:56,671
As The Returned
438
00:15:57,183 --> 00:16:01,279
Ok so let's just stepped through this logic again just to be extra sure
439
00:16:01,535 --> 00:16:02,047
But everything
440
00:16:02,815 --> 00:16:07,167
So we're going to assign initial spawn position in an initial random Direct
441
00:16:07,679 --> 00:16:09,983
Then we're going to in The Fall
442
00:16:10,239 --> 00:16:13,055
In each iteration were going to take a sponsor
443
00:16:13,567 --> 00:16:16,639
We're going to say it's equal to the players current position Plus
444
00:16:17,151 --> 00:16:21,503
The random Direction which is a unit vector which means a vector of length 1
445
00:16:22,015 --> 00:16:23,807
A x a spawn rate
446
00:16:24,319 --> 00:16:27,903
And those two added together is going to be our new composition that were cancelled
447
00:16:28,927 --> 00:16:31,999
Then we're going to create a raycast query
448
00:16:32,255 --> 00:16:35,583
Using the player position and spawn position
449
00:16:36,607 --> 00:16:38,399
The start and end points
450
00:16:38,655 --> 00:16:39,167
The rake
451
00:16:39,423 --> 00:16:40,959
And we're going to be checking again
452
00:16:41,215 --> 00:16:42,495
The terrain layer
453
00:16:42,751 --> 00:16:43,263
4 Acre
454
00:16:44,031 --> 00:16:47,103
Then we're going to actually do the intersection Ray
455
00:16:47,359 --> 00:16:47,871
Call
456
00:16:48,127 --> 00:16:49,151
To see if that rare
457
00:16:49,407 --> 00:16:51,455
We define a peer interest
458
00:16:51,711 --> 00:16:52,223
Lights with
459
00:16:52,479 --> 00:16:52,991
Terrain
460
00:16:53,503 --> 00:16:55,551
And that's going to be stored in a result dictionary
461
00:16:56,063 --> 00:16:58,111
If the result is of being empty
462
00:16:58,367 --> 00:17:01,183
Then we're going to return that spawn position of here that we talk
463
00:17:01,695 --> 00:17:02,975
If it's not empty
464
00:17:03,231 --> 00:17:06,559
We want to change the random Direction by rotating at 90 degrees
465
00:17:06,815 --> 00:17:07,839
Anna Lowther
466
00:17:08,095 --> 00:17:09,631
To start again
467
00:17:09,887 --> 00:17:10,911
And redo all
468
00:17:11,423 --> 00:17:13,471
And so what's going to happen is we're going to check
469
00:17:13,727 --> 00:17:15,263
Up to 4 raise
470
00:17:15,775 --> 00:17:17,567
Until we find the one
471
00:17:17,823 --> 00:17:19,103
That is not colliding with
472
00:17:19,359 --> 00:17:19,871
Train
473
00:17:20,127 --> 00:17:22,175
And that spawn position the last
474
00:17:22,431 --> 00:17:23,455
Set spawn
475
00:17:23,967 --> 00:17:24,735
Will be
476
00:17:24,991 --> 00:17:25,503
Return
477
00:17:26,015 --> 00:17:26,783
From our
478
00:17:27,295 --> 00:17:30,367
Now what I'm going to do actually to make it a little bit clearer what's going on
479
00:17:30,623 --> 00:17:36,511
Is I'm going to remove this return spawn position from this result is empty and he's a different keyword called
480
00:17:37,023 --> 00:17:39,327
And what break does is that tells the loo
481
00:17:39,583 --> 00:17:40,863
To stop execute
482
00:17:41,119 --> 00:17:42,143
To stop going
483
00:17:42,399 --> 00:17:43,167
Even
484
00:17:43,423 --> 00:17:44,703
The loop isn't tag
485
00:17:44,959 --> 00:17:45,471
Play finished
486
00:17:45,727 --> 00:17:48,287
So this is a nice way in addition to returning
487
00:17:48,543 --> 00:17:50,335
We can just break early out of loop
488
00:17:50,591 --> 00:17:52,895
I think this makes more sense as well
489
00:17:53,151 --> 00:17:56,223
Because we returning spawn position at the end of the funk
490
00:17:56,479 --> 00:17:59,551
Editor seems clear to me like ok we're just going to
491
00:17:59,807 --> 00:18:00,831
What is going to stop
492
00:18:01,087 --> 00:18:02,879
Once we find a spawn position
493
00:18:03,135 --> 00:18:05,183
That is valid and then we'll go
494
00:18:06,463 --> 00:18:09,023
Let's Run the game and make sure all of that is
495
00:18:09,279 --> 00:18:11,071
If I go onto the corner of my map
496
00:18:11,327 --> 00:18:13,887
I should see no enemies coming from this direction
497
00:18:14,143 --> 00:18:15,167
They should see enemies
498
00:18:15,423 --> 00:18:15,935
Coming from
499
00:18:16,447 --> 00:18:18,495
And so far I have not seen any
500
00:18:18,751 --> 00:18:20,543
Please come from outside of the wall
501
00:18:21,055 --> 00:18:22,335
So I think we can say
502
00:18:22,591 --> 00:18:23,103
That this
503
00:18:23,359 --> 00:18:24,127
Is
504
00:18:24,383 --> 00:18:24,895
Fixed
32516
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.