Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,030 --> 00:00:01,230
Welcome to the patrol.
2
00:00:01,230 --> 00:00:02,050
Functionally.
3
00:00:02,070 --> 00:00:09,330
This consists of two parts the finite state machine for patrolling and the actual code to make it work.
4
00:00:09,390 --> 00:00:14,880
First, let's understand what patrolling does exactly when this state gets triggered.
5
00:00:14,910 --> 00:00:18,110
It will try to make the tank patrol for this.
6
00:00:18,150 --> 00:00:21,420
First, it will try to acquire a new waypoint system.
7
00:00:21,430 --> 00:00:23,790
If a free one was found, it will be used.
8
00:00:23,820 --> 00:00:30,060
If not, it'll move to a randomly generated position nearby, with sometimes generating a faraway position
9
00:00:30,060 --> 00:00:31,740
to make it more dynamic.
10
00:00:31,800 --> 00:00:33,700
This is the first level of the state machine.
11
00:00:33,720 --> 00:00:37,950
We need to go down one level more inside the patrol by double clicking it.
12
00:00:38,130 --> 00:00:43,590
Note that the patrol is called when the state machine is started as this is the default state.
13
00:00:43,620 --> 00:00:50,160
Also, this state will be used if there is no target and the agent is not currently retreating.
14
00:00:50,250 --> 00:00:52,770
The patrol is one of the simplest state machines.
15
00:00:52,920 --> 00:00:54,600
It's made of two states.
16
00:00:54,780 --> 00:00:57,900
Get the position and go to that position.
17
00:00:58,080 --> 00:01:02,640
If it has a target, it will exit the states and continue into the attack state.
18
00:01:02,910 --> 00:01:07,540
Let's check the code now and see how this works in the initialize.
19
00:01:07,560 --> 00:01:15,000
Besides the regular parameters, we will use the tank mover and connect to its finished moving signal.
20
00:01:15,390 --> 00:01:23,760
This will be useful to know exactly when to generate a new patrol point on entry is called when a new
21
00:01:23,760 --> 00:01:25,160
sub state is entered.
22
00:01:25,170 --> 00:01:28,530
And here we need to reset the turrets position.
23
00:01:28,680 --> 00:01:35,010
This is the first thing because it might be rotated from the attack funny state machine and if you are
24
00:01:35,040 --> 00:01:42,420
in the get position state, then we first need to stop the tank mover and then find a new patrol strategy.
25
00:01:42,510 --> 00:01:49,170
The find patrol strategy function is divided into two parts checking for a waypoint and then generating
26
00:01:49,170 --> 00:01:50,070
the actual path.
27
00:01:50,190 --> 00:01:55,860
We need to check if DCI doesn't currently have one waypoint because if it does, then we just get the
28
00:01:55,860 --> 00:01:57,540
next note and that's it.
29
00:01:57,600 --> 00:02:03,210
But if it doesn't have a waypoint, then we need to query the waypoint manager and get the closest available
30
00:02:03,210 --> 00:02:03,510
one.
31
00:02:03,630 --> 00:02:11,190
If there is one free and if it is, then we initialize it and we notify that it's in use so that no
32
00:02:11,190 --> 00:02:13,440
other agent can use it as well.
33
00:02:13,590 --> 00:02:21,270
After we either get to a point where we don't get if we did had a waypoint, then we can generate the
34
00:02:21,270 --> 00:02:27,360
move path using the functionality from the nav mesh from the current position of the air tank to the
35
00:02:27,360 --> 00:02:28,740
current waypoint position.
36
00:02:28,770 --> 00:02:32,880
This will generate a sequence of steps that we can fit into our tank mover.
37
00:02:32,880 --> 00:02:39,300
In the case that we don't have on waypoint, then we will generate a random number and you use those
38
00:02:39,300 --> 00:02:46,470
numbers and add it to the current positions X and Z, so that the tank will move slightly around after
39
00:02:46,470 --> 00:02:49,540
the closest random position maximum is reached.
40
00:02:49,560 --> 00:02:52,980
Then the tank will opt for a more faraway position.
41
00:02:53,100 --> 00:02:55,500
This will make the tank more dynamic.
42
00:02:55,590 --> 00:03:02,010
After this, we will have in a post X and post Y two different values, and we generate the new patrol
43
00:03:02,010 --> 00:03:04,380
point and then we get the path to that.
44
00:03:04,560 --> 00:03:12,240
So when this whole sequence finishes in, move path will either have a move path towards a new waypoint
45
00:03:12,240 --> 00:03:15,540
or a move path towards a new randomly generated location.
46
00:03:15,660 --> 00:03:19,710
And we put this into the tank mover using start move.
47
00:03:19,800 --> 00:03:23,600
If you do not know how the tank mover works, you should check out the tank mover video.
48
00:03:23,610 --> 00:03:30,240
We also need to set the trigger of the final state machine so that it'll go into the go to position.
49
00:03:30,570 --> 00:03:36,990
The difference between a trigger and a value in a fight and set machine is the fact that a value is
50
00:03:36,990 --> 00:03:43,740
continuously checked while a trigger just gets triggered once the state transitions immediately, and
51
00:03:43,740 --> 00:03:44,640
then that's it.
52
00:03:44,760 --> 00:03:47,220
So they work kind of in a similar way.
53
00:03:47,370 --> 00:03:53,610
But you have to remember for a state, variables like has a target, for example, to always make sure
54
00:03:53,610 --> 00:03:56,400
to be in the right true or false state.
55
00:03:56,400 --> 00:04:01,680
Otherwise you might get the wrong transitions when the new position is reached on finished moving will
56
00:04:01,680 --> 00:04:07,180
be called by the tank mover and we will set the trigger back to get position.
57
00:04:07,200 --> 00:04:12,780
So basically the state machine will get to position, will issue the tank mover, which will move to
58
00:04:12,780 --> 00:04:13,530
that position.
59
00:04:13,530 --> 00:04:19,500
When the tank mover finishes, it'll go back to get position basically will go get position, go to
60
00:04:19,500 --> 00:04:25,970
position and over and over again until something happens like acquiring target or retreat functionality.
61
00:04:25,980 --> 00:04:28,690
This is the patrol functionality of the agent.
62
00:04:28,710 --> 00:04:29,730
I hope you enjoyed it.
63
00:04:29,730 --> 00:04:32,280
Let me know your feedback in the comment section down below.
6644
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.