All language subtitles for 5. Implementing Hit Detection

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
ru Russian Download
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
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 0 1 00:00:00,030 --> 00:00:02,010 Welcome to hit detection. 1 2 00:00:02,730 --> 00:00:11,450 Basically, hit detection means that the enemy, when it gets hit by a projectile, it needs to be notified. 2 3 00:00:11,460 --> 00:00:12,770 Hey, wait a second. 3 4 00:00:13,050 --> 00:00:14,100 I have been hit. 4 5 00:00:14,520 --> 00:00:16,470 Let's find out how this works. 5 6 00:00:16,800 --> 00:00:23,250 So if I run the scene and we think this is a projectile and this is the enemy, if we move the projectile 6 7 00:00:23,250 --> 00:00:26,370 through the enemy, then a hit was detected in the output. 7 8 00:00:26,430 --> 00:00:31,470 Of course, multiple projectiles will yield multiple hit detected results. 8 9 00:00:31,710 --> 00:00:37,740 This is important because if the enemy does not directly detect the player, but the player hits the 9 10 00:00:37,740 --> 00:00:40,230 enemy, then the enemy should retaliate. 10 11 00:00:40,380 --> 00:00:42,610 Let's see how this is done. First, 11 12 00:00:42,630 --> 00:00:45,600 as you can see, there is no player, actually just the bullet. 12 13 00:00:46,200 --> 00:00:52,080 And the bullet has a mesh instance which is not so relevant just for visual purposes, but it has an 13 14 00:00:52,080 --> 00:00:52,430 area. 14 15 00:00:52,440 --> 00:00:55,560 And this is important because this is how the collision will happen. 15 16 00:00:55,830 --> 00:01:00,720 It has monitoring turned on and there is a collision shape which is a capsule shape. 16 17 00:01:00,900 --> 00:01:04,020 Please note that the collision shape is a little bigger than the projectile. 17 18 00:01:04,260 --> 00:01:08,700 This is just for the demo purposes to make it easier to use. 18 19 00:01:08,850 --> 00:01:11,280 Now let's see about the bullet. 19 20 00:01:11,640 --> 00:01:14,010 By the way, please note that the area 20 21 00:01:15,240 --> 00:01:21,360 has on body_entered and this signal is getting triggered in the bullet. 21 22 00:01:22,050 --> 00:01:25,110 So basically the bullet script is quite simple. 22 23 00:01:25,380 --> 00:01:34,680 It just detects if a body entered the area, it gets the parent of that object and then if the object 23 24 00:01:34,680 --> 00:01:36,780 has the method called register hit. 24 25 00:01:36,900 --> 00:01:41,130 In this case, for example, the AI would have implemented this method, then it calls it. 25 26 00:01:41,460 --> 00:01:42,990 If not, nothing happens. 26 27 00:01:43,410 --> 00:01:45,000 Now let's look at the AI. 27 28 00:01:45,090 --> 00:01:51,750 So here the actual collision happens in the kinematic body by just having the body in the bullet. 28 29 00:01:51,840 --> 00:01:55,600 We will not get the register hit, which is a level above it. 29 30 00:01:55,650 --> 00:01:58,620 So of course this get parent needs to be used. 30 31 00:01:58,650 --> 00:02:03,510 By the way, pro tip, make sure you have the same structure for the enemies as for the players because 31 32 00:02:03,510 --> 00:02:05,250 you have a generic projectile. 32 33 00:02:05,310 --> 00:02:06,440 Then, 33 34 00:02:06,480 --> 00:02:11,220 in some cases this might be at the body level, in some other cases it might be at the parent level. 34 35 00:02:11,340 --> 00:02:17,490 And then you have to implement either checks for just the body if it has this register hit or the parent 35 36 00:02:17,490 --> 00:02:19,670 and the body and it will get messy. 36 37 00:02:19,680 --> 00:02:24,600 So make sure you have the same structure for every object that needs to receive a projectile. 37 38 00:02:24,630 --> 00:02:26,400 But in this case is the higher level. 38 39 00:02:26,550 --> 00:02:31,680 So here is just a register hit and of course it will print hit detected. 39 40 00:02:31,800 --> 00:02:38,430 Then this can be later included in the AI's decision system and tell: Hey, please attack the player now 40 41 00:02:38,460 --> 00:02:40,590 or retreat or whatever. 41 42 00:02:40,830 --> 00:02:47,580 So basically this is the hit detection. Now that we have covered how to deal if sensors, state machines. 42 43 00:02:47,610 --> 00:02:53,100 Let's head over to the last part of the course, which is the actual project. I'll see you in there! 4447

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