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:04,608
Before we wrap up the course there is one final bug to address and that is that
2
00:00:05,120 --> 00:00:07,168
Enemies can get stuck in the wall
3
00:00:07,680 --> 00:00:08,704
As you say
4
00:00:08,960 --> 00:00:09,728
Right here
5
00:00:10,240 --> 00:00:12,032
And this happens under a verb
6
00:00:12,288 --> 00:00:14,592
Specific Circumstance which I will describe
7
00:00:14,848 --> 00:00:15,360
Now
8
00:00:15,616 --> 00:00:18,432
So let's go to our handy paint and let's
9
00:00:18,688 --> 00:00:20,224
Draw a line that rep
10
00:00:20,480 --> 00:00:22,016
Against the wall and if you recall
11
00:00:22,528 --> 00:00:23,808
The way that we
12
00:00:24,320 --> 00:00:25,344
Spon End
13
00:00:25,856 --> 00:00:29,440
Is that we take the player position which is let's a right
14
00:00:29,696 --> 00:00:30,208
Who's the player
15
00:00:30,976 --> 00:00:32,512
And we basically shark
16
00:00:33,024 --> 00:00:34,048
A vector
17
00:00:34,560 --> 00:00:36,352
Along some Direction
18
00:00:36,864 --> 00:00:38,144
To see if there is a collision
19
00:00:38,656 --> 00:00:40,192
Edit there isn't a collision
20
00:00:40,448 --> 00:00:40,960
Respond
21
00:00:41,216 --> 00:00:41,728
Enemy
22
00:00:41,984 --> 00:00:43,520
What happens if h
23
00:00:43,776 --> 00:00:44,544
Raycast
24
00:00:44,800 --> 00:00:48,128
Ends one pixel before the wall likes
25
00:00:48,640 --> 00:00:50,688
And doesn't register a collision we say oh
26
00:00:50,944 --> 00:00:54,528
Well then that means that there is no collision in so what we're going to do
27
00:00:54,784 --> 00:00:55,808
An enemy
28
00:00:56,064 --> 00:00:57,088
So we spawn the end
29
00:00:57,600 --> 00:00:58,112
Play here
30
00:00:58,368 --> 00:00:58,880
However
31
00:00:59,136 --> 00:01:01,037
The enemy is now on top of the wall and
32
00:01:01,039 --> 00:01:03,515
Subtitled by
online-courses.club
We compress knowledge for you!
33
00:01:03,516 --> 00:01:05,792
Remember the enemy has a collision shape which is like a circle
34
00:01:06,048 --> 00:01:09,120
Are the enemy ends up with a circle Collider
35
00:01:09,376 --> 00:01:11,424
That is halfway inside of a wall
36
00:01:11,936 --> 00:01:17,056
So the fix for this is really simple instead of checking the exact distance along which we
37
00:01:17,312 --> 00:01:18,080
How to spawn the end
38
00:01:18,592 --> 00:01:20,128
We're actually going to add
39
00:01:20,384 --> 00:01:23,200
An additional 20 years so pixel check
40
00:01:23,712 --> 00:01:24,224
Like so
41
00:01:24,992 --> 00:01:27,808
So that means that if it's whole range if this whole
42
00:01:28,064 --> 00:01:28,576
Line
43
00:01:28,832 --> 00:01:30,112
Does not contain a collision
44
00:01:30,624 --> 00:01:32,416
Then we'll go ahead and spawn the enemy
45
00:01:33,440 --> 00:01:33,952
The tip
46
00:01:34,208 --> 00:01:34,720
The Orange
47
00:01:36,256 --> 00:01:37,024
Desired
48
00:01:37,280 --> 00:01:37,792
Sponge
49
00:01:38,304 --> 00:01:41,376
So essentially just adding an extra 20 years ago pics
50
00:01:41,632 --> 00:01:42,656
Checking to the
51
00:01:42,912 --> 00:01:43,680
The array
52
00:01:43,936 --> 00:01:48,800
So that we can be guaranteed that there will be at least 20 pixels of distance between
53
00:01:49,056 --> 00:01:49,824
Responding the enemy
54
00:01:50,080 --> 00:01:50,592
Between the
55
00:01:51,616 --> 00:01:54,688
So let's go ahead and open up our enemy manager
56
00:01:55,200 --> 00:01:59,296
And implement exactly that fix so go ahead and open up the screw
57
00:01:59,808 --> 00:02:05,440
And basically and hear what we've got going on is we are setting the enemy spawn position
58
00:02:05,696 --> 00:02:08,768
To the player global position plus that random Direction
59
00:02:09,024 --> 00:02:09,536
Choosing
60
00:02:09,792 --> 00:02:10,560
Up here
61
00:02:10,816 --> 00:02:12,864
X the spawn radius
62
00:02:13,376 --> 00:02:16,704
And like I showed in the drawing we basically want to
63
00:02:17,728 --> 00:02:18,240
Something
64
00:02:18,496 --> 00:02:20,032
20 additional pixels
65
00:02:20,288 --> 00:02:21,824
To the Ray
66
00:02:22,080 --> 00:02:22,592
Checking
67
00:02:22,848 --> 00:02:24,384
And so what we're going to do for that
68
00:02:24,640 --> 00:02:27,712
Is were going to create a new variable called additional
69
00:02:30,784 --> 00:02:33,088
And we're just going to random Direction
70
00:02:33,856 --> 00:02:34,368
Times 2
71
00:02:35,392 --> 00:02:39,488
And then in this line we were constructing the physics re query parameter
72
00:02:40,000 --> 00:02:44,096
We just simply going to add that additional check offset to the second
73
00:02:44,608 --> 00:02:46,656
So it's going to be spawn position Plus
74
00:02:47,424 --> 00:02:48,192
Additional
75
00:02:48,448 --> 00:02:48,960
Check
76
00:02:49,472 --> 00:02:49,984
Off
77
00:02:51,008 --> 00:02:54,848
So what does essentially going to do is that's going to create a rave and the player position
78
00:02:55,360 --> 00:02:58,688
To the spawn position that we want to have for the enemy
79
00:02:58,944 --> 00:03:00,224
But Plus
80
00:03:00,480 --> 00:03:02,016
An additional 20 pixel
81
00:03:02,272 --> 00:03:03,296
In the same direction
82
00:03:03,808 --> 00:03:07,904
And as long as that raycast does not return a collision result
83
00:03:08,416 --> 00:03:09,696
Then we can spawn em
84
00:03:10,976 --> 00:03:14,560
So you can run the game to test it's going to be very difficult to test
85
00:03:14,816 --> 00:03:15,328
But
86
00:03:15,584 --> 00:03:19,680
If you play the game a little bit more you should notice that it stops
87
00:03:19,936 --> 00:03:20,448
Happening
88
00:03:20,704 --> 00:03:23,520
And enemies are still spawning like normal
5786
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.