All language subtitles for 004 Damaging the Player[UdemyIran.Com]

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 Download
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,140 --> 00:00:04,400 In the last couple of videos, we made a vitality component that can be used for both the enemies and 2 00:00:04,400 --> 00:00:07,220 the player, and we implemented damaging for the enemies. 3 00:00:07,220 --> 00:00:11,090 However, there is still no way for a player to take damage, so we're going to take care of that in 4 00:00:11,090 --> 00:00:11,900 this video. 5 00:00:11,930 --> 00:00:17,450 The first thing we want to do is that if we play, you can see that the crab is blocking us and we can 6 00:00:17,450 --> 00:00:18,380 jump on top of it. 7 00:00:18,410 --> 00:00:23,570 We want to change the collision between pawns to not be blocking, but to just be overlapping. 8 00:00:23,570 --> 00:00:28,910 And instead of blocking this, we then just want to add damage to the player if we touch each other. 9 00:00:29,210 --> 00:00:35,540 To do that, we go to the content, draw blueprints characters, and we use the BP action chart base 10 00:00:35,540 --> 00:00:39,140 because this affects both the players and the enemies. 11 00:00:39,590 --> 00:00:44,930 So we want to go to the capsule component because this is the one actually colliding. 12 00:00:44,930 --> 00:00:51,320 And here we can go down to the collision settings and we can see here the collision preset is --. 13 00:00:51,320 --> 00:00:52,490 We can open this up. 14 00:00:52,490 --> 00:00:56,360 And you can see that pawn and pawn are actually blocking each other. 15 00:00:56,630 --> 00:00:58,610 And we only have to change one simple thing. 16 00:00:58,610 --> 00:01:02,870 So I believe there is no need to make a separate channel and do all of those things. 17 00:01:02,870 --> 00:01:04,790 Again we did for the projectile here. 18 00:01:04,790 --> 00:01:05,390 I think it's fine. 19 00:01:05,390 --> 00:01:11,030 We just go to custom and we simply set the pawn from blocking to overlap. 20 00:01:11,030 --> 00:01:12,830 And that's all we're going to do here. 21 00:01:12,830 --> 00:01:17,090 If you want to manage it a little bit more cleanly, you could go and make another collision preset 22 00:01:17,090 --> 00:01:18,320 again if you wanted to. 23 00:01:18,320 --> 00:01:20,120 But this is so simple I think it's fine. 24 00:01:20,630 --> 00:01:26,180 So what happens now is that if we play well, we can just walk through each other, and now we want 25 00:01:26,180 --> 00:01:27,530 to listen to the event that happens. 26 00:01:27,530 --> 00:01:29,390 If the player overlaps with an enemy. 27 00:01:29,390 --> 00:01:34,340 And this is something we don't want to do in the action base, because this is only for the player, 28 00:01:34,340 --> 00:01:38,930 an enemy doesn't really need to know if it overlaps with another enemy, or if it overlaps with a player, 29 00:01:38,930 --> 00:01:40,790 because nothing is going to happen to it. 30 00:01:40,880 --> 00:01:44,030 So in this case, I think the player is the one who should be checking. 31 00:01:44,030 --> 00:01:44,900 Did I hit an enemy? 32 00:01:44,900 --> 00:01:47,150 And then it applies damage to itself. 33 00:01:47,150 --> 00:01:49,010 But again, this is just personal preference. 34 00:01:49,010 --> 00:01:52,910 You could also make it so all the enemies are always checking for the player and then apply damage to 35 00:01:52,910 --> 00:01:53,570 the player. 36 00:01:53,570 --> 00:01:58,310 However, then you have to check for this event on every single enemy all the time instead of just checking 37 00:01:58,310 --> 00:01:59,690 for it once on the player. 38 00:01:59,690 --> 00:02:05,090 So to do that, we just go to the content draw player and use the BP player. 39 00:02:05,090 --> 00:02:07,220 And yeah, make sure to not mix these up. 40 00:02:07,220 --> 00:02:11,870 We use the BP player and in the capsule component we scroll down. 41 00:02:11,870 --> 00:02:16,160 And of course you can see that our settings have been passed down, right. 42 00:02:16,160 --> 00:02:20,150 The pawn overlap has been passed down from the parent, the action char. 43 00:02:20,150 --> 00:02:25,910 And now at the bottom we want to look for the on component begin overlap event and add it here. 44 00:02:25,910 --> 00:02:30,200 And again just to demonstrate the first thing we can do just print string. 45 00:02:31,730 --> 00:02:33,350 Just to make sure that everything is working. 46 00:02:33,350 --> 00:02:36,950 It's like a sanity check and just print the other actor. 47 00:02:37,190 --> 00:02:37,850 Go in here. 48 00:02:37,850 --> 00:02:41,060 And yeah, you can see we detect the BP enemy crab. 49 00:02:41,980 --> 00:02:48,340 So in this case, we again want to make sure though that this doesn't trigger when we overlap with stage 50 00:02:48,340 --> 00:02:49,990 elements with other things. 51 00:02:49,990 --> 00:02:53,440 This should only happen if we overlap with an enemy. 52 00:02:53,440 --> 00:02:58,720 So other actor we can just cast to enemy base like this. 53 00:02:59,140 --> 00:03:02,200 And now this is not going to happen if we overlap with another player. 54 00:03:02,200 --> 00:03:06,910 In case you have a multiplayer game, for example, or if there's just like objects in the stage, right? 55 00:03:06,910 --> 00:03:11,830 So this is only going to execute if the overlapping actor is actually an enemy. 56 00:03:12,340 --> 00:03:14,260 And here we could also use the faction system. 57 00:03:14,260 --> 00:03:17,350 But to get access to the faction system we would have to cast anyway. 58 00:03:17,350 --> 00:03:19,510 So this is just a nicer shortcut. 59 00:03:20,350 --> 00:03:23,110 And then we can just apply damage to ourselves. 60 00:03:23,110 --> 00:03:25,510 So here just call apply damage. 61 00:03:26,460 --> 00:03:29,700 And for the damage actor, we just pass our self. 62 00:03:30,600 --> 00:03:34,470 Because right now we are in the player and we want to damage ourselves. 63 00:03:34,470 --> 00:03:39,750 If we detect we touched an enemy and for the base damage, let's just turn this into a variable, promote 64 00:03:39,750 --> 00:03:42,540 the variable and just call it overlap damage. 65 00:03:43,330 --> 00:03:46,270 And just put it here, compile and save. 66 00:03:46,270 --> 00:03:48,700 And we can now give it a default value. 67 00:03:48,700 --> 00:03:50,350 And I think one is fine. 68 00:03:50,350 --> 00:03:52,330 I think our character is going to have ten health. 69 00:03:52,330 --> 00:03:57,130 And if you touch another enemy it's going to take away one health bar from you. 70 00:03:58,950 --> 00:04:00,810 For the instigator, damage, cause or damage type. 71 00:04:00,810 --> 00:04:02,340 We don't really care about this now. 72 00:04:02,340 --> 00:04:03,870 Let's just see how this works. 73 00:04:04,140 --> 00:04:08,370 Go in here and you can see we get the damage flashing right. 74 00:04:08,370 --> 00:04:14,430 And if we take all of the damage because I think we have ten health, our character is going to disappear. 75 00:04:15,260 --> 00:04:20,000 And if you exit out now, you're gonna maybe know we actually don't get any error messages. 76 00:04:20,000 --> 00:04:23,660 But something that happens often is if you just destroy the player. 77 00:04:23,690 --> 00:04:27,860 Other things that are referencing the player and expecting at least one player to be active are going 78 00:04:27,860 --> 00:04:28,970 to throw error messages. 79 00:04:28,970 --> 00:04:32,330 So actually just destroying the player is not the best practice. 80 00:04:32,360 --> 00:04:37,820 We want to have a whole like respawn timer and have a delay in all of those things later on, but for 81 00:04:37,820 --> 00:04:38,810 now, this is fine. 82 00:04:39,200 --> 00:04:45,680 One more thing we want to do here, though, is that we want to make sure on the player that we don't 83 00:04:45,680 --> 00:04:46,820 just apply the damage. 84 00:04:46,820 --> 00:04:53,390 If we overlap with anything in the enemy, we actually want to make sure that we overlap with the capsule 85 00:04:53,390 --> 00:04:59,000 component, because later on, we're going to have the fly enemy who has another collision for the aggro 86 00:04:59,000 --> 00:04:59,390 range. 87 00:04:59,390 --> 00:05:01,880 So what happens if we don't add another check here? 88 00:05:01,880 --> 00:05:06,020 We're already going to start taking damage, even if we just overlap with the aggro range. 89 00:05:06,560 --> 00:05:08,900 And that is, of course, not what we want. 90 00:05:08,930 --> 00:05:15,620 So a simple way of doing this is that we actually we don't only check for the other actor, but we can 91 00:05:15,620 --> 00:05:17,330 also check for the other component. 92 00:05:17,330 --> 00:05:20,330 So let's just print this so you can see what this looks like. 93 00:05:20,330 --> 00:05:20,510 Right. 94 00:05:20,510 --> 00:05:21,680 So we can print string. 95 00:05:22,270 --> 00:05:30,340 Here other comp and you're going to see that it says well enemy grab collision cylinder which is the 96 00:05:30,340 --> 00:05:31,570 capsule collision. 97 00:05:32,020 --> 00:05:37,900 And what we can do here now is that we can check if the other comp equals, equals. 98 00:05:38,890 --> 00:05:43,990 And actually I want to plug this in down so we can hold control and change the order. 99 00:05:43,990 --> 00:05:47,380 And here I want to get the capsule component. 100 00:05:49,060 --> 00:05:54,280 And it should be all the way at the bottom and open up some space like this. 101 00:05:54,280 --> 00:06:00,760 So this way we check if the other component that we overlapped with is actually the capsule component 102 00:06:00,760 --> 00:06:06,640 on the enemy, or something else, and only in that case do we want to add a branch here. 103 00:06:08,260 --> 00:06:10,810 And continue the execution. 104 00:06:11,140 --> 00:06:16,120 So if we overlap with anything else in the enemy, we're not going to execute this. 105 00:06:16,150 --> 00:06:18,400 We're just going to stop here at false. 106 00:06:18,400 --> 00:06:23,140 And this is only going to happen if we overlap with the capsule component, which you can see here for 107 00:06:23,140 --> 00:06:23,770 the grab. 108 00:06:23,770 --> 00:06:26,020 And just to show you that this still works right. 109 00:06:26,020 --> 00:06:26,710 We take damage. 110 00:06:26,710 --> 00:06:27,340 It still works. 111 00:06:27,340 --> 00:06:28,210 It's all good. 112 00:06:29,900 --> 00:06:35,180 But we made this more future proof because we know other collisions might be inside of the character 113 00:06:35,180 --> 00:06:35,930 later on. 114 00:06:36,670 --> 00:06:41,980 And the next thing we have to do is that if we touch the enemy, we need to have some time where we 115 00:06:41,980 --> 00:06:42,880 are invincible. 116 00:06:42,880 --> 00:06:46,570 So you probably know from other games the thing where the sprite flashes. 117 00:06:46,570 --> 00:06:51,880 It lets you know that, hey, you cannot take damage right now and we need to implement this invincibility 118 00:06:51,880 --> 00:06:52,450 now. 119 00:06:53,110 --> 00:06:57,220 And another issue we have right now is that we can only take damage from the enemy once. 120 00:06:57,220 --> 00:07:02,260 If we don't walk outside here again, we're not going to trigger the on begin overlap event and we can 121 00:07:02,260 --> 00:07:03,970 just stand inside of the enemy. 122 00:07:03,970 --> 00:07:06,100 So let's actually take care of that first. 123 00:07:06,750 --> 00:07:13,320 In the player blueprint on the event graph, we are just gonna right click somewhere in open space and 124 00:07:13,320 --> 00:07:15,000 add a custom event. 125 00:07:16,850 --> 00:07:20,780 And we want to call this trigger invincibility. 126 00:07:26,070 --> 00:07:30,750 At this year, and the first thing you want to do is to get the capsule component of the player. 127 00:07:30,750 --> 00:07:35,700 And we want to set collision response to channel. 128 00:07:36,180 --> 00:07:40,140 We're still going to need the capsule to check for the floor and everything else. 129 00:07:40,140 --> 00:07:45,990 But after we take damage for a while, we want to disable the capsule when it comes to checking for 130 00:07:45,990 --> 00:07:52,950 other enemies for pawns, so we can just set the channel the pawn to ignore for now. 131 00:07:52,950 --> 00:07:56,490 And what this does is basically it goes into these settings. 132 00:07:56,490 --> 00:07:58,530 Here we have on the collision settings, right. 133 00:07:58,530 --> 00:08:03,090 And it's going to temporarily change this from overlap to ignore. 134 00:08:03,090 --> 00:08:08,460 Just we can do this inside of the blueprint instead of having to click here right like this. 135 00:08:09,640 --> 00:08:12,910 But we also now need to call this trigger invincibility. 136 00:08:12,910 --> 00:08:14,530 And when do we want to call it? 137 00:08:14,560 --> 00:08:18,130 Well, we do want to call it here when we apply the damage to ourselves, right? 138 00:08:18,130 --> 00:08:19,720 When we overlap with an enemy. 139 00:08:19,720 --> 00:08:23,740 But actually we want to trigger this whenever we take any damage. 140 00:08:23,740 --> 00:08:29,530 Because also if we get hit by a projectile, we then also want to not be able to hit enemies again, 141 00:08:29,530 --> 00:08:30,130 right? 142 00:08:30,130 --> 00:08:35,409 So the better way to call this is to actually implement the any damage now, which we're going to need 143 00:08:35,409 --> 00:08:35,860 right. 144 00:08:35,860 --> 00:08:37,510 The event any damage. 145 00:08:37,510 --> 00:08:41,590 And we can then trigger invincibility here from the any damage. 146 00:08:42,950 --> 00:08:44,660 And just doing it like this. 147 00:08:44,660 --> 00:08:47,540 There's going to be one issue which I'm going to show you, right? 148 00:08:47,540 --> 00:08:51,320 Because if I start now, actually, I cannot take damage at all anymore. 149 00:08:51,320 --> 00:08:54,740 And this is related to the whole thing with a parent and child, right? 150 00:08:54,740 --> 00:08:58,700 Because we are now overriding the any damage event on the parent. 151 00:08:58,700 --> 00:09:03,560 So actually what we need to do here, we've done it a couple of times is add call to parent function. 152 00:09:03,860 --> 00:09:04,250 Right. 153 00:09:04,250 --> 00:09:09,980 So we first want to call the whole damage thing on the parent and pass everything through here. 154 00:09:11,060 --> 00:09:14,120 And after that we want to trigger the invincibility. 155 00:09:14,120 --> 00:09:15,380 And now everything should work. 156 00:09:15,380 --> 00:09:17,630 If we compile, save, go in here, right. 157 00:09:17,630 --> 00:09:20,660 We take damage once and we can never take damage again. 158 00:09:20,660 --> 00:09:22,730 Because for now, we only turn it off. 159 00:09:22,730 --> 00:09:25,460 But after a while, we want to turn it on again. 160 00:09:26,050 --> 00:09:27,340 So this is the first step. 161 00:09:27,340 --> 00:09:28,390 It's working right. 162 00:09:28,390 --> 00:09:30,310 So on the trigger invincibility. 163 00:09:30,310 --> 00:09:32,410 Well we want to add a delay here. 164 00:09:32,410 --> 00:09:37,930 And again it's just safer to use a retrigger delay because this will actually reset if we call this 165 00:09:37,930 --> 00:09:39,010 multiple times. 166 00:09:39,710 --> 00:09:41,990 And yeah, let's just turn this into a variable. 167 00:09:41,990 --> 00:09:43,790 The invincibility duration. 168 00:09:43,790 --> 00:09:48,470 Promote variable invincibility duration. 169 00:09:49,130 --> 00:09:54,020 And for now we can just compile and save and just set it to 0.5 for now. 170 00:09:54,110 --> 00:09:56,240 We're gonna tweak this value a little bit later. 171 00:09:56,240 --> 00:09:59,480 But yeah, I think 0.5 is in the right ballpark. 172 00:09:59,480 --> 00:10:03,980 And now this we can just copy control C, control V paste it. 173 00:10:04,250 --> 00:10:09,410 And after 0.5 seconds we want to set the pawn response back to overlap. 174 00:10:09,410 --> 00:10:09,920 Right. 175 00:10:09,920 --> 00:10:11,390 So first we take damage. 176 00:10:11,390 --> 00:10:16,130 We turn off the checking for enemies and then we turn it on again. 177 00:10:18,020 --> 00:10:19,220 Let's try this out. 178 00:10:20,010 --> 00:10:24,000 So I can walk in, I take damage, I walk back, I take damage. 179 00:10:24,000 --> 00:10:24,870 So this is working. 180 00:10:24,870 --> 00:10:25,680 So what happens now? 181 00:10:25,680 --> 00:10:30,990 If I keep on standing inside of the enemy, I take damage and I keep on taking damage, which is what 182 00:10:30,990 --> 00:10:31,620 we want. 183 00:10:31,620 --> 00:10:35,490 Of course, later on we're going to have a knockback and other things. 184 00:10:35,490 --> 00:10:37,050 So this doesn't really happen. 185 00:10:37,050 --> 00:10:39,960 But in terms of mechanics, we want to have this. 186 00:10:39,960 --> 00:10:42,780 And yeah, so this is the thing I talked about with the errors. 187 00:10:42,780 --> 00:10:47,430 If you just delete the player and because you always need to be careful, something is probably running 188 00:10:47,430 --> 00:10:48,060 on the player. 189 00:10:48,060 --> 00:10:49,320 But for now this is fine. 190 00:10:49,320 --> 00:10:54,360 Later on we're going to put in a proper cooldown for respawning, and we're going to take care of these 191 00:10:54,360 --> 00:10:57,570 issues so we can just turn this off. 192 00:10:57,570 --> 00:10:59,910 And yes, so this is working right. 193 00:10:59,910 --> 00:11:02,550 So the invincibility itself is working. 194 00:11:02,550 --> 00:11:07,320 However, it's hard to see like when and how we are invincible because we still don't have the sprite 195 00:11:07,320 --> 00:11:08,760 flickering implemented. 196 00:11:09,270 --> 00:11:13,710 Now back in the player, we want to create a new function for the sprite flicker. 197 00:11:13,710 --> 00:11:18,600 So just add one and it's called toggle sprite flicker. 198 00:11:20,820 --> 00:11:21,780 I have a Big Al here. 199 00:11:21,780 --> 00:11:22,470 Sorry. 200 00:11:22,890 --> 00:11:23,250 Toggle. 201 00:11:23,250 --> 00:11:23,520 Sprite. 202 00:11:23,520 --> 00:11:24,150 Flicker. 203 00:11:25,590 --> 00:11:27,120 And doing this is very simple. 204 00:11:27,120 --> 00:11:31,950 All we have to do is actually just get the sprite, where is it the sprite. 205 00:11:31,950 --> 00:11:34,620 And there is something called visible. 206 00:11:34,620 --> 00:11:35,250 Yes. 207 00:11:35,250 --> 00:11:40,800 So we can simply just turn this on and off in the blueprint to show this sprite flickering. 208 00:11:41,690 --> 00:11:44,120 So back in the function Tog'l sprite flicker. 209 00:11:44,120 --> 00:11:48,830 In here we want to get the sprite and we set visible visibility. 210 00:11:48,830 --> 00:11:49,760 Actually sorry. 211 00:11:49,940 --> 00:11:53,870 And we want to set this to well what do we want to set this to. 212 00:11:53,870 --> 00:11:56,900 We want to set it to what it currently is not. 213 00:11:56,900 --> 00:12:00,020 So if it is visible we want to set it to invisible. 214 00:12:00,020 --> 00:12:02,930 If it is invisible, we want to set it to visible. 215 00:12:02,930 --> 00:12:08,450 So we can just again grab the sprite and we can get visibility. 216 00:12:09,740 --> 00:12:14,960 I get visible in this case and just use the not boolean. 217 00:12:16,030 --> 00:12:18,850 And this is basically just going to turn it into the opposite. 218 00:12:18,850 --> 00:12:19,420 Right. 219 00:12:19,420 --> 00:12:23,470 And if you have multiple sprites attached, maybe you want to use propagate to children. 220 00:12:23,470 --> 00:12:25,990 So the sprites that are below are also going to take this in. 221 00:12:25,990 --> 00:12:30,280 So yeah we can just turn this on even though we don't have any children in this case. 222 00:12:30,580 --> 00:12:32,770 And this is pretty much it. 223 00:12:32,770 --> 00:12:37,300 But we now need to call this at a certain interval and then turn it on, turn it off, turn it on, 224 00:12:37,300 --> 00:12:38,050 turn it off. 225 00:12:38,410 --> 00:12:47,110 So back in the event graph where we have the trigger invincibility right before the delay like here. 226 00:12:47,790 --> 00:12:50,940 We want to call timer. 227 00:12:51,240 --> 00:12:51,840 Sorry. 228 00:12:51,840 --> 00:12:53,520 Timer by event. 229 00:12:54,110 --> 00:12:56,750 Set timer by event like this. 230 00:12:56,750 --> 00:12:58,220 And the event. 231 00:12:58,780 --> 00:13:02,680 Just right event and it's gonna be create event. 232 00:13:02,800 --> 00:13:06,220 And this allows us to pick any function or any custom event. 233 00:13:06,220 --> 00:13:09,700 And here we just want to pick the toggle sprite flicker right. 234 00:13:09,700 --> 00:13:11,230 And can look for it. 235 00:13:11,230 --> 00:13:12,670 Toggle sprite flicker. 236 00:13:12,670 --> 00:13:16,030 If it doesn't show up you might have to compile and save like this. 237 00:13:16,030 --> 00:13:19,690 And this basically is just a node that helps us call this function. 238 00:13:19,690 --> 00:13:21,400 But with a timer. 239 00:13:21,400 --> 00:13:24,010 And we are able to loop it and do things like that. 240 00:13:25,830 --> 00:13:29,880 So first we want to open up a little more space here and we want to set the timer. 241 00:13:29,880 --> 00:13:33,180 So this is in what interval it's going to call this function. 242 00:13:33,180 --> 00:13:39,960 So also just turn this to a variable and just call it sprite flicker. 243 00:13:41,140 --> 00:13:42,160 Interval. 244 00:13:43,070 --> 00:13:47,510 And this is something I've been playing around with to compile, save and find the right value. 245 00:13:47,510 --> 00:13:54,500 And I think 0.12 is a value that looks nice and we want this to loop. 246 00:13:55,540 --> 00:13:56,560 Okay, let's try this out. 247 00:13:56,590 --> 00:13:58,690 Now compile save and let's check it out. 248 00:13:58,690 --> 00:13:59,200 Right. 249 00:13:59,200 --> 00:14:00,730 So it just keeps on flickering. 250 00:14:00,730 --> 00:14:03,340 This is looking nice but it doesn't stop. 251 00:14:03,340 --> 00:14:05,290 It just keeps on flickering forever. 252 00:14:05,470 --> 00:14:06,100 It doesn't matter. 253 00:14:06,100 --> 00:14:10,120 Like how many times we take damage, it just keeps on flickering, even if the invincibility is already 254 00:14:10,120 --> 00:14:10,690 over. 255 00:14:11,430 --> 00:14:18,450 So what we can do here is that after the invincibility duration, we want to cancel this event. 256 00:14:18,960 --> 00:14:20,430 And how can we cancel this? 257 00:14:20,430 --> 00:14:22,740 Well, we need to use the handle. 258 00:14:22,740 --> 00:14:26,640 So the timer creates a handle which we can then use to clear it. 259 00:14:26,640 --> 00:14:29,430 So here we could just call clear right. 260 00:14:29,430 --> 00:14:32,820 But well this is happening in a different timeline. 261 00:14:32,820 --> 00:14:36,210 So I actually want to save this in a variable as well. 262 00:14:36,210 --> 00:14:40,020 So we can promote the variable and just call it Flickr handle. 263 00:14:40,980 --> 00:14:42,270 And to save it here. 264 00:14:44,060 --> 00:14:50,270 And then after this is over, we can just get the Flickr handle and just call clear. 265 00:14:50,750 --> 00:14:52,100 Clear and invalidate. 266 00:14:52,100 --> 00:14:53,420 Timer by handle. 267 00:14:53,660 --> 00:14:54,830 That's a mouthful. 268 00:14:54,830 --> 00:14:55,550 But yeah. 269 00:14:55,550 --> 00:14:59,420 So this is going to work then like this. 270 00:14:59,840 --> 00:15:06,980 But yeah one problem you see now is that there is a chance that we stop flickering while we are invisible. 271 00:15:06,980 --> 00:15:09,140 So that is also something we have to do. 272 00:15:09,170 --> 00:15:12,830 So after this we always want to make sure that the sprite is visible. 273 00:15:12,830 --> 00:15:15,890 So we can just get the sprite set visibility. 274 00:15:15,890 --> 00:15:21,020 And just make sure after we clear the timer it just sets it back to visible one time. 275 00:15:21,020 --> 00:15:26,690 So there's no chance of us just being unlucky and landing on a frame where it is invisible. 276 00:15:26,720 --> 00:15:28,370 So here, now I can go in. 277 00:15:29,970 --> 00:15:34,890 But now this also shows us that 0.5 seconds is actually not enough of invincibility. 278 00:15:34,890 --> 00:15:41,790 So we can just go back to the player and look for our invincibility duration and set it to 1.5, make 279 00:15:41,790 --> 00:15:44,100 it a little bit longer and compile and save. 280 00:15:44,100 --> 00:15:45,330 And let's see this now. 281 00:15:45,750 --> 00:15:47,070 And yeah, this is more reasonable. 282 00:15:47,070 --> 00:15:48,630 It gives you more time to adapt. 283 00:15:48,630 --> 00:15:52,380 It shows the player some time to get out of the way and do things like that. 284 00:15:52,980 --> 00:15:55,170 And yeah, this is what I want. 285 00:15:56,350 --> 00:15:56,830 Now. 286 00:15:56,830 --> 00:16:02,410 There is one small bug though, which I introduced, and if we just keep on standing in here, we keep 287 00:16:02,410 --> 00:16:03,190 on taking damage. 288 00:16:03,190 --> 00:16:06,700 This is working fine, but the flicker is actually not showing up correctly. 289 00:16:06,700 --> 00:16:08,920 And there's a very easy fix for this. 290 00:16:09,700 --> 00:16:16,180 To see what's happening here is that we can just call a print string here after the right trigger invincibility, 291 00:16:16,180 --> 00:16:20,470 where we set the handle, just print, uh, print string. 292 00:16:21,450 --> 00:16:22,740 And just say. 293 00:16:24,810 --> 00:16:25,860 Start Flickr. 294 00:16:25,890 --> 00:16:27,360 Start Flickr. 295 00:16:28,980 --> 00:16:33,690 And then after here, where we clear the handle just to have another print string. 296 00:16:34,890 --> 00:16:36,900 And just call it clear. 297 00:16:36,900 --> 00:16:37,860 Flicker. 298 00:16:38,810 --> 00:16:39,920 And just compile and save. 299 00:16:39,920 --> 00:16:41,990 And now we can have a look what happens here. 300 00:16:41,990 --> 00:16:46,220 And you can see that we call Start Flickr, start Flickr and then clear Flickr. 301 00:16:47,470 --> 00:16:53,800 So we actually have an issue with the order in which we are calling these things, because we call start 302 00:16:53,800 --> 00:16:56,500 Flickr once and we save this handle. 303 00:16:56,500 --> 00:17:02,470 But then before we clear it, we take damage again and we call the second time, and then we actually 304 00:17:02,470 --> 00:17:05,260 cancel the second handle. 305 00:17:05,530 --> 00:17:10,240 So the way we can fix this is to, well, we can get rid of the print strings again because you saw 306 00:17:10,240 --> 00:17:11,079 what happens here. 307 00:17:11,079 --> 00:17:13,210 We just need to change the order here. 308 00:17:13,210 --> 00:17:19,720 So before we set the collision back and before we are able to take damage again, we want to clear the 309 00:17:19,720 --> 00:17:20,050 trigger. 310 00:17:20,050 --> 00:17:23,530 So we just cut this out control X and move this over here. 311 00:17:24,720 --> 00:17:27,450 And we can then drag this up here. 312 00:17:28,860 --> 00:17:29,640 Like this. 313 00:17:29,640 --> 00:17:36,390 And so what happens here is it makes sure that we clear the flicker timer before we allow taking damage 314 00:17:36,390 --> 00:17:36,630 again. 315 00:17:36,630 --> 00:17:40,500 So we cannot have this bug where we call things in the wrong order. 316 00:17:40,500 --> 00:17:45,660 And now even if we just stand in the enemy, we keep on getting damaged and we keep on flickering. 317 00:17:45,660 --> 00:17:46,890 So this is working fine now. 318 00:17:46,890 --> 00:17:52,200 Just a small bug I found right now, but I think this was a good example of how you would go about debugging 319 00:17:52,200 --> 00:17:53,820 something like this with print strings. 320 00:17:54,210 --> 00:17:57,720 Of course, it usually doesn't happen that you just keep on standing in the enemy, but in the next 321 00:17:57,720 --> 00:18:00,030 video we're going to implement a knockback and stun. 322 00:18:00,030 --> 00:18:03,240 So what could happen is that one enemy knocks you into the other enemy. 323 00:18:03,240 --> 00:18:06,990 And that's the reason why we just took care of this flickering issue to make sure that it wouldn't cause 324 00:18:06,990 --> 00:18:08,190 problems in that case. 30112

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