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
0 What are finite state machines? 1
Well, a finite state machine or, for short, FSM is a collection of states and transitions. 2
The states represent the actions that an AI agent can take. For example: fire, run, patrol, and so on, so 3
forth. 4
And the transitions are the links between these actions that tells when the AI should change its current 5
state. 6
For example, if the AI was patrolling and it encounters a player, then the state should change from 7
patrol to attack so that AI can properly play the animation, fire the projectile and face and run 8
towards the enemy. 9
This is one example, but finite state machines is one of the most common ways to implement AI 10
in games. 11
Behind the scenes, an FSM is basically a graph and if you don't know what the graph is, then you should 12
definitely check the bonus section, the data structures. 13
What it does is basically these nodes represent the states and the transitions represent the edges between 14
them. 15
Let's now look at the pros and cons of using a finite state machine. 16
Well, one of the most important pros is the fact that it's very easy to use and understand. 17
You basically create the states. 18
You name them and you use them. 19
You connect them via transitions. 20
And basically, this is it. 21
And of course, because of its simplicity, that means that it's very fast. 22
So if you have a lot of AI instances, for example: 1000, then a finite state machine would do good 23
because it doesn't require so much processing power. 24
What are the cons of a finite state machine? 25
Well, the first one that it might get out of hand quickly if you had more states, more transitions, 26
you interconnect them with each other, then you might end up with a spaghetti of something that it's 27
hard to maintain. 28
And it's also hard to reuse because you cannot just take parts out of it because they are tightly connected 29
with each other. 30
But with all of these cons, I still believe it's a powerful system and it's used in modern games. 31
There are ways to mitigate all of these risks by implementing something called hierarchical state machines. 32
And the good news is that in the final project that we will have in this course, we actually have a 33
hierarchical finite state machine. 34
Basically what it means is that the groups states together in bigger states to avoid having too many 35
redundant transitions. 36
But you'll find out more in the later project. Now that you know what the final state machine is 37
let's find out how you can implement one yourself in Godot.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.