All language subtitles for lesson101

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
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
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian Download
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:06,656 --> 00:00:12,800 Rights of the enemies can hurt player but the player 2 00:00:13,056 --> 00:00:18,688 Really hurt the enemy right it's not really fair system where we can hurt 3 00:00:18,944 --> 00:00:19,968 The enemies 4 00:00:20,224 --> 00:00:24,320 Alright so let's first just create a variable called health 5 00:00:24,576 --> 00:00:25,856 Pretty anime 6 00:00:26,624 --> 00:00:32,768 We have a private integer called health and by the fault it's going to be 100 7 00:00:33,024 --> 00:00:36,608 And then we can have a private integer Max health 8 00:00:36,864 --> 00:00:41,728 That's going to be 100 as well ok is very somewhere to a new player here 9 00:00:42,240 --> 00:00:43,776 Can you play a has a 10 00:00:44,288 --> 00:00:47,104 Health and also a Max health value 11 00:00:47,616 --> 00:00:49,152 The same is true for enemies here 12 00:00:49,920 --> 00:00:50,688 Ok 13 00:00:51,200 --> 00:00:52,992 So what we're going to do here 14 00:00:53,248 --> 00:00:55,552 Is Russia going to create something called 15 00:00:55,808 --> 00:00:57,088 Hitbox 16 00:00:57,856 --> 00:00:59,648 And hitbox is going to be 17 00:01:00,123 --> 00:01:02,491 Subtitled by -♪ online-courses.club ♪- We compress knowledge for you! https://t.me/joinchat/ailxpXoW3JVjYzQ1 18 00:01:02,492 --> 00:01:06,304 On a player you can also put them on enemies as well but in this case we're just going to put it on our player 19 00:01:06,560 --> 00:01:08,096 And what is allows us to do 20 00:01:08,608 --> 00:01:12,192 Is create an invisible field in front of the player 21 00:01:12,448 --> 00:01:16,544 Hurt enemies if it touches those enemies 22 00:01:17,056 --> 00:01:23,200 Usually you will activate this by clicking your mouse button or may be pressing I don't know x on you 23 00:01:23,456 --> 00:01:27,040 Keyboard in activate that invisible field ok 24 00:01:27,552 --> 00:01:30,624 What we're going to do is Russia going to create something called 25 00:01:30,880 --> 00:01:37,024 An attack fox some people will call it a hitbox some people might even colder hurtbox and 26 00:01:37,280 --> 00:01:43,424 I like that word because it implies that maybe the players getting hurt as opposed to the player hurting an enemy 27 00:01:43,680 --> 00:01:47,776 Play Like a word attack box I think that's a really specific word 28 00:01:48,032 --> 00:01:52,128 How to spell understand what is saying actually does ok 29 00:01:52,384 --> 00:01:55,712 So I'm going to do is just a simple box Collider 2D 30 00:01:58,016 --> 00:02:01,600 And we're just going to say is Trigger is true 31 00:02:02,112 --> 00:02:03,392 Now I'm going to do is 32 00:02:03,648 --> 00:02:04,416 Simply 33 00:02:04,672 --> 00:02:08,256 Dragging over here to about 1 position of 1 34 00:02:09,024 --> 00:02:15,168 Maybe we should put it right snow against the player that looks good so maybe .8 instead 35 00:02:15,424 --> 00:02:16,192 Ok 36 00:02:16,704 --> 00:02:19,008 We have this attack box 37 00:02:19,520 --> 00:02:21,312 So the idea is that 38 00:02:21,568 --> 00:02:27,712 When I press a key on the keyboard so the attack key or right click the mouse this will appear 39 00:02:27,968 --> 00:02:32,832 Inherit the enemies that touch this box 40 00:02:33,088 --> 00:02:39,232 So this could be swinging a sword or punching in this attack box is invisible 41 00:02:39,488 --> 00:02:45,632 The way for us to you have an idea of where the enemy has to be to get hurt when they're in front of the player 42 00:02:45,888 --> 00:02:50,240 So just be clear let's go ahead and just add a Sprite renderer of this 43 00:02:51,008 --> 00:02:54,848 I can really see what's going on and 44 00:02:55,104 --> 00:03:01,248 Looks like we don't have a square Sprite so just going to level one here and I just create 45 00:03:01,504 --> 00:03:03,808 Google Pixel that we can use 46 00:03:06,112 --> 00:03:07,648 Actually like to have 47 00:03:09,440 --> 00:03:14,560 A single spray called white pixel in my games so that I can use it wherever I need to 48 00:03:15,328 --> 00:03:17,120 To use that white pixel 49 00:03:17,632 --> 00:03:19,168 On our attack box 50 00:03:20,448 --> 00:03:21,984 What's an import here there we go 51 00:03:22,240 --> 00:03:23,520 Dragon in there 52 00:03:24,032 --> 00:03:30,176 Now we have a box Collider that's way bigger than my pixel so what happens is you can actually remove the box Collider 53 00:03:30,432 --> 00:03:31,456 Inad again 54 00:03:33,760 --> 00:03:38,112 And it's going to be now decide about pixel and then we could use the right tool 55 00:03:38,880 --> 00:03:45,024 Just scale it up pretty big here 56 00:03:45,280 --> 00:03:49,120 What's the job done here we go hold shift scale down to see her 57 00:03:50,656 --> 00:03:53,216 Right here and let's make it red 58 00:03:53,728 --> 00:03:57,824 So we get an idea what is actual attackbox is ok 59 00:03:58,592 --> 00:03:59,872 Alright so 60 00:04:00,128 --> 00:04:04,736 What's Tesla sell last thing you want to do is just make sure to trigger 61 00:04:06,528 --> 00:04:08,576 Now it's tested out 62 00:04:11,904 --> 00:04:13,184 Ok 63 00:04:13,440 --> 00:04:19,583 So obviously I can't do anything when I touch the enemy but the idea for this box Collider 64 00:04:19,839 --> 00:04:20,863 Is that one 65 00:04:21,375 --> 00:04:24,959 We need to have it actually flip so when the players going left 66 00:04:25,471 --> 00:04:28,031 Is a turn that's one thing we need to do 67 00:04:29,055 --> 00:04:33,663 And also we wanted to be by default deactivated 68 00:04:34,431 --> 00:04:38,015 When we press the attack key or maybe click the mouse 69 00:04:38,783 --> 00:04:40,319 Quickly flash 70 00:04:40,575 --> 00:04:41,599 My cat 71 00:04:42,111 --> 00:04:44,927 Not obviously won't actually show that Red Box 72 00:04:45,183 --> 00:04:49,791 For the purposes of creating this game right now you're going to show the box 73 00:04:50,303 --> 00:04:52,863 When we click the mouse or press the attack 74 00:04:53,375 --> 00:04:57,727 The first and foremost let's go ahead in make the player flip 75 00:04:59,007 --> 00:05:00,799 When he's going in a certain Direction 76 00:05:01,311 --> 00:05:04,639 What's the weather going to do that is simply go into the update 77 00:05:04,895 --> 00:05:06,431 Create a new condition 78 00:05:06,943 --> 00:05:11,551 Reddit comment here that says flip the players 79 00:05:12,063 --> 00:05:13,599 Local scale 80 00:05:14,879 --> 00:05:15,903 The xx 81 00:05:16,415 --> 00:05:16,927 GIF 82 00:05:17,695 --> 00:05:19,743 The move speed 83 00:05:19,999 --> 00:05:21,279 Is greater than 84 00:05:22,303 --> 00:05:27,935 Say 0.01 or West End negative 2.01 ok 85 00:05:28,447 --> 00:05:29,215 Sophie's 86 00:05:30,239 --> 00:05:31,519 Moving to the right 87 00:05:31,775 --> 00:05:34,591 Is new speed is greater than 1 there for 88 00:05:34,847 --> 00:05:35,359 Is 89 00:05:35,615 --> 00:05:37,663 Logo scale should be positive 90 00:05:37,919 --> 00:05:40,479 Otherwise it should be negative ok 91 00:05:40,991 --> 00:05:47,135 Tell displayways to do this and is also really smart genius ways of doing this out of friend's name the araki actually 92 00:05:47,391 --> 00:05:53,535 My game never song and he could probably condense down what I'm about to write into one line of code 93 00:05:53,791 --> 00:05:58,399 But because we're all going to treat this tutorial as a layman's tutorial 94 00:05:58,655 --> 00:06:02,239 Pretty rudimentary about how we write it's ok 95 00:06:02,751 --> 00:06:03,775 If 96 00:06:04,031 --> 00:06:05,567 Target velocity 97 00:06:05,823 --> 00:06:06,591 That 98 00:06:06,847 --> 00:06:10,943 X is smaller than -1 99 00:06:12,223 --> 00:06:15,551 We're just going to set the transformed at local scale 100 00:06:16,575 --> 00:06:17,343 2 101 00:06:17,599 --> 00:06:19,647 New vector2 102 00:06:20,415 --> 00:06:21,951 Where did you -1 103 00:06:22,207 --> 00:06:24,255 And we'll keep why the same 104 00:06:29,119 --> 00:06:30,655 You do lcf 105 00:06:31,935 --> 00:06:33,727 Target velocity 106 00:06:34,239 --> 00:06:36,799 Directions greater than 101 107 00:06:37,311 --> 00:06:38,591 Just putting back 108 00:06:39,615 --> 00:06:40,895 21 109 00:06:41,407 --> 00:06:42,175 Ok 110 00:06:42,687 --> 00:06:45,759 To this should flip the players local scale 111 00:06:46,527 --> 00:06:49,855 If he's moving to left or is moving to the right 112 00:06:50,367 --> 00:06:51,647 Stridor sound 113 00:06:53,439 --> 00:06:54,463 Tiplee 114 00:06:58,559 --> 00:06:59,583 Awesome 115 00:07:03,167 --> 00:07:04,703 Just for clarification guys 116 00:07:05,471 --> 00:07:07,007 It has the attack box 117 00:07:07,775 --> 00:07:09,567 Is a child of the player 118 00:07:11,103 --> 00:07:13,407 When we flip the -1 119 00:07:13,663 --> 00:07:16,479 The attack box is going to do that as well 120 00:07:17,247 --> 00:07:22,111 All I said when we click on the attack box there is a scale is still the same here 121 00:07:22,367 --> 00:07:24,159 But it's being influenced 122 00:07:25,183 --> 00:07:27,743 Buy essentially a multiplier 123 00:07:28,767 --> 00:07:30,303 On the parrot 124 00:07:30,559 --> 00:07:32,095 Which is -1 125 00:07:33,887 --> 00:07:36,959 Even though it's scale is 10 essentially 10 126 00:07:38,239 --> 00:07:42,079 Because the players x scale is -1 127 00:07:42,591 --> 00:07:48,735 It flips the child inside of it think of nesting dolls that are really good way of thinking about if you turn a parrot nesting 128 00:07:48,991 --> 00:07:51,551 Around may be flooded upside down 129 00:07:52,319 --> 00:07:56,671 What's inside of it is locally basically the same but globally 130 00:07:57,439 --> 00:07:59,231 Based on the parents rotation 131 00:07:59,487 --> 00:08:01,023 Drogheda rotating side 132 00:08:02,303 --> 00:08:03,583 Alright there we go 133 00:08:08,447 --> 00:08:12,287 Alright so he flips now so now we get erase and code 134 00:08:13,567 --> 00:08:14,335 Dad will 135 00:08:15,359 --> 00:08:17,663 Make the box appear only 136 00:08:17,919 --> 00:08:24,063 When we attack and I actually really like attack to be a mouse click you guys can make it worse 137 00:08:24,319 --> 00:08:30,463 Why if you want to be the X key or whatever that's totally fine so first off the very first thing you need to do is go 138 00:08:30,719 --> 00:08:31,487 Project settings 139 00:08:32,255 --> 00:08:35,839 Emily go to work input manager remember this and we go to 140 00:08:36,095 --> 00:08:37,375 Fire 1 141 00:08:38,143 --> 00:08:43,775 Fire one is ok it's the positive line is left control or 142 00:08:44,031 --> 00:08:48,383 Ok so it looks like we can use the input 143 00:08:48,639 --> 00:08:50,687 Stream name of Fire 1 144 00:08:51,199 --> 00:08:52,991 Actually make this thing appear 145 00:08:54,015 --> 00:08:55,551 So let's try and do that really quick 146 00:08:56,063 --> 00:08:58,623 Let's do some pseudocode here if 147 00:08:59,391 --> 00:09:00,671 We press 148 00:09:01,183 --> 00:09:02,719 Fire 1 149 00:09:02,975 --> 00:09:03,743 Then 150 00:09:04,255 --> 00:09:05,279 Set 151 00:09:05,535 --> 00:09:07,071 The attackbox 152 00:09:07,583 --> 00:09:09,119 To active 153 00:09:09,887 --> 00:09:11,423 Otherwise 154 00:09:12,447 --> 00:09:15,007 Set active to fos 155 00:09:16,031 --> 00:09:20,127 Ok I will do this wireless give it a shot must you 156 00:09:20,383 --> 00:09:21,151 Input 157 00:09:21,407 --> 00:09:22,175 Diet 158 00:09:22,687 --> 00:09:23,199 Get 159 00:09:24,223 --> 00:09:24,991 Button 160 00:09:25,247 --> 00:09:26,271 Down 161 00:09:27,295 --> 00:09:28,831 Fire 1 162 00:09:31,647 --> 00:09:36,511 Then we need to say attack box set active 163 00:09:36,767 --> 00:09:37,535 True 164 00:09:40,607 --> 00:09:46,751 We have a little zig zag haircuts this variable doesn't exist so that variable appear 165 00:09:47,263 --> 00:09:53,407 Betsy here I think putting it somewhere around here is fine will organise over variables in a cleaner 166 00:09:53,919 --> 00:10:00,063 Section of a tutorial but for now we're just gonna put the right here and let's go how to make a private but we do want it cereal 167 00:10:00,345 --> 00:10:02,376 Subtitled by -♪ online-courses.club ♪- We compress knowledge for you! https://t.me/joinchat/ailxpXoW3JVjYzQ1 168 00:10:02,377 --> 00:10:02,623 Serializefield 169 00:10:02,879 --> 00:10:03,903 Private 170 00:10:04,159 --> 00:10:05,695 Silly a game object 171 00:10:06,975 --> 00:10:08,255 Check tax 172 00:10:10,815 --> 00:10:12,607 Go back in the unity here 173 00:10:13,375 --> 00:10:14,399 And now 174 00:10:14,655 --> 00:10:20,799 We have the attack box showing up here but there is no reference to it to Unity doesn't really know 175 00:10:21,055 --> 00:10:25,919 The gameobject is supposed to be all in those that it is a gameobject unity 176 00:10:26,175 --> 00:10:26,943 Is this 177 00:10:28,479 --> 00:10:31,039 If you go back into the scripture 178 00:10:31,295 --> 00:10:34,367 If input.get letting down fire 1 179 00:10:34,623 --> 00:10:36,415 Will make the attack box 180 00:10:36,671 --> 00:10:37,695 Activate 181 00:10:43,327 --> 00:10:49,471 Not obviously guys there's cleaner ways of reading this code we can compress this down into one line 182 00:10:49,727 --> 00:10:55,871 But again for the purposes of this tutorial I want to make sure everything is as clear as day to you guys especially with 183 00:10:56,127 --> 00:10:56,895 Conditions 184 00:10:57,151 --> 00:10:59,455 It's a bit out here going unity 185 00:10:59,967 --> 00:11:05,343 Hopefully when we play here this looking really deactivate because when I actually pressing the mouse 186 00:11:06,367 --> 00:11:07,391 Click it 187 00:11:10,207 --> 00:11:11,487 Quickly appears 188 00:11:11,999 --> 00:11:18,143 Now you'll notice that it's really fast I mean sometimes you can't even see it it'll disappear immediately 189 00:11:18,399 --> 00:11:20,447 Well we need to actually write a function 190 00:11:20,703 --> 00:11:24,287 See the active for a set amount of seconds ok 191 00:11:25,055 --> 00:11:27,359 Because clicking a mouse 192 00:11:28,127 --> 00:11:29,663 Is so fast 193 00:11:31,711 --> 00:11:37,855 Times you can barely even see the attack box and I can imagine that would be very third of a player because who knows 194 00:11:38,111 --> 00:11:41,439 Maybe that attack box doesn't last long enough 195 00:11:41,695 --> 00:11:43,231 Even hurt the enemy 196 00:11:43,743 --> 00:11:48,607 So instead of having it immediately disappear in a scripture 197 00:11:49,119 --> 00:11:51,935 What can I use as something called a coroutine 198 00:11:52,447 --> 00:11:58,591 And I know what you're thinking that's a really weird word what the heck are we talking about Thomas and 199 00:11:58,847 --> 00:12:04,991 I'd ever later saying hey guys feel I really do because I don't even know if I'm saying it right it doesn't matter with me 200 00:12:05,247 --> 00:12:10,879 I know what it's use is right so take a look at what a cuppa routine is 201 00:12:11,135 --> 00:12:12,415 Inside of Unity 202 00:12:12,671 --> 00:12:18,815 It says the execution of a current team can be passed at any point using the yield stable 203 00:12:19,071 --> 00:12:25,215 When a years statements used the curry team passes execution in America 204 00:12:25,471 --> 00:12:31,615 Resume that the next frame business what the heck are they talking about basically all occurrence 205 00:12:31,871 --> 00:12:34,431 Is guys is it allows us 206 00:12:34,687 --> 00:12:35,967 To start a function 207 00:12:36,479 --> 00:12:41,087 And that function can actually pause for a certain amount of seconds 208 00:12:41,343 --> 00:12:42,879 And then continue 209 00:12:43,135 --> 00:12:46,207 So why is this valuable to us 210 00:12:46,463 --> 00:12:49,023 Easter Mouse is clicked 211 00:12:49,535 --> 00:12:54,399 I want to start a function called what's a show a tack box 212 00:12:54,911 --> 00:12:57,471 I want to wait maybe half a second 213 00:12:57,727 --> 00:12:59,775 And then disable the attack box 214 00:13:00,287 --> 00:13:06,431 So let's go ahead in create that so let's just write out some pseudocode here but 215 00:13:06,687 --> 00:13:09,247 Start routine 216 00:13:09,503 --> 00:13:11,807 Activate attack 217 00:13:12,575 --> 00:13:13,343 Ok 218 00:13:13,855 --> 00:13:18,463 That's going to be r function so we're starting a curry teen and it's called 219 00:13:18,719 --> 00:13:19,999 Activate attack 220 00:13:20,767 --> 00:13:26,911 Now let's just put it right below here just so we can see it this is going to be activate attack 221 00:13:27,167 --> 00:13:31,519 Punching ok that's just a comment for me to know what this is 222 00:13:32,031 --> 00:13:35,871 Create a function the status in tax year is public void 223 00:13:36,127 --> 00:13:37,151 Activate 224 00:13:37,407 --> 00:13:38,431 Tag 225 00:13:39,967 --> 00:13:46,111 And then we're going to activate the attack box so attack box set active true 226 00:13:46,879 --> 00:13:50,207 Then we're going to wait point 227 00:13:50,463 --> 00:13:51,743 5 seconds 228 00:13:53,023 --> 00:13:55,839 And then we're going to send it back 229 00:13:56,351 --> 00:13:57,631 Boss 230 00:13:58,143 --> 00:13:59,167 Licence 231 00:14:00,191 --> 00:14:05,311 How we actually write this code out to go back to the unity documentation 232 00:14:06,847 --> 00:14:10,175 You can see here we can use this command here 233 00:14:10,687 --> 00:14:16,831 Yield return new waitforseconds is just basically a way of saying a unity I need to wait 234 00:14:17,087 --> 00:14:23,231 Stop reading stop your speed reading and just wait 235 00:14:23,487 --> 00:14:29,375 Return new wife for s a m 2.5 s 236 00:14:30,911 --> 00:14:34,751 So we're getting this red zigzag here what is that mean well 237 00:14:35,007 --> 00:14:41,151 Guys don't rush things right always look at your documentation what's exactly 2 238 00:14:41,407 --> 00:14:47,551 Wrong is well we didn't read the documentation in the documentation it says this is actually how 239 00:14:48,063 --> 00:14:49,087 We declare 240 00:14:49,343 --> 00:14:51,391 A function that uses 241 00:14:52,159 --> 00:14:53,183 Await time 242 00:14:53,695 --> 00:14:54,463 It's cold 243 00:14:54,719 --> 00:15:00,863 In saying that right I'm leaving now but I'm getting it doesn't matter what matters is 244 00:15:01,119 --> 00:15:04,191 You know what these things are used for ok and then you can do 245 00:15:04,447 --> 00:15:06,751 You know Google and unity documentation 246 00:15:07,263 --> 00:15:13,407 So when using a function that waits and stops reading for just a second 247 00:15:13,663 --> 00:15:16,735 You going to make it a type of a numerator ok 248 00:15:17,503 --> 00:15:18,271 Cell 249 00:15:18,527 --> 00:15:20,319 Instead of void 250 00:15:20,831 --> 00:15:22,111 What we're going to write is 251 00:15:22,623 --> 00:15:27,743 Ienumerator there is not a memorable but I numerator 252 00:15:27,999 --> 00:15:30,303 I don't even know what that means 253 00:15:30,559 --> 00:15:36,703 Ok well I know that we can now use this way time 254 00:15:37,471 --> 00:15:38,239 Tell 255 00:15:38,751 --> 00:15:42,335 I'm coming to sell start coroutine 256 00:15:42,591 --> 00:15:45,663 Activate attack so when we press fire 257 00:15:45,919 --> 00:15:51,295 It's going to start a career team meeting is going to start a function that uses 258 00:15:51,807 --> 00:15:52,575 Away time 259 00:15:53,599 --> 00:15:55,391 And that's called activate attack 260 00:15:56,927 --> 00:15:57,951 And here's the function 261 00:15:58,719 --> 00:16:04,863 It looks a little bit different than a regular function because it is use void actually utilising in ienumerator mean 262 00:16:05,119 --> 00:16:11,263 We can now wait so this is one of those things in unity guys where I still to this day 263 00:16:11,519 --> 00:16:14,079 Will have to Google how exactly to write this stuff 264 00:16:14,335 --> 00:16:15,359 Just know 265 00:16:15,615 --> 00:16:20,223 When you want to put a wait time in your function and have a wade 266 00:16:21,503 --> 00:16:23,551 Username generator 267 00:16:23,807 --> 00:16:29,951 Mm to actually call this function you need to make sure you type start a routine before you actually call 268 00:16:30,207 --> 00:16:31,487 Stop the function ok 269 00:16:31,743 --> 00:16:36,095 That doesn't make sense it's ok we can use these a couple times in a game 270 00:16:36,351 --> 00:16:38,911 Tell this is the only time we're going to use it so don't panic 271 00:16:40,191 --> 00:16:41,983 Don't make sense the more you use it 272 00:16:43,007 --> 00:16:47,359 What before we hit playlist just make sure attackbox is deactivated by default 273 00:16:48,127 --> 00:16:49,151 To play 274 00:16:49,919 --> 00:16:53,247 And what should happen as when we click 275 00:16:54,015 --> 00:16:56,063 Unity should literally stop 276 00:16:56,319 --> 00:16:58,367 Reading the code it's just wait 277 00:16:58,623 --> 00:17:04,255 In that function is Gonna Go hold on I'm gonna wait as like Thomas told me to 278 00:17:04,767 --> 00:17:10,143 And then deactivate the attackbox cyclic 279 00:17:10,399 --> 00:17:12,191 Activate wait deactivate 280 00:17:12,447 --> 00:17:13,983 Activate wait deactivate 281 00:17:15,519 --> 00:17:17,311 That allows us to have 282 00:17:17,823 --> 00:17:19,359 Some kind of control 283 00:17:19,871 --> 00:17:21,663 Over the length of the Punch 284 00:17:26,271 --> 00:17:30,879 Set a little bit too long isn't it so we could do is actually just 285 00:17:31,135 --> 00:17:32,927 We can do it this way .1 f 286 00:17:33,439 --> 00:17:35,743 Or another way of doing it is 287 00:17:36,511 --> 00:17:38,815 Attack decoration 288 00:17:39,071 --> 00:17:40,095 Yep 289 00:17:40,351 --> 00:17:43,423 Exist there is the exact line that's ok 290 00:17:43,679 --> 00:17:44,959 Now we can 291 00:17:45,215 --> 00:17:51,359 Free specific year 8 serializefield private float attack 292 00:17:51,615 --> 00:17:52,639 Direction 293 00:17:52,895 --> 00:17:59,039 Now we can go into unity in actually tweek the attack duration at runtime 294 00:17:59,551 --> 00:18:02,879 To get to feeling perfect right now I think 295 00:18:03,391 --> 00:18:05,183 500 start with Dad 296 00:18:06,207 --> 00:18:09,535 Play here that's a little too long isn't it 297 00:18:14,655 --> 00:18:16,959 What's make it 1 298 00:18:17,471 --> 00:18:20,287 Have you got a fair 299 00:18:20,543 --> 00:18:22,079 I'm at a time 300 00:18:22,335 --> 00:18:25,407 To activate that attack box for the player 301 00:18:26,175 --> 00:18:28,479 So now I need to write a script 302 00:18:28,735 --> 00:18:32,831 That will check to see if the attack box is hitting anything 303 00:18:33,087 --> 00:18:35,391 We could technically put this script 304 00:18:35,647 --> 00:18:41,535 Anyway really we can put it inside of the player we can also put it inside of the enemy script as well 305 00:18:41,791 --> 00:18:45,631 But I'm actually couldn't create a new script called a tack box 306 00:18:45,887 --> 00:18:48,703 Because honestly we can use this script 307 00:18:48,959 --> 00:18:52,799 Across various game objects not just for the player 308 00:18:53,055 --> 00:18:55,615 Are you guys or Cy in future videos 309 00:18:55,871 --> 00:19:01,247 For now I guess I just asked you to trust me and we can create a new attack box script 310 00:19:02,271 --> 00:19:05,087 My guys are getting weird warnings weird errors 311 00:19:05,855 --> 00:19:11,999 Affecting your game that's part of the course of Unity outlets drag the attack box here 312 00:19:15,839 --> 00:19:17,887 Now we have the attack back script 313 00:19:19,423 --> 00:19:21,727 On her attackbox game object 314 00:19:22,751 --> 00:19:24,287 Because this is a Trigger 315 00:19:25,567 --> 00:19:28,895 We can actually diffuse the on trigger function 316 00:19:31,967 --> 00:19:33,503 Witches Google there 317 00:19:34,527 --> 00:19:38,111 Unity on trigger enter 2D 318 00:19:43,999 --> 00:19:45,535 Let's see 319 00:19:46,559 --> 00:19:48,351 Where are you there is 320 00:19:49,375 --> 00:19:52,703 Happiness 321 00:19:53,215 --> 00:19:56,031 Pasted into a script again guys 322 00:19:57,823 --> 00:20:00,639 Writing code is it necessarily writing code 323 00:20:01,407 --> 00:20:07,551 Actually physically typing it right sometimes has just researching it finding it and using it 324 00:20:07,807 --> 00:20:12,415 So this case we're just going to use this right here void ontriggerenter2d 325 00:20:12,927 --> 00:20:15,743 And I will do as soon as cold here 326 00:20:16,255 --> 00:20:18,303 Yes I touch 327 00:20:19,327 --> 00:20:20,607 An enemy 328 00:20:21,119 --> 00:20:22,911 The enemy 329 00:20:24,447 --> 00:20:25,215 Ok 330 00:20:26,495 --> 00:20:28,287 Sort this out if 331 00:20:29,311 --> 00:20:33,919 The collider2d which is called col col 332 00:20:34,175 --> 00:20:35,455 Game object 333 00:20:38,015 --> 00:20:43,903 Let's see how can we identify if it's an enemy what would you actually do game object that name = 334 00:20:45,439 --> 00:20:47,487 Anime do it that way 335 00:20:51,327 --> 00:20:53,375 I touched an enemy 336 00:20:55,935 --> 00:20:56,703 Ok 337 00:20:57,215 --> 00:20:59,775 Does say they're out for now and just see if that works 338 00:21:00,287 --> 00:21:01,055 Ok 339 00:21:01,823 --> 00:21:02,847 It's like this year 340 00:21:03,871 --> 00:21:05,663 His name is anime 341 00:21:06,175 --> 00:21:07,199 Closest 342 00:21:07,455 --> 00:21:08,991 Play and see what happens 343 00:21:13,599 --> 00:21:14,623 Ready 344 00:21:16,416 --> 00:21:17,440 I touched an enemy 345 00:21:18,976 --> 00:21:24,096 Looks like it's doing it pretty buggy pretty good to you right now but that's ok we're gonna clean that later 346 00:21:24,864 --> 00:21:31,008 So that works great but honestly not every enemies name is going to be enemy right 347 00:21:31,776 --> 00:21:34,848 So what if we did something like 348 00:21:35,104 --> 00:21:37,152 He said if 349 00:21:37,664 --> 00:21:42,016 Col call gameobject get component 350 00:21:43,552 --> 00:21:44,320 Anime 351 00:21:47,136 --> 00:21:50,464 Collider 2D has a component called enemy 352 00:21:51,744 --> 00:21:52,768 Then 353 00:21:53,280 --> 00:21:58,912 Do this debug reason why we do that is because if inside of you nearly here 354 00:22:01,472 --> 00:22:03,776 My copy and paste and put another Enemy here 355 00:22:04,032 --> 00:22:07,360 You need is going to add a printer says one here 356 00:22:08,128 --> 00:22:08,896 By default 357 00:22:09,920 --> 00:22:13,248 And that means that it would no longer be able to check 358 00:22:14,016 --> 00:22:17,088 Using old method if the name is actually anime 359 00:22:17,344 --> 00:22:19,648 But because it has enemy class 360 00:22:19,904 --> 00:22:23,232 That's a great way to check if you're actually hitting in enemy 361 00:22:24,256 --> 00:22:25,280 Turn it down 362 00:22:29,120 --> 00:22:30,400 Attached an enemy 363 00:22:30,912 --> 00:22:31,680 That's great 364 00:22:37,568 --> 00:22:38,336 Ego 365 00:22:39,616 --> 00:22:40,384 Alright 366 00:22:41,152 --> 00:22:45,504 So that's working great so all we're going to do here is simply just go 367 00:22:46,016 --> 00:22:47,808 Call gameobject 368 00:22:48,320 --> 00:22:49,856 Getcomponent 369 00:22:50,880 --> 00:22:51,648 Enemy 370 00:22:54,976 --> 00:22:55,488 Health 371 00:22:56,256 --> 00:22:57,280 - equals 372 00:22:58,304 --> 00:22:58,816 1 373 00:23:00,608 --> 00:23:04,192 Why is this health got a red zigzag and I need it what's going on 374 00:23:04,448 --> 00:23:09,568 Well remember we got your enemy we can look at our health is actually private 375 00:23:09,824 --> 00:23:14,944 This is an instance where we actually want to make it public otherwise we'll never be able to change 376 00:23:17,248 --> 00:23:17,760 Then 377 00:23:18,016 --> 00:23:21,088 The last thing we want to do is just in the update 378 00:23:22,112 --> 00:23:23,904 Are we going to do is good condition 379 00:23:25,696 --> 00:23:29,536 Something like if health is smaller than 0 380 00:23:31,072 --> 00:23:32,352 Destroy Me 381 00:23:33,632 --> 00:23:35,424 The way we write that is if 382 00:23:35,680 --> 00:23:36,448 My health 383 00:23:36,704 --> 00:23:38,240 Is smaller than 0 384 00:23:40,288 --> 00:23:41,312 Destroy 385 00:23:42,080 --> 00:23:43,104 Game object 386 00:23:43,616 --> 00:23:48,224 Obviously guys there's two ways of doing this you can actually destroy a gameobject 387 00:23:48,736 --> 00:23:53,088 What you can just do gameobject set active 388 00:23:55,392 --> 00:23:57,440 But I'm ok with destroying 389 00:24:00,512 --> 00:24:06,656 Something that you should know that is destroying a game object or cos he very slight 390 00:24:06,912 --> 00:24:08,192 Slight drop in frame rate 391 00:24:08,704 --> 00:24:09,728 In your game 392 00:24:09,984 --> 00:24:11,520 But if you're doing it 393 00:24:11,776 --> 00:24:17,408 Not that often saucy work killing an enemy every 30 seconds it's not that bad song in half 394 00:24:17,664 --> 00:24:20,736 Destroy function just completely destroy 395 00:24:21,248 --> 00:24:22,528 This game object from the game 396 00:24:23,552 --> 00:24:27,648 I see here just delete this enemy here we don't need this 397 00:24:29,184 --> 00:24:32,000 And it's only focus on this enemy right here 398 00:24:33,536 --> 00:24:35,072 Let's watch it health 399 00:24:35,328 --> 00:24:36,352 As we take it 400 00:24:42,752 --> 00:24:44,288 Get down a 99 401 00:24:46,080 --> 00:24:47,616 Ego 402 00:24:50,944 --> 00:24:52,992 So we definitely don't want 403 00:24:53,760 --> 00:24:56,064 Only go down by one unit at a time 404 00:24:56,576 --> 00:25:02,720 And I want this game feeling like more went when you first start out I want you to be able to kill an enemy in maybe 405 00:25:02,976 --> 00:25:04,000 It's ok 406 00:25:04,768 --> 00:25:10,912 So if 100 is going to be the max health across the board for enemies and the player 407 00:25:11,168 --> 00:25:15,776 Then I say we want to decrease by 4 hit so 408 00:25:16,288 --> 00:25:19,872 Value of 25 + decreased by a value of 25 409 00:25:20,896 --> 00:25:21,920 So 410 00:25:22,944 --> 00:25:26,272 Attack power on the enemy here 411 00:25:26,784 --> 00:25:29,600 What actually happened attack power on the new player as well 412 00:25:30,368 --> 00:25:33,696 Then we can subtract that attack power 413 00:25:34,976 --> 00:25:36,256 From the Enemy 414 00:25:36,512 --> 00:25:38,048 Public editor 415 00:25:38,304 --> 00:25:39,584 Attack power 416 00:25:40,608 --> 00:25:41,632 What's my day 417 00:25:41,888 --> 00:25:43,168 25 418 00:25:48,288 --> 00:25:51,616 Now when the attackbox hits in enemy 419 00:25:52,128 --> 00:25:53,152 Simply Go 420 00:25:53,664 --> 00:25:58,784 Decrease by new player that instance 421 00:26:01,600 --> 00:26:05,440 Now we can have some kind of RPG elements in this game 422 00:26:05,952 --> 00:26:12,096 We can actually increase the attack power maybe take a purchase increase in attack power maybe every time that beat 423 00:26:12,352 --> 00:26:14,912 Herbal beginning increase in attack power 424 00:26:16,192 --> 00:26:18,240 Tell if we go to iPlayer here 425 00:26:18,496 --> 00:26:20,032 Protect H 25 426 00:26:20,288 --> 00:26:21,312 I mean it's going to take 427 00:26:21,568 --> 00:26:22,592 4 hits 428 00:26:23,104 --> 00:26:23,872 How to kill the enemy 429 00:26:25,408 --> 00:26:25,920 1 430 00:26:26,176 --> 00:26:26,944 2 431 00:26:27,968 --> 00:26:29,504 34 432 00:26:33,600 --> 00:26:39,744 His health is currently 0 so it actually going to take 5 hits 433 00:26:40,000 --> 00:26:42,816 Easily just jump into your enemy here 434 00:26:43,072 --> 00:26:48,960 Change this to if health is smaller than or equal to 0 435 00:26:49,472 --> 00:26:50,752 Destroy gameobject 436 00:26:52,800 --> 00:26:55,616 No you guys me have noticed that 437 00:26:55,872 --> 00:27:02,016 The attackbox is actually causing the playlist stock rate 438 00:27:02,272 --> 00:27:04,064 Stuck in various places 439 00:27:04,320 --> 00:27:06,624 That's because when a Collider 440 00:27:06,880 --> 00:27:08,160 Even though it's a Trigger 441 00:27:08,672 --> 00:27:11,232 Is a child of another Collider 442 00:27:11,488 --> 00:27:12,512 In this case 443 00:27:12,768 --> 00:27:14,816 Is the child of this capsule Collider here 444 00:27:15,840 --> 00:27:20,192 Double click here in June in this attack box 445 00:27:20,704 --> 00:27:23,776 Is actually because this capsulitis here 446 00:27:24,032 --> 00:27:26,848 It's been treated as another 447 00:27:27,360 --> 00:27:28,128 Collider 448 00:27:28,896 --> 00:27:35,040 You know it's still said to trigger is it just a weird idiosyncrasy with unity they're not gonna get too much detail about 449 00:27:35,552 --> 00:27:39,392 By the way that we fix this is just simply add a rigidbody 2D to it 450 00:27:40,672 --> 00:27:44,256 And then we're going to make that kinematic and all kinematic means is 451 00:27:44,768 --> 00:27:50,656 Exactly influenced by Gravity it's not good actually fall or move like a rigid body would 452 00:27:50,912 --> 00:27:54,240 Just going to be stable so I can remove it all 453 00:27:54,752 --> 00:27:58,080 And also that use for kinematic contact 454 00:27:58,336 --> 00:27:59,104 Is quite 455 00:27:59,616 --> 00:28:01,152 A little bit of a weird 456 00:28:01,664 --> 00:28:02,432 Problem 457 00:28:03,456 --> 00:28:06,272 Are you going to have but just had a rigid body 458 00:28:06,528 --> 00:28:08,064 Gearbox Coletta new speaker 459 00:28:09,088 --> 00:28:10,368 Tested out now 460 00:28:15,744 --> 00:28:17,536 Get stuck to things 461 00:28:18,304 --> 00:28:20,096 But I'm still going to get that triggering 462 00:28:20,864 --> 00:28:23,424 And I can kill you 463 00:28:23,680 --> 00:28:29,824 Are hydrate beautiful her just a beautiful too 464 00:28:30,080 --> 00:28:30,848 I'm up games 465 00:28:31,104 --> 00:28:34,944 Not yet that's ok though how are doing is getting the basics down 466 00:28:35,200 --> 00:28:36,736 To the concert skinning it later 467 00:28:37,504 --> 00:28:43,648 I want to do guys make sure you guys get this number right you just want to set the attack direction to something that 468 00:28:43,904 --> 00:28:47,232 Like so I would say .05 it's great for me 469 00:28:49,536 --> 00:28:51,072 A really quick Direction 470 00:28:51,840 --> 00:28:53,632 There we go that's perfect 471 00:28:56,192 --> 00:29:00,800 I know right perfect now there's plenty of things here guys that we could fix right 472 00:29:01,056 --> 00:29:07,200 We need to add a type of feedback to the player meaning if we get hurt we need to flash the screen if we 473 00:29:07,456 --> 00:29:10,016 Hurting enemy we need a flash that enemy 474 00:29:10,528 --> 00:29:16,672 Things that we need to do and we can talk about that in future videos 35358

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