Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,060 --> 00:00:03,390
Let's look now at the enemy's tank mover system.
2
00:00:03,420 --> 00:00:12,360
This system is responsible for moving the tank across a list of steps they are provided in the 3D space.
3
00:00:12,360 --> 00:00:18,990
So they are vector three, then the tank mover cycles for every single one of them and moves the tank
4
00:00:18,990 --> 00:00:19,680
accordingly.
5
00:00:19,860 --> 00:00:21,900
Let's find out how this system works.
6
00:00:21,900 --> 00:00:24,030
First, we need to initialize this.
7
00:00:24,030 --> 00:00:29,250
And as the enemy actually has the speed, we do need to provide the speed at the initial step.
8
00:00:29,250 --> 00:00:35,490
And then we get the tank, which is the kinematic body and also the tank mesh.
9
00:00:36,060 --> 00:00:39,090
We will need them both for our next steps.
10
00:00:39,210 --> 00:00:45,160
The main functionalities that are called In the Tank Move are the following Start Move, which takes
11
00:00:45,160 --> 00:00:53,400
the list of steps and also initializes the index of the whole path to zero reset, which stops any movement
12
00:00:53,400 --> 00:01:01,620
that is currently happening, and also a query that will say true or false, either if the path is finished
13
00:01:01,620 --> 00:01:02,580
or not.
14
00:01:02,580 --> 00:01:04,110
Basically if it's moving or not.
15
00:01:04,320 --> 00:01:07,410
So the actual movement happens in the physics process first.
16
00:01:07,410 --> 00:01:11,250
If we don't have a path and if it's known, then we don't actually care.
17
00:01:11,250 --> 00:01:14,700
But if we do have a path, we of course need to check the index.
18
00:01:14,700 --> 00:01:21,300
So if the current position is not the final one, and if it's not the final one, then it means that
19
00:01:21,300 --> 00:01:24,900
we have to go to that particular one thing to compute the direction.
20
00:01:25,110 --> 00:01:32,130
So in order to do this, we take the 3D position that was specified at the PATH Index position and subtract
21
00:01:32,130 --> 00:01:34,590
the value of the tank's position.
22
00:01:34,830 --> 00:01:40,890
This will give us the direction vector or the vector that is headed from the tank to that particular
23
00:01:40,890 --> 00:01:41,460
position.
24
00:01:41,460 --> 00:01:48,180
If the length of that the action vector is below one, then that means the position was reached and
25
00:01:48,180 --> 00:01:49,740
we need to increase the index.
26
00:01:49,800 --> 00:01:53,970
If it's bigger than one, then this means we haven't reached yet the position.
27
00:01:53,970 --> 00:01:59,760
So we need to apply a translation and of course you need to normalize the direction because the direction
28
00:01:59,760 --> 00:02:02,820
would be the whole vector from the tank to the new position.
29
00:02:02,820 --> 00:02:09,420
By normalizing it we take a vector of length one but the same orientation and we multiply it with the
30
00:02:09,420 --> 00:02:14,010
move speed that we use in initialize and also with the delta between frames.
31
00:02:14,010 --> 00:02:17,070
So we make sure that it's frame rate independent next.
32
00:02:17,070 --> 00:02:20,940
This handles the actual movement, but what about the rotation?
33
00:02:20,940 --> 00:02:26,520
We will use the tank mesh as we don't want actually to rotate the kinematic body, we'll just rotate
34
00:02:26,520 --> 00:02:27,390
the 3D mesh.
35
00:02:27,390 --> 00:02:33,990
So what we do will make it look at at the next path, which is the path we're actually heading towards.
36
00:02:34,080 --> 00:02:37,950
Of course, we need to also reset the rotations that we don't need.
37
00:02:37,980 --> 00:02:44,460
This is to prevent the case when the tank gets closer to the position and the position actually gets
38
00:02:44,460 --> 00:02:45,540
below it, kind of.
39
00:02:45,540 --> 00:02:52,650
So it might be that if we look at and we don't reset the X and Z rotation, the tank will look actually
40
00:02:52,650 --> 00:02:54,120
down and it will look strange.
41
00:02:54,120 --> 00:02:55,950
So make sure that this is in place.
42
00:02:56,100 --> 00:03:00,540
Of course, if you have terrain that's not flat, then you might need to change this.
43
00:03:00,540 --> 00:03:03,210
But I would rather go for a different result.
44
00:03:03,210 --> 00:03:07,830
Let's say Iraq last and check the terrain below and check the normal there.
45
00:03:07,950 --> 00:03:09,540
That's the other way to do it.
46
00:03:09,540 --> 00:03:14,760
And if the path index has reached the final position, then we omit the signal on finished moving.
47
00:03:14,850 --> 00:03:18,900
This will inform any particular objects that are on.
48
00:03:18,990 --> 00:03:23,610
Subscribe to this notification to make sure that other functionalities are played.
49
00:03:23,610 --> 00:03:29,640
For example, if the enemy has reached the destination of a waypoint, then we need to make sure that
50
00:03:29,640 --> 00:03:32,100
we need to go to the next one and so on and so forth.
51
00:03:32,130 --> 00:03:36,540
So basically this is how the tank I moves, by the way.
52
00:03:36,660 --> 00:03:38,660
This is just the movement functionality.
53
00:03:38,670 --> 00:03:44,430
The other part of the movement functionality is using the nav mesh to actually generate the path that's
54
00:03:44,430 --> 00:03:45,720
being provided here.
55
00:03:46,140 --> 00:03:51,960
So this just moves the tank, but you'll see later on how we can also use the nav mesh to generate the
56
00:03:51,960 --> 00:03:52,320
path.
57
00:03:52,320 --> 00:03:54,780
I hope you enjoyed this and see you in the next one.
5934
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.