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 Welcome to hit detection. 1
Basically, hit detection means that the enemy, when it gets hit by a projectile, it needs to be notified. 2
Hey, wait a second. 3
I have been hit. 4
Let's find out how this works. 5
So if I run the scene and we think this is a projectile and this is the enemy, if we move the projectile 6
through the enemy, then a hit was detected in the output. 7
Of course, multiple projectiles will yield multiple hit detected results. 8
This is important because if the enemy does not directly detect the player, but the player hits the 9
enemy, then the enemy should retaliate. 10
Let's see how this is done. First, 11
as you can see, there is no player, actually just the bullet. 12
And the bullet has a mesh instance which is not so relevant just for visual purposes, but it has an 13
area. 14
And this is important because this is how the collision will happen. 15
It has monitoring turned on and there is a collision shape which is a capsule shape. 16
Please note that the collision shape is a little bigger than the projectile. 17
This is just for the demo purposes to make it easier to use. 18
Now let's see about the bullet. 19
By the way, please note that the area 20
has on body_entered and this signal is getting triggered in the bullet. 21
So basically the bullet script is quite simple. 22
It just detects if a body entered the area, it gets the parent of that object and then if the object 23
has the method called register hit. 24
In this case, for example, the AI would have implemented this method, then it calls it. 25
If not, nothing happens. 26
Now let's look at the AI. 27
So here the actual collision happens in the kinematic body by just having the body in the bullet. 28
We will not get the register hit, which is a level above it. 29
So of course this get parent needs to be used. 30
By the way, pro tip, make sure you have the same structure for the enemies as for the players because 31
you have a generic projectile. 32
Then, 33
in some cases this might be at the body level, in some other cases it might be at the parent level. 34
And then you have to implement either checks for just the body if it has this register hit or the parent 35
and the body and it will get messy. 36
So make sure you have the same structure for every object that needs to receive a projectile. 37
But in this case is the higher level. 38
So here is just a register hit and of course it will print hit detected. 39
Then this can be later included in the AI's decision system and tell: Hey, please attack the player now 40
or retreat or whatever. 41
So basically this is the hit detection. Now that we have covered how to deal if sensors, state machines. 42
Let's head over to the last part of the course, which is the actual project. I'll see you in there!
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.