All language subtitles for 26. Adding Player Health

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 Download
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
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:00,256 --> 00:00:03,584 One major thing that are lacking in our game is player health 2 00:00:03,840 --> 00:00:06,912 Currently the player has no way to take damage in no way 3 00:00:07,424 --> 00:00:07,936 Die 4 00:00:08,192 --> 00:00:09,728 Salt we're going to get started 5 00:00:09,984 --> 00:00:11,008 Implementing that 6 00:00:11,264 --> 00:00:12,800 In this life 7 00:00:13,312 --> 00:00:13,824 So 8 00:00:14,080 --> 00:00:15,360 We already have 9 00:00:15,872 --> 00:00:16,640 Health composed 10 00:00:16,896 --> 00:00:20,224 And remember how I said we designed it in a way that we can read 11 00:00:20,480 --> 00:00:20,992 Set the cross 12 00:00:21,248 --> 00:00:22,016 Odyssey 13 00:00:22,784 --> 00:00:26,112 So that's exactly what we're going to do so go ahead and open up your players 14 00:00:26,368 --> 00:00:29,696 By clicking me open in editor button from the main scene 15 00:00:29,952 --> 00:00:32,000 Let's go ahead and then stands in Uno 16 00:00:32,256 --> 00:00:33,024 With control 17 00:00:34,048 --> 00:00:34,816 Search for health 18 00:00:35,072 --> 00:00:35,584 Composer 19 00:00:35,840 --> 00:00:37,888 And that and then we'll move it 20 00:00:38,400 --> 00:00:39,424 Above the above 21 00:00:40,192 --> 00:00:45,824 Tell component how much health 312 player to have well this is going to be largely up to you and how you 22 00:00:46,336 --> 00:00:48,896 But I guess I will just leave it 23 00:00:49,152 --> 00:00:49,920 10 for now 24 00:00:50,176 --> 00:00:51,200 And then we'll see you how 25 00:00:51,456 --> 00:00:51,968 Hatfield 26 00:00:52,480 --> 00:00:53,760 Ok so that's simple enough 27 00:00:54,016 --> 00:00:55,552 The problem is we need to be a 28 00:00:55,808 --> 00:00:57,088 How to change the health 29 00:00:57,344 --> 00:00:58,368 When the player come 30 00:00:58,624 --> 00:00:59,136 Collision 31 00:00:59,392 --> 00:01:00,141 With an n 32 00:01:00,143 --> 00:01:02,619 Subtitled by online-courses.club We compress knowledge for you! 33 00:01:02,620 --> 00:01:01,952 And how are we going to do that 34 00:01:02,208 --> 00:01:06,304 I'm gonna do is we're going to create another area 2D 35 00:01:06,816 --> 00:01:09,376 In addition to the area to do that we have here 36 00:01:09,632 --> 00:01:12,704 Dad is going to be able to detect enemies enter 37 00:01:13,216 --> 00:01:13,984 The player 38 00:01:14,496 --> 00:01:16,288 Animal use that as the base 39 00:01:16,800 --> 00:01:17,568 Dl10 40 00:01:17,824 --> 00:01:18,336 Switch to the player 41 00:01:18,592 --> 00:01:22,176 So let's go ahead and rename this existing area too 42 00:01:22,688 --> 00:01:23,712 To pick up area 43 00:01:24,480 --> 00:01:24,992 To Dean 44 00:01:27,040 --> 00:01:28,832 So that it better describes what this is 45 00:01:29,600 --> 00:01:32,160 Purposes animal create another node on 46 00:01:32,416 --> 00:01:34,720 Can you search of type area2d 47 00:01:34,976 --> 00:01:37,792 And we'll go ahead and move it just under the pick-up area 48 00:01:38,048 --> 00:01:40,352 What's this collision area 49 00:01:40,608 --> 00:01:41,120 2D 50 00:01:42,656 --> 00:01:44,704 And I'm going to go ahead and add a child node 51 00:01:45,728 --> 00:01:46,496 Colours and shapes 52 00:01:46,752 --> 00:01:47,264 Utilita 53 00:01:47,776 --> 00:01:49,568 Let's go down to the ship resource 54 00:01:50,336 --> 00:01:52,128 And create a new 55 00:01:52,384 --> 00:01:53,152 Circle shape 56 00:01:53,408 --> 00:01:57,248 And it looks like we can turn this down to about 57 00:01:57,760 --> 00:01:58,784 Which roughly 58 00:01:59,040 --> 00:02:00,832 Matches the player size 59 00:02:01,088 --> 00:02:05,952 And then select the collision area to DW on the keyboard for the move tool 60 00:02:06,208 --> 00:02:07,488 And we're just going to move 61 00:02:08,512 --> 00:02:10,304 To roughly be centred around 62 00:02:10,560 --> 00:02:11,072 The player 63 00:02:11,328 --> 00:02:17,216 I think that looks ok what I am going to do is I'm going to go back to the collision shape to the underneath 64 00:02:17,984 --> 00:02:20,032 Change the radius to something like said 65 00:02:20,544 --> 00:02:22,592 Remember it's not necessarily a bad thing 66 00:02:22,848 --> 00:02:25,920 Going to have your collision area by a little bit smaller 67 00:02:26,944 --> 00:02:29,760 And if you want to see this letter you can read the collision area 2D 68 00:02:30,016 --> 00:02:32,576 Above the Sprite just so we can get an idea 69 00:02:33,088 --> 00:02:34,368 How dad's look 70 00:02:34,624 --> 00:02:35,392 Can I take it 71 00:02:35,904 --> 00:02:36,416 Fine 72 00:02:36,672 --> 00:02:37,184 Ok 73 00:02:37,440 --> 00:02:37,952 So 74 00:02:38,208 --> 00:02:40,000 What's going on open up the place Crewe 75 00:02:40,256 --> 00:02:42,048 And we want to 76 00:02:42,304 --> 00:02:44,352 Detect when an enemy enters a collision 77 00:02:45,120 --> 00:02:45,632 So 78 00:02:45,888 --> 00:02:46,400 What 79 00:02:46,656 --> 00:02:47,424 Do we need 80 00:02:47,680 --> 00:02:48,192 To do 81 00:02:48,448 --> 00:02:51,776 We need to configure the collision layer in the collision mask of the 82 00:02:52,032 --> 00:02:52,544 An area 83 00:02:52,800 --> 00:02:53,312 To be able 84 00:02:53,568 --> 00:02:54,336 You detect enemy 85 00:02:54,848 --> 00:02:55,616 Stop 86 00:02:55,872 --> 00:02:56,896 Scroll down 87 00:02:57,152 --> 00:02:58,944 With collision area2d selected 88 00:02:59,200 --> 00:03:00,224 And we were 89 00:03:00,480 --> 00:03:03,040 To make this not exist on any layer 90 00:03:03,296 --> 00:03:05,856 And we wanted to look for collisions with me 91 00:03:06,112 --> 00:03:06,880 Me and looking at 92 00:03:07,904 --> 00:03:12,768 So central going to be doing is let me open up of the basic anime scene Justice 93 00:03:13,280 --> 00:03:13,792 I'm going to 94 00:03:14,048 --> 00:03:14,560 Turn the TV mode 95 00:03:14,816 --> 00:03:17,632 So what we can figure it out our collision area to the 96 00:03:18,144 --> 00:03:18,912 To look for it 97 00:03:19,168 --> 00:03:23,264 Player seen is we're looking at centrally for this collision shape 98 00:03:23,520 --> 00:03:24,032 Of the 99 00:03:24,288 --> 00:03:25,568 So the small one 100 00:03:25,824 --> 00:03:26,336 The inside 101 00:03:26,592 --> 00:03:27,104 And why is 102 00:03:27,360 --> 00:03:28,640 Because the basic enemy 103 00:03:29,920 --> 00:03:35,552 Actually this basic enemy exist on the enemy collision layer so this is the this so I'm going 104 00:03:35,808 --> 00:03:36,320 His Highness 105 00:03:36,576 --> 00:03:37,344 Hide the hurt 106 00:03:37,600 --> 00:03:40,672 Components of this blue circle right here is the thing that we wanted to 107 00:03:41,184 --> 00:03:44,512 So is actually incorrect that's not the enemy layer 108 00:03:44,768 --> 00:03:45,536 That is 109 00:03:45,792 --> 00:03:46,304 The 110 00:03:46,560 --> 00:03:48,096 Enemy collision 111 00:03:48,352 --> 00:03:49,888 So we want to look for enemy 112 00:03:50,144 --> 00:03:50,656 Collision 113 00:03:50,912 --> 00:03:51,424 Instead 114 00:03:51,680 --> 00:03:53,472 So I'm gonna go back to my player 115 00:03:53,728 --> 00:03:55,264 The collision area 2D 116 00:03:55,520 --> 00:03:56,288 Change the mass 117 00:03:56,544 --> 00:03:57,056 From 118 00:03:57,312 --> 00:03:58,080 Two enemy collision 119 00:03:58,592 --> 00:04:03,200 That's going to be looking for the smaller area the same collision shape that the enemy uses for 120 00:04:03,456 --> 00:04:04,736 Collisions against the train 121 00:04:04,992 --> 00:04:05,504 Ok 122 00:04:05,760 --> 00:04:08,320 Now the thing about the basic enemy 123 00:04:08,576 --> 00:04:10,880 And as listening to that end 124 00:04:11,136 --> 00:04:12,160 Collision layer 125 00:04:12,416 --> 00:04:14,464 Collisions is that this is actually 126 00:04:14,720 --> 00:04:15,232 Type 127 00:04:15,488 --> 00:04:16,256 Barry 128 00:04:16,512 --> 00:04:17,280 Instead of 129 00:04:18,303 --> 00:04:19,583 So this is a body to do 130 00:04:19,839 --> 00:04:21,119 Another area to 131 00:04:21,375 --> 00:04:25,215 And so we're going to have to use a slightly different signal in our area 132 00:04:25,471 --> 00:04:26,239 Detection 133 00:04:26,495 --> 00:04:27,263 In the playlist 134 00:04:27,775 --> 00:04:30,847 Gutter collision area today let's go and open up the playlist 135 00:04:31,359 --> 00:04:34,943 And what we want to do in the ready metal that's removed this past line 136 00:04:35,455 --> 00:04:37,759 And Wilder in here let's go ahead and remove 137 00:04:38,015 --> 00:04:40,063 The comments as well because we 138 00:04:42,111 --> 00:04:43,391 So we're going to 139 00:04:43,647 --> 00:04:45,183 Collision area2d 140 00:04:45,695 --> 00:04:47,999 A reference that with the dollar sign shortcut 141 00:04:48,255 --> 00:04:50,303 Then we're going to say body and 142 00:04:51,071 --> 00:04:53,887 So she had a different an area entered which we've been using 143 00:04:54,143 --> 00:04:55,167 Previously 144 00:04:55,423 --> 00:04:56,959 Because we're going to be listening for thing 145 00:04:57,215 --> 00:04:59,007 That have expired 146 00:05:00,031 --> 00:05:01,311 And we're going to connect 147 00:05:02,079 --> 00:05:03,615 On Barry 148 00:05:05,919 --> 00:05:08,223 And let's Create that function at the bar 149 00:05:08,479 --> 00:05:09,759 On body enter 150 00:05:10,015 --> 00:05:12,319 And by the way you'll notice that we are 151 00:05:12,575 --> 00:05:15,135 Putting all of the signal functions at the bottom 152 00:05:15,391 --> 00:05:16,927 That's just personally how I like 153 00:05:17,183 --> 00:05:18,975 To organise the code 154 00:05:19,487 --> 00:05:21,791 To put all the Single functions at the bottom and prefix 155 00:05:22,047 --> 00:05:22,559 Was on 156 00:05:22,815 --> 00:05:23,583 Underscore 157 00:05:23,839 --> 00:05:25,631 So it's very clear that these are sick 158 00:05:26,655 --> 00:05:28,959 And let's go hence like the Cleveland area to 159 00:05:29,215 --> 00:05:30,239 In our 160 00:05:30,495 --> 00:05:34,847 Seen here and we're going to go to the notepad to look at the singer 161 00:05:35,103 --> 00:05:35,871 We can see the 162 00:05:36,127 --> 00:05:39,455 We have Barry entered and body Exeter Sid 163 00:05:39,967 --> 00:05:44,831 And the body that's coming in is a no too deep so let's go ahead and say 164 00:05:45,343 --> 00:05:46,111 Other body 165 00:05:46,879 --> 00:05:48,415 And that subtype notary 166 00:05:48,927 --> 00:05:50,463 Corn at the end and then pass 167 00:05:50,719 --> 00:05:55,583 Before we go any further how do we want to play that actually take damage with the thing that I'm in Vision 168 00:05:55,839 --> 00:05:56,351 Is that 169 00:05:56,607 --> 00:05:58,143 The player will take damage 170 00:05:58,655 --> 00:05:59,423 While 171 00:05:59,679 --> 00:06:01,471 There is an enemy colliding with 172 00:06:02,239 --> 00:06:03,519 So what needs to happen 173 00:06:03,775 --> 00:06:06,847 We need to listen for a body and turn signal 174 00:06:07,103 --> 00:06:08,127 We need to 175 00:06:08,383 --> 00:06:09,151 Doodle 176 00:06:09,407 --> 00:06:12,479 Periodically while a body is inside of the play 177 00:06:12,735 --> 00:06:16,575 Right so we don't want to damage every frame because I would be unfair the player died in 178 00:06:17,087 --> 00:06:18,879 So I'm thinking every 179 00:06:19,135 --> 00:06:20,159 A second or so 180 00:06:20,415 --> 00:06:21,951 While there is an enemy 181 00:06:22,207 --> 00:06:23,231 Colliding with the 182 00:06:23,487 --> 00:06:24,767 We deal 183 00:06:25,279 --> 00:06:29,119 So what we need to do to achieve that is we need to listen for body enter 184 00:06:29,375 --> 00:06:31,167 But also body exit 185 00:06:31,679 --> 00:06:33,215 And we need to make sure that it work 186 00:06:33,727 --> 00:06:36,543 With multiple bodies so imagine the situation 187 00:06:36,799 --> 00:06:39,615 For all collide with the player at the same time 188 00:06:40,127 --> 00:06:45,503 We are going to want to listen for those but we don't want to multiply the damage the player is taken by 4 189 00:06:45,759 --> 00:06:48,319 We just want to say all the players taking down 190 00:06:48,831 --> 00:06:49,855 When those bars 191 00:06:50,111 --> 00:06:55,487 Exit the player or when one body except the player we still want to keep doing damage because they're still three other body 192 00:06:55,743 --> 00:06:57,023 On a plate does that makes 193 00:06:57,535 --> 00:07:03,679 So I sent you all we need to do is we need to keep track of the number of bodies that are colliding with the player and as long as they 194 00:07:03,935 --> 00:07:07,519 Number of bodies are greater than 0 we need a periodic Lindale Dam 195 00:07:08,799 --> 00:07:10,847 And Simon show you how we can accomplish 196 00:07:11,359 --> 00:07:11,871 So 197 00:07:12,127 --> 00:07:15,199 As I mention we're going to need a listen for body exited as well 198 00:07:15,455 --> 00:07:17,247 Time is going to duplicate this line 199 00:07:17,503 --> 00:07:18,783 By copying pasting 200 00:07:19,039 --> 00:07:20,831 And I'm going to change this to buddy x 201 00:07:21,343 --> 00:07:24,671 And we are going to change this connector method to on 202 00:07:24,927 --> 00:07:25,439 The Exeter 203 00:07:27,999 --> 00:07:29,023 Create a new function to buy 204 00:07:31,583 --> 00:07:33,119 On body X-ray 205 00:07:34,911 --> 00:07:37,471 Again looking at our no return over here 206 00:07:37,727 --> 00:07:38,239 That 207 00:07:38,495 --> 00:07:42,079 Passes in a body argument as well so we'll just say other bar 208 00:07:42,335 --> 00:07:42,847 Note 209 00:07:44,127 --> 00:07:45,151 I'm alright pass 210 00:07:46,175 --> 00:07:48,735 Set the top of a player script create a variable 211 00:07:48,991 --> 00:07:51,295 I'm gonna call this number 212 00:07:51,551 --> 00:07:52,063 Barry 213 00:07:52,319 --> 00:07:53,087 Is equal to 214 00:07:54,367 --> 00:07:55,903 Ok on body enter 215 00:07:56,159 --> 00:07:57,951 We're going to get rid of this pass line 216 00:07:58,207 --> 00:08:01,279 Do number colliding bodies + = 1 217 00:08:01,791 --> 00:08:04,351 And then on body excellent working to do - 218 00:08:04,607 --> 00:08:06,399 Colliding bodies 219 00:08:06,655 --> 00:08:07,167 Equals 220 00:08:08,191 --> 00:08:09,727 Now we need to 221 00:08:09,983 --> 00:08:12,031 Deal damage to the player periodic 222 00:08:12,543 --> 00:08:15,103 Let's create a timer on 223 00:08:15,359 --> 00:08:16,895 The players and child node 224 00:08:17,151 --> 00:08:17,663 Timer 225 00:08:18,943 --> 00:08:20,735 Guide and drag that up above 226 00:08:20,991 --> 00:08:21,759 Pick up area two 227 00:08:23,039 --> 00:08:25,087 Call this damage interview 228 00:08:25,343 --> 00:08:25,855 Timer 229 00:08:27,903 --> 00:08:29,183 Let's go to the inspector 230 00:08:29,695 --> 00:08:31,487 I'm going to change this wait time to 231 00:08:33,023 --> 00:08:34,815 Return to One Show 232 00:08:35,071 --> 00:08:36,351 Never Gonna Leave artist 233 00:08:36,607 --> 00:08:37,119 Off 234 00:08:37,887 --> 00:08:40,447 So what we need to do when the body is entering 235 00:08:40,703 --> 00:08:41,983 Is we need to 236 00:08:42,239 --> 00:08:43,007 Deal damage 237 00:08:43,519 --> 00:08:46,591 So what I'm going to do is I'm going to write a new function called 238 00:08:47,103 --> 00:08:47,615 Check 239 00:08:48,127 --> 00:08:49,151 Deal damage 240 00:08:49,407 --> 00:08:50,175 Something like 241 00:08:50,943 --> 00:08:54,271 And what I'm going to do in here I'm going to say if number 242 00:08:54,527 --> 00:08:56,063 Colliding bodies is equal to 0 243 00:08:56,319 --> 00:08:59,903 Where is gonna return so we're not going to do anything if there's currently no colliding body 244 00:09:00,159 --> 00:09:01,695 Otherwise what we're gonna do 245 00:09:01,951 --> 00:09:03,231 Is we are going to 246 00:09:03,743 --> 00:09:04,767 Deal damage to the player 247 00:09:05,023 --> 00:09:07,327 So what we're going to do is reference the health component 248 00:09:07,583 --> 00:09:09,375 And then we're going to do dot damage 249 00:09:09,631 --> 00:09:12,447 We don't have this type so we're not going to get any 250 00:09:12,959 --> 00:09:16,287 But if you need to see what the health components methods are even is open 251 00:09:16,543 --> 00:09:18,591 Add script and you can see that we have a damage 252 00:09:18,847 --> 00:09:20,639 Function right here was damaging 253 00:09:21,151 --> 00:09:24,991 So I'm just going to go back to the play script and I'm just going to deal 1 damage 254 00:09:25,503 --> 00:09:29,343 Then what's going to happen is I'm going to reference the damage interval time 255 00:09:29,855 --> 00:09:31,647 With dollar sign damage in triple time 256 00:09:31,903 --> 00:09:32,671 And 257 00:09:32,927 --> 00:09:34,207 I'm going to start 258 00:09:35,487 --> 00:09:38,815 So there's a couple of things so basically we want this to deal damage 259 00:09:39,071 --> 00:09:40,351 When the number of Llandudno 260 00:09:40,607 --> 00:09:41,375 0 261 00:09:41,631 --> 00:09:45,983 We also want it to only deal damage if the damaged interval timer is stop 262 00:09:46,239 --> 00:09:49,567 So let's get a reference for this damage in trouble timer so we don't have to 263 00:09:50,079 --> 00:09:51,615 Using the star sign notation 264 00:09:51,871 --> 00:09:54,175 I'm gonna go to the top of my script 265 00:09:54,687 --> 00:09:56,479 I'm going to write on red 266 00:09:56,735 --> 00:09:57,247 Via 267 00:09:57,759 --> 00:09:59,551 Damage underscore interval 268 00:10:00,345 --> 00:10:02,504 Subtitled by online-courses.club We compress knowledge for you! 269 00:10:02,505 --> 00:10:02,367 Underscore timer is equal to 270 00:10:02,879 --> 00:10:03,903 Damage internal time 271 00:10:04,159 --> 00:10:04,927 And again 272 00:10:05,183 --> 00:10:05,951 This means that 273 00:10:06,207 --> 00:10:10,047 When were sewing missing in a variable we don't have to go to the same tree 274 00:10:10,559 --> 00:10:12,095 To get that node every time 275 00:10:12,351 --> 00:10:13,375 Just a little bit more can 276 00:10:14,399 --> 00:10:15,423 Mirena replaced 277 00:10:15,679 --> 00:10:17,983 Dollar sign damaged interval timer with Arnie 278 00:10:18,239 --> 00:10:22,847 Variable and then in the top here if number of colliding bodies is equal to 0 279 00:10:23,103 --> 00:10:23,871 Or 280 00:10:24,127 --> 00:10:25,919 So that's 2 pipes for the or 281 00:10:26,175 --> 00:10:26,943 Damage 282 00:10:27,199 --> 00:10:28,223 Interval timer 283 00:10:28,479 --> 00:10:30,527 Is stop and we actually want to 284 00:10:30,783 --> 00:10:31,295 What's this tune 285 00:10:31,551 --> 00:10:33,343 Stop which basically means 286 00:10:33,599 --> 00:10:39,743 If our number of claim bodies is 0 or H damage interval timer is running them 287 00:10:39,999 --> 00:10:44,607 Because we don't want to deal damage while the timer is still running that's basically just a graze 288 00:10:45,119 --> 00:10:46,655 Which the player count 289 00:10:47,167 --> 00:10:50,495 Sauna on body enter what we want to do is we want to call 290 00:10:50,751 --> 00:10:51,263 Deals 291 00:10:52,543 --> 00:10:53,567 Now the problem here 292 00:10:54,079 --> 00:10:56,383 Is that we're only calling this now 293 00:10:56,895 --> 00:10:57,407 When 294 00:10:57,663 --> 00:10:58,943 An enemy enter 295 00:10:59,199 --> 00:11:00,223 The play area 296 00:11:00,735 --> 00:11:04,319 But what happens if that enemy is on top of the player 297 00:11:04,831 --> 00:11:06,623 4 more than half a second 298 00:11:06,879 --> 00:11:09,951 There's nothing that tells this to be called again 299 00:11:10,207 --> 00:11:13,535 And so what we're going to do is we actually going to call this function 300 00:11:13,791 --> 00:11:15,583 When the damage interval timer 301 00:11:15,839 --> 00:11:16,607 Times out 302 00:11:17,119 --> 00:11:18,655 Let's go back up to are ready 303 00:11:18,911 --> 00:11:19,423 Function 304 00:11:19,679 --> 00:11:21,471 And we're going to say dammit 305 00:11:21,727 --> 00:11:22,495 Interval timer 306 00:11:22,751 --> 00:11:23,775 Time out 307 00:11:24,031 --> 00:11:25,055 Dartconnect 308 00:11:25,823 --> 00:11:28,383 Water coolers on damage interval 309 00:11:28,895 --> 00:11:29,407 Timer 310 00:11:29,663 --> 00:11:30,175 Time out 311 00:11:30,431 --> 00:11:31,199 Your notice 312 00:11:31,455 --> 00:11:34,271 That's rather cause I'm being very verbal 313 00:11:34,783 --> 00:11:36,063 In my function name 314 00:11:36,575 --> 00:11:38,623 And why is that because it's just 315 00:11:38,879 --> 00:11:39,903 Easier to read 316 00:11:40,159 --> 00:11:42,719 More descriptive variable names and 317 00:11:43,231 --> 00:11:43,743 Functioning 318 00:11:44,255 --> 00:11:46,303 So how include you do the same 319 00:11:46,559 --> 00:11:48,863 You can go to any piece of old code 320 00:11:49,119 --> 00:11:50,655 As your building out your game 321 00:11:50,911 --> 00:11:54,239 As long as you using descriptive variable names and function name 322 00:11:54,495 --> 00:11:57,567 You're going to have an easy time wrapping your head around 323 00:11:57,823 --> 00:11:58,591 What the code is doing 324 00:11:58,847 --> 00:12:00,127 If you haven't seen it for a while 325 00:12:00,383 --> 00:12:02,431 So I'm going to create that function at the bottom 326 00:12:02,687 --> 00:12:03,199 On 327 00:12:03,455 --> 00:12:05,503 What was it called on damage introvert 328 00:12:06,271 --> 00:12:07,039 Timer time 329 00:12:08,831 --> 00:12:09,855 And what are we going to do 330 00:12:10,111 --> 00:12:10,879 In this function 331 00:12:11,135 --> 00:12:11,903 We're going to rain 332 00:12:12,415 --> 00:12:13,695 Check deal damage 333 00:12:13,951 --> 00:12:17,023 Now you could just put cheque deal damage 334 00:12:17,279 --> 00:12:17,791 Here 335 00:12:18,047 --> 00:12:19,327 As the signal connection 336 00:12:19,583 --> 00:12:22,399 But again I don't like to do that I like to have a 337 00:12:22,655 --> 00:12:24,703 Function explicitly handles the signal 338 00:12:24,959 --> 00:12:25,727 Omission 339 00:12:25,983 --> 00:12:28,031 It just seems to make more sense 340 00:12:28,543 --> 00:12:29,055 To me 341 00:12:29,311 --> 00:12:31,359 So when the timer runs out you're going 342 00:12:31,615 --> 00:12:33,663 Calling check deal damage again 343 00:12:33,919 --> 00:12:36,735 So that means that as long as there is an enemy 344 00:12:37,759 --> 00:12:38,271 The player 345 00:12:38,527 --> 00:12:41,087 Check deal damage is going to keep being cold 346 00:12:41,343 --> 00:12:42,367 Every have a 347 00:12:42,879 --> 00:12:44,159 Tell me some cities in 348 00:12:44,671 --> 00:12:45,439 So let's say that 349 00:12:45,695 --> 00:12:50,559 The damage interval timer is at .4 seconds and is running but the enemy exit 350 00:12:50,815 --> 00:12:52,607 When is timer countdown 351 00:12:53,119 --> 00:12:53,887 What's going to happen 352 00:12:54,143 --> 00:12:58,495 It's going to see that all there's no more colliding bodies so we just 353 00:12:59,263 --> 00:13:01,823 So we've got the appropriate safety is in place so when I go 354 00:13:02,079 --> 00:13:03,615 We doing erroneous data 355 00:13:04,127 --> 00:13:04,639 To the 356 00:13:05,151 --> 00:13:06,687 Alright and then the last thing to do 357 00:13:06,943 --> 00:13:10,271 Is 2 let's just print for debug purposes the player 358 00:13:10,527 --> 00:13:11,551 So print 359 00:13:11,807 --> 00:13:13,343 Dollar sign health component 360 00:13:14,367 --> 00:13:16,671 And let's go back to the health components 361 00:13:17,183 --> 00:13:18,207 I've got current 362 00:13:18,463 --> 00:13:19,743 So we can reference that 363 00:13:19,999 --> 00:13:21,791 By simply just doing current 364 00:13:22,047 --> 00:13:22,559 Underscore 365 00:13:23,583 --> 00:13:25,887 Toilet seat for work so I'm Gonna Run the game 366 00:13:26,143 --> 00:13:29,471 I'm just going to shrink the window so I can see my output console at the bar 367 00:13:31,007 --> 00:13:33,055 We see 987 368 00:13:33,311 --> 00:13:33,823 X5 369 00:13:34,079 --> 00:13:35,871 So yeah that is counting down appropriate 370 00:13:36,383 --> 00:13:39,711 Hello that are player even gets freed from the scene 371 00:13:39,967 --> 00:13:40,479 When 372 00:13:40,735 --> 00:13:41,759 Selfridges 373 00:13:42,015 --> 00:13:46,367 And you can see that the fruit of our defensive programming have worked because 374 00:13:46,623 --> 00:13:50,975 Despite the fact that there's no player in the scene anymore because he got q-free 375 00:13:51,231 --> 00:13:56,351 Are Games still running in housing crash and we have no errors in the console why because we were taking care 376 00:13:56,607 --> 00:14:01,471 To make sure that we are checking the validity of the player that we were referencing 377 00:14:01,727 --> 00:14:05,055 And so the enemies they don't have a target to move through so they just 378 00:14:05,311 --> 00:14:06,847 The camera is just 379 00:14:07,103 --> 00:14:08,127 The timer is still going 380 00:14:08,383 --> 00:14:11,455 So that's all that's very good demonstration of the benefits of 381 00:14:11,967 --> 00:14:12,735 Defensive Pro 382 00:14:13,247 --> 00:14:15,551 Alright so we've got basic hair 383 00:14:16,063 --> 00:14:17,855 Damage logic in 384 00:14:18,111 --> 00:14:18,623 For the player 385 00:14:18,879 --> 00:14:22,463 And the next step is to make it visible on screen 25689

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