All language subtitles for 003 Damage Flash Material[UdemyIran.Com]

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian Download
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,170 --> 00:00:04,040 Our damaged system is working now, but it is really hard to tell if we actually hit somebody. 2 00:00:04,040 --> 00:00:07,400 So we want to implement a material flash if we hit an enemy. 3 00:00:07,430 --> 00:00:12,320 I would love to show you some examples of the many games that use this, but I don't think I can share 4 00:00:12,320 --> 00:00:14,900 gameplay footage on this site due to copyright reasons. 5 00:00:14,930 --> 00:00:19,370 I'll attach a YouTube video to this lecture where I show off some examples and also go into more detail, 6 00:00:19,370 --> 00:00:21,110 so please feel free to check it out. 7 00:00:21,110 --> 00:00:22,280 Like I said last time. 8 00:00:22,310 --> 00:00:28,010 One approach to make it readable that we hit an enemy would be a hit animation or a hurt animation. 9 00:00:28,010 --> 00:00:35,300 And if we look at the paper assets for the player, the player, we actually have a hurt animation. 10 00:00:35,360 --> 00:00:36,230 Where is it? 11 00:00:36,850 --> 00:00:37,390 This one. 12 00:00:37,390 --> 00:00:37,750 Right? 13 00:00:37,750 --> 00:00:40,540 So we actually have a special animation for being hurt. 14 00:00:40,540 --> 00:00:43,990 And this is good for readability because it easily tells us that we took damage. 15 00:00:43,990 --> 00:00:48,910 However, in many cases for enemies you won't have hurt animations because the artist didn't go through 16 00:00:48,910 --> 00:00:50,560 the trouble of making them for each enemy. 17 00:00:50,560 --> 00:00:55,390 Because it's a lot of work, and the material flesh we implement now is a good substitution for that, 18 00:00:55,390 --> 00:00:58,300 but it can also be used together with a hurt animation. 19 00:00:59,080 --> 00:01:03,880 And to achieve a material flash, we first need to find the material that our characters are using. 20 00:01:03,880 --> 00:01:11,380 So in the DBP action char base, if we look at the sprite, we can see we have the masked lit sprite 21 00:01:11,380 --> 00:01:12,250 material. 22 00:01:12,250 --> 00:01:15,040 And this is a material that we didn't create ourself. 23 00:01:15,040 --> 00:01:17,020 This actually came with paper 2D. 24 00:01:17,320 --> 00:01:20,260 And we can click on the folder icon to show us this right. 25 00:01:20,260 --> 00:01:23,260 You can see we have the mask sprite material. 26 00:01:23,260 --> 00:01:26,290 And you can see that this is a material instance. 27 00:01:26,290 --> 00:01:29,800 And it is based on the default lit sprite material. 28 00:01:29,800 --> 00:01:30,040 Right. 29 00:01:30,040 --> 00:01:31,510 So this is the parent. 30 00:01:31,510 --> 00:01:34,780 And this is kind of similar to how we have parents and children with the blueprints. 31 00:01:34,780 --> 00:01:37,450 But it is materials and material instances here. 32 00:01:37,450 --> 00:01:39,310 And now we are using the lit version. 33 00:01:39,310 --> 00:01:44,440 But later on we're going to use the default sprite material, which is the unlit version as well. 34 00:01:44,440 --> 00:01:46,840 So we actually want to copy both of these. 35 00:01:46,840 --> 00:01:51,280 We actually don't want to apply any changes to the material right here, because this material is shared 36 00:01:51,280 --> 00:01:53,980 between all of your Unreal Engine 5.3 projects. 37 00:01:53,980 --> 00:01:59,500 We just want to make a copy of these so we can scroll all the way up to content. 38 00:02:00,060 --> 00:02:05,940 And we have a materials folder already so we can get the default lid spread material, hold control 39 00:02:05,940 --> 00:02:07,320 and click the other one. 40 00:02:07,320 --> 00:02:10,590 And we can just drag to the materials folder. 41 00:02:10,590 --> 00:02:14,730 And we want to very importantly not move here copy here. 42 00:02:15,800 --> 00:02:16,970 And now we can go in here. 43 00:02:16,970 --> 00:02:18,980 And now you can see we have a copy of these. 44 00:02:18,980 --> 00:02:22,970 Both the thumbnail was a bit weird, but after you wait a while it shows up correctly. 45 00:02:23,180 --> 00:02:24,620 Let's change the names now. 46 00:02:24,620 --> 00:02:27,110 So the default lit sprite material. 47 00:02:27,640 --> 00:02:34,330 I just want to hit F2 to rename it and just call it M underscore custom lit sprite material. 48 00:02:36,760 --> 00:02:39,460 And the other one I want to rename two. 49 00:02:40,610 --> 00:02:45,170 M underscore custom unlit sprite material. 50 00:02:48,100 --> 00:02:53,170 And we're going to start our implementation in the custom lit sprite material. 51 00:02:53,710 --> 00:02:55,450 So double click to open it up. 52 00:02:55,450 --> 00:02:57,430 And you're going to see a lot of nodes in here. 53 00:02:57,430 --> 00:03:01,540 And we're not going to go too much into detail on all of the different things you can do in a material. 54 00:03:01,540 --> 00:03:03,340 We're going to keep it pretty simple. 55 00:03:03,340 --> 00:03:05,170 But you have an output node here, right? 56 00:03:05,170 --> 00:03:08,740 And you can see the base color is going to be the source texture. 57 00:03:08,740 --> 00:03:10,540 And we have an opacity mask. 58 00:03:10,540 --> 00:03:12,760 We have normal maps and all these kind of things in here. 59 00:03:12,760 --> 00:03:19,570 But what we want to do is change something in the emissive color because we want to flash the material. 60 00:03:19,570 --> 00:03:21,700 So we only want to change the image of color. 61 00:03:21,700 --> 00:03:24,010 We don't have to worry about all of the other things here. 62 00:03:24,460 --> 00:03:29,230 The first thing we need here is a color, because we want to give a color to the emissive color. 63 00:03:29,230 --> 00:03:35,110 And the way we can create a new color is by holding four on the keyboard, the four key and left clicking. 64 00:03:35,470 --> 00:03:39,760 And this gives us a vector for which in this case is treated as a color. 65 00:03:40,210 --> 00:03:42,220 And we can then just click this. 66 00:03:42,220 --> 00:03:45,160 And here on the left side under constant you can open it up. 67 00:03:45,160 --> 00:03:48,550 And this gives us a lot of colors here that we can use. 68 00:03:48,550 --> 00:03:52,090 And I'm just going to go like in the yellow somewhere here. 69 00:03:52,090 --> 00:03:53,410 Kind of orangey. 70 00:03:53,410 --> 00:03:54,610 And click okay. 71 00:03:54,610 --> 00:03:56,500 And you can see that it changes now. 72 00:03:56,500 --> 00:04:01,240 And we can then simply use this and put it into the emissive color. 73 00:04:02,340 --> 00:04:03,960 And now you can see the sprite on the left side. 74 00:04:03,960 --> 00:04:05,760 Here it is lighting up. 75 00:04:06,210 --> 00:04:09,390 And for now, let's just apply this to the character and see what it looks like. 76 00:04:09,390 --> 00:04:12,150 So we can go to the action chart base on the sprite. 77 00:04:12,150 --> 00:04:15,090 We're just going to use our M custom. 78 00:04:16,329 --> 00:04:19,690 Lit sprite material, right. 79 00:04:19,690 --> 00:04:20,950 And we need to compile and save. 80 00:04:20,950 --> 00:04:23,770 And actually in the material itself we also need to apply. 81 00:04:24,640 --> 00:04:27,670 And safe, otherwise it's not going to show up. 82 00:04:27,670 --> 00:04:29,200 And then you can see the action jar. 83 00:04:29,230 --> 00:04:34,630 Now it's just flashing all the time, but we only want it to flash once and then go back to the regular 84 00:04:34,630 --> 00:04:35,140 color. 85 00:04:36,220 --> 00:04:37,750 And back in the material. 86 00:04:37,750 --> 00:04:41,140 The best way of doing this is to multiply the color. 87 00:04:42,670 --> 00:04:43,270 I multiply. 88 00:04:43,270 --> 00:04:48,940 Sorry, I mistyped multiply the color by a scalar. 89 00:04:48,940 --> 00:04:54,040 So we could just multiply this by zero and then connect this instead. 90 00:04:54,310 --> 00:04:56,530 And now it's just going to be completely ignored. 91 00:04:56,530 --> 00:05:01,420 So this is nice because it lets us turn it on and off very easily just by using a number. 92 00:05:01,420 --> 00:05:03,550 And we can actually make it shine even more. 93 00:05:03,550 --> 00:05:09,370 We can go like 40 maybe, and it's going to shine even stronger than it did before with one. 94 00:05:09,370 --> 00:05:11,410 So this gives us a lot of control. 95 00:05:11,410 --> 00:05:16,210 But instead of just writing it here, I want to have a parameter so I can just hold a one, the one 96 00:05:16,210 --> 00:05:20,500 key and left click and get a constant like this and just connect it here. 97 00:05:20,500 --> 00:05:22,930 And the default can just stay at zero. 98 00:05:22,930 --> 00:05:26,470 But this lets us now control what we put in here. 99 00:05:26,470 --> 00:05:30,250 And we want to be able to change this dynamically. 100 00:05:30,250 --> 00:05:33,940 So we want to right click this and convert to parameter. 101 00:05:33,940 --> 00:05:39,190 Converting something to a parameter lets us easily change it in the material instances, and we can 102 00:05:39,190 --> 00:05:42,070 also override it during runtime from the blueprint. 103 00:05:42,070 --> 00:05:43,900 So this is very useful. 104 00:05:43,900 --> 00:05:46,840 I'm just going to call this flash multiplier. 105 00:05:47,460 --> 00:05:48,480 Like this. 106 00:05:48,480 --> 00:05:52,680 And we also can change the color because sometimes you have other effects you want to show differently. 107 00:05:52,680 --> 00:05:55,620 So maybe if you have a poison effect only that should be in green. 108 00:05:55,620 --> 00:05:57,630 And if you have a fire effect, maybe that in red. 109 00:05:57,630 --> 00:05:59,940 So it just gives us more versatility. 110 00:05:59,940 --> 00:06:03,030 So just right click this and also convert to parameter. 111 00:06:03,030 --> 00:06:05,670 And I'm just going to call it flash color. 112 00:06:05,670 --> 00:06:09,390 And these names are actually very important because we're going to use them later. 113 00:06:09,390 --> 00:06:10,710 So we have to remember them. 114 00:06:10,710 --> 00:06:12,780 Or we can just come back to look them up again. 115 00:06:13,260 --> 00:06:17,640 And just like with blueprints, we can collapse this because now, like somebody might look at this 116 00:06:17,640 --> 00:06:19,860 and like, what is this flash color and flash multiplier? 117 00:06:20,010 --> 00:06:22,110 They have to like think about it for a second. 118 00:06:22,110 --> 00:06:23,910 We can just convert. 119 00:06:23,910 --> 00:06:24,690 No sorry. 120 00:06:25,200 --> 00:06:29,250 We can just collapse nodes and just call it. 121 00:06:30,220 --> 00:06:32,080 Flash effect. 122 00:06:32,980 --> 00:06:35,740 And this just makes it very clear what is happening here. 123 00:06:35,740 --> 00:06:37,810 And we can just drag it somewhere here. 124 00:06:37,810 --> 00:06:38,080 Right. 125 00:06:38,080 --> 00:06:41,380 And then we can open it up again and just look into what we have here. 126 00:06:41,380 --> 00:06:42,250 But we finished it. 127 00:06:42,250 --> 00:06:43,810 We don't have to worry about it again. 128 00:06:43,810 --> 00:06:45,640 And now it's just cleaner. 129 00:06:45,910 --> 00:06:51,580 What we do want to do though is just copy the splash effect control C, and we also have to add this 130 00:06:51,580 --> 00:06:56,590 to our custom unlit sprite, because later on we're going to use this one as well. 131 00:06:56,590 --> 00:07:04,060 But the problem here is control V first that the emissive color is already being used by the texture. 132 00:07:04,780 --> 00:07:09,760 And like I said before, because an unlit sprite will kind of create its own emissive ness, its own 133 00:07:09,760 --> 00:07:13,360 shine, to not rely on light sources. 134 00:07:13,360 --> 00:07:19,390 But what we can do here now is that we just add this drag off and add. 135 00:07:20,020 --> 00:07:20,530 Here. 136 00:07:20,530 --> 00:07:21,490 Connect this. 137 00:07:22,580 --> 00:07:27,290 So now it's just going to take the original emissive color and add to it the flash effect that we want 138 00:07:27,290 --> 00:07:29,750 to have, and use that as the new color. 139 00:07:29,840 --> 00:07:32,540 I can also just apply this and save. 140 00:07:32,750 --> 00:07:38,120 And we now want to well, we can just close all of this down first close tabs to the right. 141 00:07:38,120 --> 00:07:38,510 Yes. 142 00:07:38,510 --> 00:07:39,980 Apply materials. 143 00:07:39,980 --> 00:07:42,410 And now yeah we have the default value of zero. 144 00:07:42,410 --> 00:07:43,640 So it's not shining. 145 00:07:43,970 --> 00:07:47,240 But we also want to create our material instances. 146 00:07:47,240 --> 00:07:50,300 As you've seen we could just use the material in the character right away. 147 00:07:50,300 --> 00:07:54,530 But a material instance is just more versatile and it's also more optimized behind the scenes. 148 00:07:54,530 --> 00:07:57,470 So it's always a good practice to create material instances. 149 00:07:57,470 --> 00:08:04,160 Start with the custom unlit sprite and create material instance, and we can just keep everything the 150 00:08:04,160 --> 00:08:04,850 same. 151 00:08:04,850 --> 00:08:13,970 Just remove the inset at the end and I want to call me so my custom unlit sprite material and do the 152 00:08:13,970 --> 00:08:18,230 same for the custom lit sprite material here, create a material instance again. 153 00:08:18,230 --> 00:08:24,320 Again, just delete the instance suffix and add the me prefix. 154 00:08:24,320 --> 00:08:29,930 So my custom lit sprite material, my custom unlit sprite material. 155 00:08:29,930 --> 00:08:32,600 And again this is for our 2d 3D hybrid games. 156 00:08:32,600 --> 00:08:36,559 And this is for our 2D only games, which we're going to switch into later. 157 00:08:36,559 --> 00:08:40,700 Now in the action chart, we want to use this material instance instead of this material that we have 158 00:08:40,700 --> 00:08:41,450 been using. 159 00:08:41,450 --> 00:08:42,530 So blueprints. 160 00:08:42,559 --> 00:08:43,850 Characters. 161 00:08:43,850 --> 00:08:44,300 Action. 162 00:08:44,300 --> 00:08:44,540 Char. 163 00:08:44,540 --> 00:08:45,140 Base. 164 00:08:45,810 --> 00:08:47,460 On the sprite. 165 00:08:47,460 --> 00:08:49,230 We just look for me. 166 00:08:49,260 --> 00:08:50,760 Underscore custom. 167 00:08:51,090 --> 00:08:53,790 Custom lit sprite material. 168 00:08:53,790 --> 00:08:57,030 And yeah, the naming can be confusing, but this is the convention. 169 00:08:57,030 --> 00:08:59,340 Lit means that it can receive lighting. 170 00:08:59,340 --> 00:09:01,170 So again 2d 3d hybrid. 171 00:09:01,200 --> 00:09:06,180 We want to have the Me custom lit sprite material and we can compile and save. 172 00:09:06,180 --> 00:09:10,230 And yeah you can see like right now nothing really changed. 173 00:09:10,230 --> 00:09:11,340 It still looks the same. 174 00:09:11,340 --> 00:09:12,270 We can receive the shadows. 175 00:09:12,270 --> 00:09:13,170 Everything is fine. 176 00:09:13,170 --> 00:09:15,120 I shoot him and still nothing happens. 177 00:09:15,120 --> 00:09:20,760 Because now we need to actually tell the material from the blueprints which multiply we want to use 178 00:09:20,760 --> 00:09:25,170 when in the BP action chart, because we also want to use this for the player later. 179 00:09:25,170 --> 00:09:25,770 Maybe. 180 00:09:26,490 --> 00:09:32,640 We then need to get a reference to the material, and it's not like we can just drag this out here. 181 00:09:32,640 --> 00:09:33,690 This doesn't work. 182 00:09:33,690 --> 00:09:40,530 We need to go to Beginplay and we drag out the sprite because the material is on the sprite. 183 00:09:41,370 --> 00:09:48,990 And here we want to dynamic create dynamic material instance like this. 184 00:09:49,970 --> 00:09:52,640 And the element index is very important. 185 00:09:52,640 --> 00:09:56,600 On the sprite you can see we have element zero for the materials. 186 00:09:56,600 --> 00:09:58,610 So we need to match this number. 187 00:09:58,610 --> 00:10:00,560 And this one only has one material. 188 00:10:00,560 --> 00:10:01,340 So there's no problem. 189 00:10:01,340 --> 00:10:05,120 But sometimes we have models or for sprites usually not. 190 00:10:05,120 --> 00:10:08,480 But for models that could have multiple materials. 191 00:10:08,660 --> 00:10:10,130 The rest we don't have to fill out. 192 00:10:10,130 --> 00:10:11,750 We don't care what source material, option name. 193 00:10:11,750 --> 00:10:12,890 We don't care about this. 194 00:10:12,890 --> 00:10:16,220 We just want to get a dynamic material instance here. 195 00:10:16,460 --> 00:10:18,860 And this is what the return value is. 196 00:10:18,860 --> 00:10:23,450 So this isn't just a material, but it also prepares the material for us in a way that we can affect 197 00:10:23,450 --> 00:10:24,590 it dynamically. 198 00:10:25,740 --> 00:10:29,610 And here I just want to drag this off and promote to variable. 199 00:10:29,610 --> 00:10:34,920 And I'm just going to call this dynamic sprite mat for dynamic sprite material. 200 00:10:34,950 --> 00:10:35,160 Right. 201 00:10:35,160 --> 00:10:38,850 So on Beginplay, when the character is spawned, we just save this here. 202 00:10:38,850 --> 00:10:42,480 And then later in the blueprint, anywhere we can just do whatever we want to do. 203 00:10:43,100 --> 00:10:49,250 So for example, just for testing after the beginplay, we could just get the dynamic material instance. 204 00:10:49,400 --> 00:10:55,760 And here we can just set scaler sorry set scalar parameter value. 205 00:10:56,350 --> 00:10:57,970 And like we have before. 206 00:10:57,970 --> 00:11:00,160 Let's just open up the material again and. 207 00:11:01,360 --> 00:11:07,150 Under materials and the custom lit sprite material. 208 00:11:07,150 --> 00:11:09,610 The mi instance is fine too. 209 00:11:09,760 --> 00:11:12,490 And by the way, this is what an instance looks like. 210 00:11:12,490 --> 00:11:14,860 And we have the parent reference here, right? 211 00:11:14,860 --> 00:11:19,960 And in an instance we could just have this flash multiplier and just set it to four for example here. 212 00:11:19,960 --> 00:11:22,990 And you can see how it changes uh directly. 213 00:11:22,990 --> 00:11:29,350 And actually if I just drag this off to the side and have the game open, you can see that this changes 214 00:11:29,350 --> 00:11:30,520 in real time. 215 00:11:30,520 --> 00:11:35,200 If I change something here, you can see every character or every sprite that is using this material 216 00:11:35,200 --> 00:11:36,700 changes in real time. 217 00:11:36,700 --> 00:11:40,210 And now all we want to do is tap into this from the blueprint. 218 00:11:40,210 --> 00:11:43,510 So we don't do this manually here, but through the game logic. 219 00:11:45,310 --> 00:11:50,650 But you can just drag this back here and just set this back to the default value, because we're going 220 00:11:50,650 --> 00:11:52,390 to change this from the blueprint. 221 00:11:53,220 --> 00:11:55,020 But here we can see the name, right? 222 00:11:55,020 --> 00:11:58,110 We have this flash multiplier name that we set up before. 223 00:11:58,110 --> 00:12:00,810 And we want to use this here for the parameter name. 224 00:12:00,810 --> 00:12:03,360 So just type in flash multiplier. 225 00:12:03,360 --> 00:12:07,590 And here you have to be very careful that you don't have typos or it's just not going to work. 226 00:12:07,590 --> 00:12:09,870 And we can just connect this here right. 227 00:12:10,490 --> 00:12:12,290 And I'm just going to set this to ten. 228 00:12:12,320 --> 00:12:13,040 It doesn't really matter. 229 00:12:13,040 --> 00:12:14,720 It's just a demonstration. 230 00:12:14,960 --> 00:12:17,480 And you can see now the character is normal. 231 00:12:17,480 --> 00:12:18,380 It's not lighting up. 232 00:12:18,380 --> 00:12:24,050 And I press play because begin play is going to trigger right action char bass begin play triggers when 233 00:12:24,050 --> 00:12:25,100 I start the game. 234 00:12:25,100 --> 00:12:27,590 And we're going to set the flash multiplier to ten. 235 00:12:28,190 --> 00:12:32,180 And this is just to show you how we can use a dynamic sprite material. 236 00:12:32,600 --> 00:12:36,740 We can just take this now um control X to cut it out. 237 00:12:36,740 --> 00:12:39,500 And we can just make a custom event here. 238 00:12:39,500 --> 00:12:41,990 Just custom event. 239 00:12:43,400 --> 00:12:44,870 And this could also be a function. 240 00:12:44,870 --> 00:12:46,310 This could be a custom event. 241 00:12:46,310 --> 00:12:48,890 Both are kind of the same thing in this case. 242 00:12:48,890 --> 00:12:52,820 And just call trigger flash just like this. 243 00:12:53,590 --> 00:12:59,050 And now we can just Ctrl v and paste in this set scalar parameter value here. 244 00:12:59,790 --> 00:13:05,550 But the reason we want to use a custom event here is that in a function, we cannot have a timeline, 245 00:13:05,550 --> 00:13:09,810 but we want to use a timeline later to make the flash fade out slowly. 246 00:13:09,810 --> 00:13:13,680 And this is why we're using a custom event instead of a function. 247 00:13:14,280 --> 00:13:16,620 And here we can now also set the color. 248 00:13:16,620 --> 00:13:18,750 So again copy paste the dynamic sprite mat. 249 00:13:18,750 --> 00:13:21,240 But this is actually not a scalar parameter. 250 00:13:21,240 --> 00:13:24,660 If we look here it's a vector parameter the flash color. 251 00:13:24,660 --> 00:13:25,200 Right. 252 00:13:25,200 --> 00:13:29,730 So we can set vector parameter value. 253 00:13:29,730 --> 00:13:32,190 Yeah this one and go here. 254 00:13:32,880 --> 00:13:34,110 And the parameter name. 255 00:13:34,110 --> 00:13:37,020 Again we want to get this flash color. 256 00:13:37,640 --> 00:13:45,560 So flash color and we can set any color here that we want to set, but we don't want to hard code this 257 00:13:45,560 --> 00:13:45,950 and this. 258 00:13:45,980 --> 00:13:49,970 We just want to expose this to the custom event, the function. 259 00:13:49,970 --> 00:13:51,860 So we can just drag this in here. 260 00:13:51,860 --> 00:13:53,990 And it's going to create an input pin. 261 00:13:53,990 --> 00:13:55,070 And the same for this one. 262 00:13:55,070 --> 00:13:58,250 We can just drag it in here and it's going to create an input pin. 263 00:13:58,520 --> 00:14:00,650 Um I want to change this. 264 00:14:00,650 --> 00:14:04,910 Make some reroute nodes with double clicks to make this better. 265 00:14:04,910 --> 00:14:05,840 Like this. 266 00:14:06,810 --> 00:14:07,590 Better visible. 267 00:14:07,590 --> 00:14:09,450 And I also want to change the name here. 268 00:14:09,450 --> 00:14:09,720 Right. 269 00:14:09,720 --> 00:14:13,110 So here I want the flash multiplier. 270 00:14:17,650 --> 00:14:20,020 And here I want to have the flash color. 271 00:14:21,280 --> 00:14:23,950 So again, this just does the same thing we had before. 272 00:14:23,950 --> 00:14:25,810 But now I can just call this trigger flash. 273 00:14:25,810 --> 00:14:26,080 Right. 274 00:14:26,080 --> 00:14:33,100 So again just on Beginplay to demonstrate I can just have the maybe have a short delay, sorry, have 275 00:14:33,100 --> 00:14:35,800 a short delay and then trigger flash. 276 00:14:36,900 --> 00:14:39,870 And I didn't compile, so the names are corrupted. 277 00:14:39,900 --> 00:14:42,420 You can just delete this compile save. 278 00:14:42,420 --> 00:14:44,850 And now again trigger flash. 279 00:14:44,850 --> 00:14:45,810 And now it's working right. 280 00:14:45,810 --> 00:14:46,920 We have the flash multiplier. 281 00:14:46,920 --> 00:14:48,000 Let's just set it to one. 282 00:14:48,000 --> 00:14:52,080 And we can just pick any color here and then go to the map. 283 00:14:52,080 --> 00:14:52,620 Right. 284 00:14:52,620 --> 00:14:53,520 Wait for a bit. 285 00:14:53,520 --> 00:14:55,170 Well actually 0.2 is very fast. 286 00:14:55,170 --> 00:14:57,630 So you don't really see the switch right. 287 00:14:57,630 --> 00:14:58,290 Nothing happens. 288 00:14:58,290 --> 00:15:02,040 Then after one second we get the flash color that we put in here. 289 00:15:02,040 --> 00:15:05,070 And I hope you understand this just makes it very versatile to use this. 290 00:15:05,070 --> 00:15:07,320 We can just pop this all around. 291 00:15:07,680 --> 00:15:10,350 We can just change the color on the fly, change the multiplier. 292 00:15:10,350 --> 00:15:13,050 And this is just a nice way to make this modular. 293 00:15:13,470 --> 00:15:16,260 And now while we implement this we just keep this here for testing. 294 00:15:16,260 --> 00:15:17,040 Right. 295 00:15:17,040 --> 00:15:24,450 And what we want is that we want it to flash once and then we want it to slowly go back to the original, 296 00:15:24,750 --> 00:15:26,970 um, parameter value for flash multiplier. 297 00:15:26,970 --> 00:15:31,440 We don't really have to change the color, we just want to set this back to zero. 298 00:15:32,150 --> 00:15:32,570 Right. 299 00:15:32,570 --> 00:15:34,490 We could, of course, just use a delay here. 300 00:15:35,080 --> 00:15:37,390 And then copy paste this. 301 00:15:38,560 --> 00:15:39,850 And set it back to zero. 302 00:15:39,850 --> 00:15:40,450 Right? 303 00:15:40,750 --> 00:15:41,920 And let's say one. 304 00:15:41,920 --> 00:15:45,250 And if I start now, you see it flashes red after a second. 305 00:15:45,250 --> 00:15:46,330 It just goes back. 306 00:15:46,330 --> 00:15:47,440 And this is fine. 307 00:15:47,440 --> 00:15:47,920 This is fine. 308 00:15:47,920 --> 00:15:51,250 But we can use a timeline to actually make this smoother. 309 00:15:51,730 --> 00:15:54,340 So we can just get rid of this here and this also. 310 00:15:54,340 --> 00:15:57,730 And here we just want to create a timeline. 311 00:15:57,820 --> 00:16:03,640 So add timeline I want to call it fade sprite flash like this. 312 00:16:03,640 --> 00:16:05,860 And here we just want to play from start. 313 00:16:06,890 --> 00:16:12,770 And a timeline simply gives us a value over time, which we can then use to change this to a zero. 314 00:16:12,770 --> 00:16:19,130 So instead of going to zero instantly, we can start at the flash multiplier and then over time slowly 315 00:16:19,130 --> 00:16:20,210 go to the zero. 316 00:16:20,420 --> 00:16:23,360 And the best way of doing this is to use a lerp node. 317 00:16:23,360 --> 00:16:25,760 So now we can copy paste this again. 318 00:16:25,760 --> 00:16:30,950 And on update we want to update this every time the value here changes, right? 319 00:16:30,950 --> 00:16:36,590 And instead of having a value of 1 or 0 we can slurp slurp float. 320 00:16:36,590 --> 00:16:37,340 Yes. 321 00:16:37,340 --> 00:16:38,660 And where do we start. 322 00:16:38,660 --> 00:16:42,800 Well we do start at the same value we pass in here right. 323 00:16:42,800 --> 00:16:46,520 So this is our default value a where we start at. 324 00:16:47,330 --> 00:16:48,410 Like this. 325 00:16:49,110 --> 00:16:50,100 Double click. 326 00:16:51,120 --> 00:16:54,900 And we want to slowly go from A to B. 327 00:16:55,520 --> 00:16:59,660 And B should be zero because we don't want to have any flash after this is done. 328 00:16:59,660 --> 00:17:01,160 But we need this alpha, right? 329 00:17:01,160 --> 00:17:05,270 So if the alpha is zero, A is active and will be passed through here. 330 00:17:05,270 --> 00:17:09,740 If the alpha is one, then B will be active and pass through here. 331 00:17:09,740 --> 00:17:14,300 And if it's something in between, well then it is between the value of a and b. 332 00:17:14,300 --> 00:17:20,450 So we need to have a timeline here for this alpha value that slowly goes from 0 to 1. 333 00:17:20,450 --> 00:17:24,319 So we can slowly go from A to B and we can go in here. 334 00:17:24,980 --> 00:17:28,940 And set the length to one second to start out. 335 00:17:28,940 --> 00:17:34,400 Then we create a new track and it should be a float track because we just need a single number and just 336 00:17:34,400 --> 00:17:35,510 call this alpha. 337 00:17:35,810 --> 00:17:38,060 And again we want to start at zero. 338 00:17:38,060 --> 00:17:44,300 So we can just right click and add a new keyframe and set this to zero time, because it starts right 339 00:17:44,300 --> 00:17:45,110 at the beginning. 340 00:17:45,110 --> 00:17:47,390 And the value should also be zero. 341 00:17:47,390 --> 00:17:49,190 And then right click again. 342 00:17:49,190 --> 00:17:50,630 Create another key. 343 00:17:50,630 --> 00:17:53,570 And this should be a time one the same time as the length. 344 00:17:53,570 --> 00:17:56,000 Here the value should be one, right? 345 00:17:56,090 --> 00:17:56,810 Sorry. 346 00:17:57,260 --> 00:18:00,410 Click again and the way this works is right. 347 00:18:00,410 --> 00:18:03,890 We start at zero and over time we slowly go to one. 348 00:18:06,030 --> 00:18:11,490 And we could also give this some smoothing if we just select all of these and right click one and just 349 00:18:11,490 --> 00:18:14,250 set the interpolation to auto. 350 00:18:14,550 --> 00:18:19,290 You can see that it has a nice little curve and it's going to look a little bit smoother even. 351 00:18:19,710 --> 00:18:22,890 And now we can go back to our event graph here. 352 00:18:22,890 --> 00:18:25,770 And we have this alpha value now which we can just plug in here. 353 00:18:25,770 --> 00:18:26,010 Right. 354 00:18:26,010 --> 00:18:29,910 So we start at zero here A and go to one the b. 355 00:18:32,810 --> 00:18:34,370 Now let's try this out. 356 00:18:34,370 --> 00:18:35,240 Go here. 357 00:18:36,260 --> 00:18:40,070 It flashes and you can see it slowly goes back to not flashing right. 358 00:18:40,620 --> 00:18:41,820 Just like this. 359 00:18:42,180 --> 00:18:47,610 Uh, one problem now, though, is that we cannot really, uh, affect the length, right? 360 00:18:47,610 --> 00:18:52,260 Because in here we set one second and let's say we want to change it to 1.5 seconds. 361 00:18:52,260 --> 00:18:54,450 Then we have to change this entire thing again. 362 00:18:54,450 --> 00:18:55,710 We have to change all of this. 363 00:18:55,710 --> 00:18:55,890 Right? 364 00:18:55,890 --> 00:19:00,360 Because if I set it to 1.5, you can see that this does not update, only this changed. 365 00:19:00,360 --> 00:19:04,290 So then I would have to pull this over and do all of these kind of things, which is not great. 366 00:19:04,290 --> 00:19:05,790 So let's just set this back to one. 367 00:19:05,790 --> 00:19:08,160 There is a better way of handling this. 368 00:19:08,220 --> 00:19:13,080 And before we call play from start, we want to open up some space. 369 00:19:13,850 --> 00:19:16,310 And here we just type in the name of our timeline. 370 00:19:16,310 --> 00:19:21,200 So fade sprite flash and here get fade sprite flash. 371 00:19:21,200 --> 00:19:24,260 And here I can set play rate. 372 00:19:26,980 --> 00:19:28,420 And put this out here. 373 00:19:29,340 --> 00:19:33,900 And what this does is it is a multiplier for this time. 374 00:19:33,900 --> 00:19:35,970 So let's say I set it to two. 375 00:19:36,000 --> 00:19:37,770 It's going to play twice as fast. 376 00:19:37,770 --> 00:19:40,560 If I set it to 0.5, it's going to play half as fast. 377 00:19:40,560 --> 00:19:45,000 And this gives us a lot of control without having to go in here and update everything every single time. 378 00:19:45,630 --> 00:19:47,790 And we want the flash to be rather snappy. 379 00:19:47,790 --> 00:19:49,620 So I can just set this to five. 380 00:19:49,620 --> 00:19:53,400 But I want to put this to a variable so we can easily change this. 381 00:19:53,400 --> 00:19:53,640 Right? 382 00:19:53,640 --> 00:20:02,490 So promote the variable and just call it sprite flash play rate this compile and save. 383 00:20:02,490 --> 00:20:04,440 And yeah our default value is five. 384 00:20:04,440 --> 00:20:05,250 That is fine. 385 00:20:05,640 --> 00:20:08,610 And just to show you that this works just do this again. 386 00:20:08,610 --> 00:20:10,590 And yeah you can see it works. 387 00:20:10,590 --> 00:20:14,550 But now we don't want to call this on Beginplay anymore. 388 00:20:14,550 --> 00:20:16,320 We can just get rid of this. 389 00:20:16,800 --> 00:20:19,770 And we want to play this when we take damage. 390 00:20:19,770 --> 00:20:22,530 So right event any damage receive damage. 391 00:20:22,530 --> 00:20:24,690 And then we check if is defeated. 392 00:20:24,690 --> 00:20:28,410 And we actually only want to play this if we are not defeated. 393 00:20:28,410 --> 00:20:28,620 Right. 394 00:20:28,620 --> 00:20:32,010 Because if we are defeated we might play a different death animation. 395 00:20:32,010 --> 00:20:34,380 And we don't want to have the sprite flash. 396 00:20:34,380 --> 00:20:38,610 So here we can just, uh, flash trigger flash. 397 00:20:38,610 --> 00:20:39,360 Right. 398 00:20:39,630 --> 00:20:42,030 So if we are defeated, just destroy the actor. 399 00:20:42,030 --> 00:20:43,860 If we're not defeated, play the flash. 400 00:20:43,860 --> 00:20:49,470 And I like to use a yellow orange like we already used before for this. 401 00:20:49,470 --> 00:20:53,310 I think that looks nice, but you could also just use white if you wanted to. 402 00:20:53,760 --> 00:20:55,380 So just select the color you like. 403 00:20:55,380 --> 00:20:57,540 And I want it to flash a little bit more. 404 00:20:57,540 --> 00:20:58,740 I want it to be quite strong. 405 00:20:58,740 --> 00:21:00,540 So I'm actually going to set this to ten. 406 00:21:00,540 --> 00:21:03,180 But again this is kind of up to your own preference. 407 00:21:03,750 --> 00:21:06,150 So now we can try this again. 408 00:21:06,150 --> 00:21:09,780 And I shoot the enemy and you can see it's nice. 409 00:21:09,780 --> 00:21:13,650 We actually feel now that we apply damage to the enemy. 410 00:21:13,650 --> 00:21:17,100 Of course, there's many more things like sound effects and other things that are going to improve this 411 00:21:17,100 --> 00:21:17,760 even more. 412 00:21:17,760 --> 00:21:20,190 But this alone is a huge step. 413 00:21:20,190 --> 00:21:22,320 I still don't really like the speed though. 414 00:21:22,320 --> 00:21:24,150 I feel like it's a little bit slow. 415 00:21:24,150 --> 00:21:30,360 So again, for the sprite, uh, flash play rate here, I want to set this to eight. 416 00:21:31,700 --> 00:21:32,870 And do this again. 417 00:21:33,970 --> 00:21:36,160 And yeah, I think this feels a lot better. 418 00:21:36,780 --> 00:21:38,370 It's a lot snappier. 419 00:21:38,370 --> 00:21:41,670 It's very flashy and it tells you that you actually hit the enemy. 420 00:21:41,670 --> 00:21:45,720 And this is just a very easy but often used way to make the game more readable. 421 00:21:45,720 --> 00:21:47,460 But that's it for this video. 422 00:21:47,460 --> 00:21:52,680 In the next video, we want to implement damaging the player, because now even if I walk into the enemy, 423 00:21:52,680 --> 00:21:53,730 I'm actually being blocked. 424 00:21:53,730 --> 00:21:55,080 I'm not taking any damage. 425 00:21:55,080 --> 00:21:57,120 That is what we're going to do in the next video. 37522

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