All language subtitles for 3. FSM Example in Godot

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

0 In this example, we will have three different states: the idle state, the move state, and the fire 1

state. 2

These are basically just some scripts with a little code. 3

They're nothing special. 4

But of course you can imagine that this is an AI because it can be 5

an actual AI here. Every state will be connected with each other and will trigger transitions when 6

specific conditions are met. 7

Let's configure the finite state machine example first. 8

This will be the main screen which currently has two buttons. 9

Is moving button and is firing button. 10

Basically what they'll do is have a special signal. 11

That this called in this debug script and this debug script. 12

What it does it has two signals from is moving button and is firing button and it was set up two states 13

and will set up inside the custom finite state machine that we created. The database with the is_moving or 14

is_firing and will also reflect this in the button text itself. 15

Also, we need to show the current state in a label. 16

So if we go back, the current state will be visible in this label to be able to properly debug it. 17

Now let's go back a little to the idle state because we need to make some changes here because we will 18

have some connections between idle state, move state and fire state. 19

If the finite state machine... 20

By the way, in this implementation, in the check conditions, we will create the transitions for various 21

states. 22

So we need to get the value and is moving. 23

Be mindful that this value is actually set in this debug script. 24

So is_moving. 25

It needs to be the same. 26

I can just copy paste it to make sure is the same. 27

Otherwise what I recommend you to do is create a globals file. 28

You can do that by using a singleton in Godot and basically create a variable that has this string 29

and use that variable instead to remove the hardcoding part. 30

Because by just missing one character here, then it won't work anymore. 31

This is a pro tip basically. 32

So get value is_moving. 33

And of course this is true. 34

Then we need to change the state to the move state. 35

How is the move state called? 36

Well, it's actually the same name as here. 37

And, if you remember from the implementation, we get every state from the children. 38

We create the dictionary where we keep our values. 39

So based on the name actually written here, we actually get the state as well. 40

So this is how we go to the move state. 41

And now, of course, we don't want to continue this because we already changed the finite state machine 42

to the move state. 43

But if it was not moving, then it might be a possibility for it to be shooting or is_firing. 44

And if that's the case, then we need to change it. 45

FireState. 46

And by changing to the fire state, then of course, this is a new state. 47

And in the move state as well as in the fire state, we see very similar code, but we just check for 48

the values in the other direction. 49

Just be mindful that some changes here are really important. 50

So as you can see in the move state, it's a little different. 51

The if statements are embedded as well as in the fire state. 52

This is important to prevent unusual transitions in the state machine. 53

Before we can run this, I need to set up the entry state in the custom finite state machine. 54

And of course I want it to be IdleState. 55

So the entry state will be running. By the way, if we run the state machine about this, it'll crash. 56

So make sure to actually put this here. 57

If we run this, then of course, the current state is idle state and we entered the idle state. 58

If the enemy is moving, then the variable is_moving will be set up. 59

In this case, I'm just going to set it up by pressing the button. 60

But as you can see, we exited the idle state and we entered the move state. 61

And the current state is of course, the move state. 62

If I put in the firing. 63

As you can see here, the moves state is still going because of the way conditions are created. 64

So it will go to firing only if I disable is_moving. 65

And basically what it does here, it goes back to idle and then checks: is firing online? 66

And as you can see here in the moving so exited move state. Entered idle state exited idle state 67

and entered fire state. 68

And this is how we end up in the fire state. 69

Be careful how you create your transitions because this will affect your whole logic of the finite state 70

machine. 71

Basically, this is all about finite state machines. 72

Now let's find out in the next module how to get an AI from a position A to a position B using pathfinding.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.