Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Welcome to the patrol.
Functionally.
This consists of two parts the finite state machine for patrolling and the actual code to make it work.
First, let's understand what patrolling does exactly when this state gets triggered.
It will try to make the tank patrol for this.
First, it will try to acquire a new waypoint system.
If a free one was found, it will be used.
If not, it'll move to a randomly generated position nearby, with sometimes generating a faraway position
to make it more dynamic.
This is the first level of the state machine.
We need to go down one level more inside the patrol by double clicking it.
Note that the patrol is called when the state machine is started as this is the default state.
Also, this state will be used if there is no target and the agent is not currently retreating.
The patrol is one of the simplest state machines.
It's made of two states.
Get the position and go to that position.
If it has a target, it will exit the states and continue into the attack state.
Let's check the code now and see how this works in the initialize.
Besides the regular parameters, we will use the tank mover and connect to its finished moving signal.
This will be useful to know exactly when to generate a new patrol point on entry is called when a new
sub state is entered.
And here we need to reset the turrets position.
This is the first thing because it might be rotated from the attack funny state machine and if you are
in the get position state, then we first need to stop the tank mover and then find a new patrol strategy.
The find patrol strategy function is divided into two parts checking for a waypoint and then generating
the actual path.
We need to check if DCI doesn't currently have one waypoint because if it does, then we just get the
next note and that's it.
But if it doesn't have a waypoint, then we need to query the waypoint manager and get the closest available
one.
If there is one free and if it is, then we initialize it and we notify that it's in use so that no
other agent can use it as well.
After we either get to a point where we don't get if we did had a waypoint, then we can generate the
move path using the functionality from the nav mesh from the current position of the air tank to the
current waypoint position.
This will generate a sequence of steps that we can fit into our tank mover.
In the case that we don't have on waypoint, then we will generate a random number and you use those
numbers and add it to the current positions X and Z, so that the tank will move slightly around after
the closest random position maximum is reached.
Then the tank will opt for a more faraway position.
This will make the tank more dynamic.
After this, we will have in a post X and post Y two different values, and we generate the new patrol
point and then we get the path to that.
So when this whole sequence finishes in, move path will either have a move path towards a new waypoint
or a move path towards a new randomly generated location.
And we put this into the tank mover using start move.
If you do not know how the tank mover works, you should check out the tank mover video.
We also need to set the trigger of the final state machine so that it'll go into the go to position.
The difference between a trigger and a value in a fight and set machine is the fact that a value is
continuously checked while a trigger just gets triggered once the state transitions immediately, and
then that's it.
So they work kind of in a similar way.
But you have to remember for a state, variables like has a target, for example, to always make sure
to be in the right true or false state.
Otherwise you might get the wrong transitions when the new position is reached on finished moving will
be called by the tank mover and we will set the trigger back to get position.
So basically the state machine will get to position, will issue the tank mover, which will move to
that position.
When the tank mover finishes, it'll go back to get position basically will go get position, go to
position and over and over again until something happens like acquiring target or retreat functionality.
This is the patrol functionality of the agent.
I hope you enjoyed it.
Let me know your feedback in the comment section down below.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.