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 Let's look now at the waypoint manager and system. 1
I'm going to play the scene quickly and spawn an AI. 2
So when an AI gets spawned, they automatically go into patrol mode and if they find the waypoint 3
system, then they'll move to the closest point. 4
And then, from that point, they'll do the whole waypoint step by step. 5
Of course, at one point (in time), only one instance can use a particular waypoint. 6
Let's see how this all works in this lesson. 7
This is the waypoint system. 8
It might get confusing a little, so I'll try to make sure that everything is straightforward. 9
I'll start here at the waypoint level. And the waypoint here is called waypoint system, but it's actually 10
just a waypoint and the waypoint is formed out of individual points like these ones. 11
These are just position3D 12
. 13
And. 14
They specify where the tanks should move next. 15
If it's following this particular waypoint system. And we have three scripts here, we have the waypoint 16
manager, the waypoint system and the waypoint node. To understand how they work, 17
instead of going through each directly, let's figure out the steps how the AI actually uses this system. 18
So the first contact with the waypoint is asking the waypoint manager: Can you give me the closest 19
waypoint node that is available? 20
Available means that it's not actually used by another AI enemy. 21
So if you go here into the waypoint manager, what we have here is of course in the initialize phase 22
we get all the waypoints that are children to it. 23
So in this case it's just waypoint A but we could have easily made other waypoints as well. 24
And here we have get the closest available waypoint. 25
So what this does, it goes through all the waypoints and if it's in use, then it just skips it. 26
And if it's not in use, then it means that it's free. 27
And then inside of this, not only that we get the waypoint, but we also get the closest node from 28
that particular waypoint. 29
So if we look back in the scene, we have four nodes here. 30
1, 2, 3, 4. 31
The closest node from the player would be this one. 32
So usually since most of the A's get spawned here, they either get this one or this one has points 33
going back. 34
So you get the closest point. 35
Of course, we don't know for sure if this particular waypoint has the closest node. 36
We just know that this is the closest node from this waypoint. 37
When we call the get closest node from the waypoint we know is the closest from this particular waypoint. 38
But if it has more waypoints, some closer nodes might be even more closer to the actual position that 39
we are specifying here. 40
So we need to make sure that we actually take care of this and we get the closest, closest point. 41
So to provide the better example, let's say I duplicate this and move it a little. 42
So... 43
Let's now say we have two waypoints systems. 44
So Waypoint 1 and Waypoint 2. 45
It will get the closest point from this one and from this one, and it'll determine based on the position 46
let's see, it's this one is the closest one. 47
And if this one is free, then it will basically return this node to the player. 48
So this is how this functionality works. 49
Basically, it just checks all the available waypoints that are not in use and then returns the closest 50
point for each. 51
And then once the player decides, Oh, this is the closest point to me, I'll use this one. 52
So basically this is what happens at this level and not much more. 53
So the waypoint manager just knows all the possible waypoint systems and gives the closest available 54
waypoint. 55
Now if you look one level down where the waypoint level is, the waypoint system actually here we actually 56
have the specification of the points. 57
Every children often waypoint system is actually a 3D position that the enemy needs to do in sequence 58
first to get all of the children. In the _process() 59
we basically just display them 60
with a debug line. 61
So this is just for visual purposes, no functionality here. 62
And, in here, we do have three main functionalities. 63
Get the closest node. 64
This gets the node closest in this particular waypoint. 65
So of course it takes a position and then goes through all of the points here. 66
And if it detects an even closer point, then it updates the closest node and once the points are finished, 67
the closest node is returned. 68
This is only used in combination with the waypoint manager because once the enemy AI has locked down on 69
a particular waypoint and it moves to a particular position, then they will use the get next node. 70
So this one works as follows: it has the current node, which is specified here and then iterates through 71
the list of waypoint nodes and if we find the current waypoint in the list, then we know that the next 72
one is where it should go next. 73
And of course we need to prevent if it's the final point, we need to go to the first point. 74
So basically this is how we can loop a waypoint system with the movement. 75
Lastly, we also need to trigger the waypoint use so that no other enemy can acquire this waypoint 76
system. 77
So this is actually called by the children. 78
I mentioned this. 79
It should not be called at this level because the waypoint manager will give the enemy a waypoint node, 80
which is actually a position and that waypoint nodal trigger this one from the parent. 81
And then that's basically it. The last level 82
here is the waypoint node. 83
If you go inside here, it's quite simple. 84
It takes the parent as the waypoint system, it triggers the waypoint use from the parent and it also 85
gets the next node from the parent. 86
So the waypoint system is actually an in-between component because get closest node is used by waypoint 87
manager, get next node and trigger waypoint use are used by its children. 88
So you as a developer don't actually need to go here and do anything because you either go to the waypoint 89
manager to query it in the first place. 90
And once you acquire a particular point, let's say this one, then you either query for the next node 91
or you triggered the waypoint use once you get it in the first place. 92
And that's basically it. 93
And then the patrol part of the enemy AI. 94
We'll look more into how this system is actually used to get the node and get to the position. 95
I hope you enjoyed this lesson and I'll see you in the next one.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.