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 The sensors. 1
Each sensor implementation is found in the course modules in the sensors section. 2
Here I want to focus on how we can actually use them in a real life use case. 3
Here is the sensor manager. 4
The sensors or the sensor manager is basically a collection of all the sensors that will be applied 5
on each enemy to be able to use one or more to detect its targets. 6
The sensor manager is meant to be used as a modular component containing other modular components. 7
You can either use individual sensors on their own like range detector, field of view, so on and so 8
forth. 9
And you can also use the sensor manager if you want the power of more sensors combined. 10
Basically, the sensor manager has these sensors attached to it and also a timer, which is the 11
PollSensorsTimer. 12
And if you look at the script, there are a couple of things that happen here that are really important 13
for us. 14
So first, I want to mention this signal. 15
So this is how the sensor manager informs other objects that, hey, my target list got changed because 16
some of my sensors detected or stopped detecting some particular objects. 17
And here are some parameters like is using field of view is using raycast, so on and so forth. 18
The initialization is one of the new styles and basically it's a key-pair value dictionary called params. 19
Here for each value we have an enum and it'll say if it should use field of view, if it should use 20
raycast, and then putting those values from the dictionary to the actual variables in this part. 21
Next we have the timer, and this time the timer is connected via code. 22
Instead of going here node -> timeout(). 23
I opted for the code version. 24
Basically, in theory, you should always use the code one because you have everything in the code and 25
it's much easier to manage because if some parts are not in the code, you will find it harder to know 26
what exactly is where. 27
This is why I put it here. Then we initialize the range detector and the raycast detector. In the _process() 28
there is one more thing that happens. 29
Since the sensors actually... 30
If you look at an AI, the sensors are actually placed in the non-moving part of the enemy AI. 31
And this means that the sensor manager doesn't move with the actual tank. 32
To fix this, we update it at every frame to the tank position. 33
This will make sure that the range gets applied from the tank origin as well as the other sensors. 34
What happens when the timer gets zero? 35
By the way, the PollSensorTimeout is specified to auto start and not one shot. 36
So it happens all the time with a refresh rate of 0.25 seconds. 37
We will have a final list, which is basically a list of the targets detected by the range detector. 38
These are all the objects around the enemy. 39
. 40
If this sensor manager is using field of view, then we will generate a new list, which is the field 41
of view target list. 42
And this list will actually be combined with the list from the range detector, because the field of 43
view actually works infinitely in in that particular range. 44
We might detect objects beyond the range. In order to combine these, 45
what we will do instead is go through every object from the final list, which is basically what was 46
detected by the range. 47
And if that object is inside the field of view, then we add it to the new list. 48
And once this is done, then we move the field of view list to the final list and basically now we'll 49
have the objects from the combined range with field of view. In the case we want to use raycast 50
if there are objects occluding the enemy, so if the target is in the range is in field of view, 51
but it's behind a cube. 52
let's say. It won't be detected if we use raycast, but it will be detected if we just use field of view 53
and range. 54
How we can fix this? 55
Of course, we go through the final list which now either contains just the targets in range. 56
So this means that either like let's say target is behind the enemy but occluded by a cube, or if it 57
uses field of view, only the targets in front of the enemy. 58
But it doesn't matter because we can use any combination. 59
So we can use it 60
with field of view or with just raycast or with both. 61
We have the final list and then if the target is visible. 62
This actually creates a raycast from the tank to the enemy. 63
And if the raycast actually hits the target and not some other object, then it will append to the list 64
and then the raycast list will get in the final version of the list. 65
And once we have the final version, we can throw the signal out that the list was updated and give 66
the final list to what system actually needs it to make the next steps. 67
This is highly customizable because it allows detection, just the range or any combination range, 68
field of view and raycast. 69
Of course, some functionalities do require to be used in other ways, such as is_target_visible. 70
That means for the raycast detector. 71
This one is actually called in some other parts of the code. 72
When we already have the target and we don't see it at some point, then this is kind of useful. Or the 73
target is in range, kind of similar. Or all the targets in range, just the range detector. 74
Basically these functions are just wrappers on top of specific sensors functionalities. 75
These are useful in particular cases of our AI implementation. But the most useful is the signal 76
. 77
on_target_list_updated. Basically this is the sensor manager. 78
You'll find it in every AI system. 79
It's the first one, the sensor manager. 80
It gets used quite heavily because this is how the enemy detects anything. 81
If we just played this scene and I'm going to use the debug sensors and of course I'm going to spawn 82
an enemy. 83
So this is the range. 84
And this is the raycast. 85
. 86
I'm going to put the camera. 87
If I move here. Now the target is not visible any more from their perspective. 88
But wait a second. 89
Now they follow. 90
Oh! Now it's visible. 91
This was the last position where the target was found. 92
And of course, it checks it a little. 93
This is the final result of the sensors, and you can customize them in the enemy initialization. 94
It's not for this particular video, but, it's in every enemy to be initialized. 95
I hope you enjoyed it. 96
And 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.