All language subtitles for 2. Tank Projectiles (GOOD)

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian Download
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,030 --> 00:00:08,160 Let's discuss about tank projectors and when discussing about tank projectors, there are two parts 2 00:00:08,160 --> 00:00:08,790 involved. 3 00:00:09,150 --> 00:00:11,580 The first one is, of course, the projector. 4 00:00:11,640 --> 00:00:14,490 The second one is the means of creating and firing. 5 00:00:14,490 --> 00:00:17,830 The projectors were in game terms, the weapon system. 6 00:00:17,850 --> 00:00:22,960 Let's look at the three different projectile types present in this project. 7 00:00:23,010 --> 00:00:29,430 So the projectors that we are going to look at are the main projectile, which is a linear projectile. 8 00:00:29,430 --> 00:00:30,870 It moves straight forward. 9 00:00:31,440 --> 00:00:39,330 We're going to look at the rocket, which has a different trajectory and an ARC projectile, which is 10 00:00:39,330 --> 00:00:44,520 basically a cannonball which moves up and then comes down in an arc. 11 00:00:44,760 --> 00:00:51,630 Each projectile has, as you probably noticed, it's on scene with its own parameters, objects and 12 00:00:51,630 --> 00:00:52,170 scripts. 13 00:00:52,200 --> 00:00:55,020 Let's get started with projectile one. 14 00:00:55,860 --> 00:01:02,280 And as you can see here, right out of the bat, all the projectiles kind of have the same scene structure. 15 00:01:02,310 --> 00:01:08,250 So once you go through one, you will understand for all of them, what does it have here? 16 00:01:08,280 --> 00:01:12,360 Of course it has the projectile model, which is just the 3D object. 17 00:01:12,480 --> 00:01:14,050 This one I created in Blender. 18 00:01:14,070 --> 00:01:16,770 But in the rocket case, I created ingot directly. 19 00:01:17,940 --> 00:01:19,890 We also have a timer. 20 00:01:20,730 --> 00:01:26,370 This is just the good old timer that acts as the timespan of the projectile. 21 00:01:26,580 --> 00:01:33,780 We do need this because in the case that the projectile hasn't collided with anything and has exited 22 00:01:33,780 --> 00:01:39,720 the main scene, so that means that the projectile is still around, but it cannot ever go away. 23 00:01:40,290 --> 00:01:41,940 We need to kill it at some point. 24 00:01:41,940 --> 00:01:44,010 And the kill time is 2 seconds. 25 00:01:44,220 --> 00:01:48,120 We also have a trail which is a component from the trail system. 26 00:01:48,150 --> 00:01:53,310 This is a very nice plugin which I recommend for good though this makes awesome trails and the collision, 27 00:01:53,310 --> 00:01:54,690 which is an error collision. 28 00:01:55,020 --> 00:01:59,820 And here we have a collision shape which should match our project. 29 00:01:59,820 --> 00:02:02,250 Elephants are critical, to be precise. 30 00:02:02,340 --> 00:02:08,010 Here I want to point out that the collision here, the collision layer doesn't matter so much because 31 00:02:08,010 --> 00:02:13,560 we don't really want the projectile colliding with themselves, but we want the masks to be one and 32 00:02:13,560 --> 00:02:17,460 two because on the one, we have the tanks and on two, we have the buildings. 33 00:02:17,760 --> 00:02:20,700 So the mask is what the projectile interacts with. 34 00:02:21,210 --> 00:02:23,520 So this is what we actually need from it. 35 00:02:23,640 --> 00:02:24,870 So let's look at the code. 36 00:02:24,960 --> 00:02:26,250 This is the projectile code. 37 00:02:26,280 --> 00:02:32,460 What we have here is, of course, the speed and damage and these values are exported so we can change 38 00:02:32,460 --> 00:02:35,070 them at project level. 39 00:02:35,310 --> 00:02:37,870 So this is quite neat functionality. 40 00:02:37,890 --> 00:02:44,610 We have the process functionality and this is the easiest one for this projectile because once the projectile 41 00:02:44,610 --> 00:02:48,090 is enabled because if it's if it's not enabled, then it will just return. 42 00:02:48,090 --> 00:02:49,290 So nothing will happen. 43 00:02:49,320 --> 00:02:54,720 We just translate it forward using the current speed and the delta, which is the time between frames 44 00:02:54,720 --> 00:02:56,890 so that this is frame rate adjusted. 45 00:02:56,910 --> 00:02:59,070 It don't move at different speeds. 46 00:02:59,190 --> 00:03:04,200 If you have 120 frames per second or 60 frames per second, the initialize function is probably the 47 00:03:04,200 --> 00:03:04,800 biggest one. 48 00:03:05,010 --> 00:03:13,500 And one important thing that I want to note here is the fact that these parameters and this method is 49 00:03:13,500 --> 00:03:15,660 the same for every single projectile. 50 00:03:15,750 --> 00:03:22,020 And this is important because if we keep the same header in the same parameters, then we can just stop 51 00:03:22,020 --> 00:03:23,610 the projectiles in and out. 52 00:03:23,790 --> 00:03:30,090 And we don't have to put more code to handle each projectile type because as you'll see here, some 53 00:03:30,090 --> 00:03:36,900 parameters like the target point is not actually used for this projectile and in other cases it will 54 00:03:36,900 --> 00:03:37,440 be used. 55 00:03:37,620 --> 00:03:42,900 But you'll see when the projectile gets called, it's just one line in the tool or for every projectile. 56 00:03:42,900 --> 00:03:47,880 So in this case, we need some parameters that might not be used by one or another projectile. 57 00:03:47,880 --> 00:03:52,890 What we have here is the start point, which tells where the projectile should start from the target 58 00:03:52,890 --> 00:04:00,330 point, which is actually not that important for a projectile that moves indefinitely forward. 59 00:04:00,390 --> 00:04:05,250 This is more for projectile that target, the specific position, the damage of the projectile, the 60 00:04:05,250 --> 00:04:12,660 color which is mostly the color of the parent, the parent tank object, which is basically needed to 61 00:04:13,140 --> 00:04:19,080 detect collisions and basically avoid collisions with the parent and the parent script which has specific 62 00:04:19,080 --> 00:04:21,320 functionality just for ARC projectiles. 63 00:04:21,330 --> 00:04:23,670 So this won't be used in this one as well. 64 00:04:23,700 --> 00:04:25,470 So first we need to set up the rotation. 65 00:04:25,710 --> 00:04:31,020 So this is how we set up the projectile rotation to the five point rotation from the tank. 66 00:04:31,050 --> 00:04:32,700 Then we set up the position. 67 00:04:32,730 --> 00:04:38,340 So as you see, the start point is basically just the transform that contains the rotation and position. 68 00:04:38,460 --> 00:04:39,630 This is enabled. 69 00:04:39,660 --> 00:04:46,260 It happens here because if we don't put this, then when we instantiate the projectile and it initially 70 00:04:46,260 --> 00:04:52,110 gets instantiated, that position 000, I think we don't want the projectile to actually start moving 71 00:04:52,110 --> 00:04:53,110 from that point. 72 00:04:53,130 --> 00:04:57,110 We want the project to start moving once it gets the right position. 73 00:04:57,120 --> 00:05:02,640 So we first set up the right position, which should be the tip of the tank start, and then we enable 74 00:05:02,640 --> 00:05:04,410 it so that it moves from that position. 75 00:05:04,890 --> 00:05:11,430 We also set the time span to start and we also need to change the color of the project. 76 00:05:11,640 --> 00:05:15,280 And here you'll see a familiar code if you checked the other tutorials. 77 00:05:15,300 --> 00:05:21,540 So we need to get the current material duplicated because otherwise we will change all the projectiles. 78 00:05:21,540 --> 00:05:24,500 And you don't want to change all the color just only for this one. 79 00:05:24,510 --> 00:05:27,390 And then we basically set it back to the same object. 80 00:05:27,640 --> 00:05:29,340 You see, this is basically the same line. 81 00:05:29,370 --> 00:05:33,870 So we take the material duplicated and then set it back and then change its color. 82 00:05:33,930 --> 00:05:39,000 This will make sure that just this particular instance of the projectile gets its color changed. 83 00:05:39,150 --> 00:05:40,850 And there is another way to do this. 84 00:05:40,860 --> 00:05:44,670 I want to quickly mention, but I will not be using that way. 85 00:05:45,870 --> 00:05:52,200 So for example, if you have a material, if you select this material, you can put in resource and 86 00:05:52,200 --> 00:05:53,360 local to scene. 87 00:05:53,400 --> 00:05:58,620 This will actually, in theory, work all the time to make this material local. 88 00:05:58,650 --> 00:06:01,260 I tried it for some particular cases. 89 00:06:01,410 --> 00:06:07,140 It might not work, I might be wrong, but I'll be using the duplicate because that's like 100% sure 90 00:06:07,140 --> 00:06:07,920 that it's going to work. 91 00:06:08,250 --> 00:06:09,780 But this isn't the way to do it. 92 00:06:10,050 --> 00:06:11,040 I just want to mention it. 93 00:06:11,640 --> 00:06:14,370 So going back to the code, Leslie, we have a twin. 94 00:06:14,880 --> 00:06:20,340 And this twin basically just interprets the speed to not have the maximum speed from the beginning, 95 00:06:20,340 --> 00:06:24,080 to just have a small transition from the current speed. 96 00:06:24,090 --> 00:06:29,430 So the speed the maximum speed is ten in this case, and the current speed will be transitioned from 97 00:06:29,430 --> 00:06:33,480 zero to the maximum speed with a factor of 0.25. 98 00:06:33,660 --> 00:06:37,270 Of course, if sine transition and is in and out. 99 00:06:37,290 --> 00:06:42,720 So if you want your speed to be directly that fast, either just to move the current speed, then just 100 00:06:42,720 --> 00:06:46,530 to speed here and to completely delay this, it don't matter. 101 00:06:46,620 --> 00:06:49,080 Next, we have the time spend time out. 102 00:06:49,080 --> 00:06:51,960 And as you can see, there is no code for this. 103 00:06:51,960 --> 00:06:54,020 So how does this gets connected? 104 00:06:54,030 --> 00:06:56,880 Well, is because I'm using the functionality from here. 105 00:06:57,000 --> 00:07:05,370 So if you just click on the time spent timer and node and we see here a list of signals that this node 106 00:07:05,550 --> 00:07:09,870 triggers when they happen and the time out happens when it when this timer reaches zero. 107 00:07:10,710 --> 00:07:17,700 So I just used connect and then put on this script and the generated this function when the time speed 108 00:07:17,700 --> 00:07:20,790 gets zero, then we free it from the memory. 109 00:07:20,790 --> 00:07:21,870 So basically we kill it. 110 00:07:21,900 --> 00:07:24,290 Next we have the on area body entered. 111 00:07:24,330 --> 00:07:30,720 And this is important because the area can detect multiple collisions, but we actually just need to 112 00:07:30,720 --> 00:07:32,400 detect the body collisions. 113 00:07:32,430 --> 00:07:35,700 So for this, we go here and we use the body. 114 00:07:35,700 --> 00:07:41,250 And third and of course, we do the same as the timer and this is what we end up with. 115 00:07:41,970 --> 00:07:43,020 So what happens here? 116 00:07:43,020 --> 00:07:45,990 First, we need to prevent the self collision. 117 00:07:46,620 --> 00:07:51,630 So if the body that was detected is the same as with the parent, then we turn. 118 00:07:51,630 --> 00:07:52,770 We don't care about it. 119 00:07:52,890 --> 00:08:00,750 The next one, if the body has no system and if you have looked at the main pair functionality, you 120 00:08:00,750 --> 00:08:08,010 know that HP system is right below the kinematic body and this would not have been possible by this. 121 00:08:08,010 --> 00:08:14,100 Otherwise I would have to go up one level, actually go up two levels and then go to systems and then 122 00:08:14,100 --> 00:08:15,210 go to system. 123 00:08:15,220 --> 00:08:18,570 So this would have looked like so is kind of weird. 124 00:08:18,990 --> 00:08:22,050 It's much easier to put it like this and it's much more clear. 125 00:08:22,680 --> 00:08:30,030 Of course, if it does have this note, then we take it out and call take damage, which takes the projectile 126 00:08:30,030 --> 00:08:37,860 damage is subtracted from the life and also it informs the object that took damage which object damaged 127 00:08:37,860 --> 00:08:38,150 it. 128 00:08:38,190 --> 00:08:45,180 So this is important for later when the enemy gets hit by the player and the enemy actually acquires 129 00:08:45,180 --> 00:08:49,470 the target from that hit, not from its other sensors. 130 00:08:49,530 --> 00:08:54,630 Next, we set up some nice effects and that is a small explosion and the camera shake. 131 00:08:54,630 --> 00:08:58,230 And you can change these values to make it look more nicer. 132 00:08:58,560 --> 00:09:02,850 And lastly, we need to destroy the projectile and we get this. 133 00:09:04,230 --> 00:09:06,240 So if you run it, this is what you get. 134 00:09:06,240 --> 00:09:09,690 The projectile instantiate an effect. 135 00:09:09,690 --> 00:09:10,500 It's quite cool. 136 00:09:10,500 --> 00:09:11,220 It's quite nice. 137 00:09:11,220 --> 00:09:11,790 It nice. 138 00:09:11,800 --> 00:09:12,810 You can change the values. 139 00:09:12,810 --> 00:09:14,550 Like damage, like speed. 140 00:09:14,940 --> 00:09:20,640 Time out, of course, to predict that once it leaves the space, it will actually die by itself. 141 00:09:21,590 --> 00:09:22,100 So. 142 00:09:23,780 --> 00:09:25,010 You see, it disappears. 143 00:09:25,010 --> 00:09:26,270 So that's the time out. 144 00:09:26,810 --> 00:09:28,220 That's when it disappears. 145 00:09:28,790 --> 00:09:33,130 If you want your project not to disappear from the screen, there are two ways to do it. 146 00:09:33,140 --> 00:09:38,060 Either you go to the maximum length and you try it like this and then you adjust the timeout. 147 00:09:38,570 --> 00:09:43,040 The other one is completely remove the timeout and surround the scene with some colliders. 148 00:09:43,040 --> 00:09:49,850 And basically you're assured that the projectile, even if it leaves the scene, it will eventually 149 00:09:49,850 --> 00:09:51,740 collide with something and it will get destroyed. 150 00:09:51,750 --> 00:09:53,270 So both are valid options. 151 00:09:53,270 --> 00:09:54,590 You can pick whatever you want. 152 00:09:54,620 --> 00:09:56,720 Now let's look at the Rocket project that. 153 00:09:56,780 --> 00:10:02,120 And before we look at the in the rocket projectile, I'm going to quickly show you how you can actually 154 00:10:02,120 --> 00:10:04,270 change projectors and then the player. 155 00:10:04,280 --> 00:10:08,210 So I'm going into the player quickly and then to the weapon system. 156 00:10:08,840 --> 00:10:10,520 And here, as you see, we have the projectile. 157 00:10:10,520 --> 00:10:11,900 So if I just drag and drop. 158 00:10:13,030 --> 00:10:14,020 The rocket projectile. 159 00:10:14,500 --> 00:10:16,720 And then, of course, into Soviet and. 160 00:10:18,450 --> 00:10:19,960 So this is the rocket projectile. 161 00:10:19,980 --> 00:10:26,460 Its main difference than the regular one is that it actually aims for a particular target so it doesn't 162 00:10:26,460 --> 00:10:31,670 move aimlessly towards infinity, but actually aims to a particular target. 163 00:10:31,680 --> 00:10:37,920 And the other part is that it starts to the particular rotation and it tries to adjust that rotation 164 00:10:37,920 --> 00:10:40,680 to eventually arrive at the target position. 165 00:10:40,710 --> 00:10:41,820 So how does this happen? 166 00:10:42,210 --> 00:10:44,730 Let's look now at the projectile rocket. 167 00:10:45,360 --> 00:10:46,630 Join the projectile rocket. 168 00:10:46,650 --> 00:10:48,840 We have the mesh, which is just the 3D model. 169 00:10:49,590 --> 00:10:50,550 We have the collision shape. 170 00:10:50,550 --> 00:10:54,960 And this was required because if we don't have it, then the kinematic body will complain. 171 00:10:55,290 --> 00:10:58,080 But the actual collision shape that matters is in the area. 172 00:10:58,200 --> 00:11:05,190 So here that we get sexually on by the entered similar as the other one we have also the time span and 173 00:11:05,190 --> 00:11:06,420 the nice trail effect. 174 00:11:06,600 --> 00:11:07,870 Let's look at the code now. 175 00:11:07,890 --> 00:11:11,280 So here, as you see, the initialize is basically the same. 176 00:11:12,240 --> 00:11:16,410 But the main difference is that we just put the origin position. 177 00:11:16,410 --> 00:11:18,510 So we just put the initial position. 178 00:11:18,510 --> 00:11:22,590 We don't put the rotation because the rotation actually is randomized. 179 00:11:22,590 --> 00:11:27,450 So the project, I'll start with a random rotation and basically this twin is the same. 180 00:11:27,450 --> 00:11:34,660 So it adjusts the speed to not be instantaneously fast from the beginning in the process, what's it's 181 00:11:34,680 --> 00:11:40,650 different because it calculates a direction from the target point that we want to achieve to the point 182 00:11:40,650 --> 00:11:41,820 that we are currently at. 183 00:11:41,820 --> 00:11:48,600 So this is a vector of we need to get the length of it and then we normalize it to a length one. 184 00:11:48,600 --> 00:11:53,370 And if the length of the vector is below two, then this means that the projectile is close to the target 185 00:11:53,370 --> 00:11:54,930 and we can actually delete it. 186 00:11:54,930 --> 00:12:00,690 But what makes the projectile work is actually we translate it to the direction multiplied with the 187 00:12:00,690 --> 00:12:02,370 current speed and the delta. 188 00:12:02,400 --> 00:12:07,620 So as I mentioned, the direction is a vector from the find the position that we want to achieve to 189 00:12:07,620 --> 00:12:09,960 the position that we currently are at. 190 00:12:09,960 --> 00:12:13,680 And we need to translate it slowly to the final position. 191 00:12:13,860 --> 00:12:17,850 And of course, if we just use this, then the projectile will look kind of weird. 192 00:12:17,850 --> 00:12:19,680 So I'm going to quickly. 193 00:12:21,380 --> 00:12:22,100 Change this. 194 00:12:22,100 --> 00:12:29,360 So I'm going to play this because it will be interesting that the projectile will still go at the destination, 195 00:12:29,360 --> 00:12:30,830 but I don't know if you see it. 196 00:12:31,460 --> 00:12:39,790 The projectile doesn't rotate correctly and basically this is what they look at does because they're 197 00:12:39,800 --> 00:12:40,040 there. 198 00:12:40,070 --> 00:12:44,390 This is basically a name that they came up with, takes the previous position. 199 00:12:44,510 --> 00:12:50,840 So I'm going to show this is the tank and this is the position that we want to arrive at the end. 200 00:12:51,380 --> 00:12:58,460 So the projectile will get fired, let's say, with this direction and needs to eventually go to this 201 00:12:58,460 --> 00:12:59,000 position. 202 00:12:59,990 --> 00:13:01,430 First the direction. 203 00:13:01,440 --> 00:13:05,750 So from the target point to the projectile will be this one. 204 00:13:08,580 --> 00:13:15,000 So this vector will actually make sure that every single frame, the projectile gets adjusted accordingly. 205 00:13:15,030 --> 00:13:19,140 Now, to actually make sure that the projectile gets. 206 00:13:20,570 --> 00:13:21,800 This kind of rotation. 207 00:13:26,100 --> 00:13:27,960 Instead of this one. 208 00:13:30,420 --> 00:13:32,490 Because this will look weird, right? 209 00:13:33,000 --> 00:13:38,620 So we need to avoid making it like this and make it look like this. 210 00:13:38,640 --> 00:13:39,840 So how can we do this? 211 00:13:40,140 --> 00:13:43,350 Let's take another arc because it's easier to see. 212 00:13:44,010 --> 00:13:46,530 So we take the previous position, which is this one. 213 00:13:48,610 --> 00:13:50,230 And the current position. 214 00:13:53,240 --> 00:13:54,020 Which is this one. 215 00:13:54,860 --> 00:13:56,660 So these are the two positions. 216 00:13:56,670 --> 00:14:00,110 So we have the current position minus the previous position. 217 00:14:00,590 --> 00:14:03,920 And this will actually give us this small factor. 218 00:14:05,710 --> 00:14:07,750 And using this small vector. 219 00:14:09,010 --> 00:14:10,630 We actually look at. 220 00:14:10,630 --> 00:14:16,180 So we use the mesh to look at this vector multiplied by ten, which will be this position. 221 00:14:16,780 --> 00:14:18,370 So basically. 222 00:14:19,940 --> 00:14:21,560 The projectile will look at. 223 00:14:21,860 --> 00:14:26,660 So in this case, it will look at this position, dislocate this position. 224 00:14:27,230 --> 00:14:30,320 This will look at this position and so on, so forth. 225 00:14:30,860 --> 00:14:34,580 But it will make it look like it's moving the right way. 226 00:14:35,060 --> 00:14:41,960 Basically, this is called the tangent, and this is basically a line that's tangent to a circle. 227 00:14:42,650 --> 00:14:48,860 So I think there are other math operations too, to do this, but this is what they came up with and 228 00:14:48,860 --> 00:14:52,340 it works nicely, but we need the previous position as well to make this work. 229 00:14:52,790 --> 00:14:55,970 So basically this is how this projectile rotates nicely. 230 00:14:57,420 --> 00:15:05,190 And of course, when the collision happens, then this code is the same as the one in the previous projectile. 231 00:15:05,220 --> 00:15:07,380 It takes the collision with the parent. 232 00:15:07,440 --> 00:15:09,180 It checks if it has an HP system. 233 00:15:09,180 --> 00:15:10,980 And if it does, then it takes damage. 234 00:15:11,220 --> 00:15:14,250 And also it has explosion and the shake camera. 235 00:15:14,280 --> 00:15:19,730 By the way, this value could have been exported nicely so that it could have been changed like at the 236 00:15:19,730 --> 00:15:20,520 inspector level. 237 00:15:21,090 --> 00:15:23,160 But you can do this in your own project. 238 00:15:23,880 --> 00:15:31,380 Now, let's set up the last projectile to the player and see how this works. 239 00:15:32,960 --> 00:15:35,270 So an important thing is not only that. 240 00:15:36,770 --> 00:15:40,550 The projectiles have the same initialize function. 241 00:15:40,820 --> 00:15:46,670 It's also important that with the same function they like pointing to the right target. 242 00:15:47,090 --> 00:15:49,220 It makes the projectiles work in any case. 243 00:15:49,880 --> 00:15:56,350 So this projectile, as you see it, forms an arc so it can go over buildings or over obstacles. 244 00:15:56,390 --> 00:16:00,530 So this is more for an artillery purposed object. 245 00:16:00,540 --> 00:16:01,700 So how does this work? 246 00:16:02,240 --> 00:16:03,860 Well, let's look into it right now. 247 00:16:04,550 --> 00:16:10,670 So the ARC projectile has the same functionalities as the one before, with the exception that the damage 248 00:16:10,670 --> 00:16:12,650 area is actually a sphere. 249 00:16:13,190 --> 00:16:17,000 And mostly the artillery projectiles do splash damage. 250 00:16:17,010 --> 00:16:20,180 So you can increase the sphere size if that's what you want. 251 00:16:20,210 --> 00:16:25,250 Now let's look at the code and here in the initialize I said, does the same for everyone. 252 00:16:25,820 --> 00:16:31,430 We need to set up the position and the rotation to the correct ones from the fire point. 253 00:16:31,430 --> 00:16:33,890 And then we do the arc calculation. 254 00:16:33,890 --> 00:16:38,610 And basically what this does is actually broken down into two parts. 255 00:16:38,630 --> 00:16:40,940 First, we calculate a vector. 256 00:16:41,150 --> 00:16:48,740 That is how much force we need to apply to this projectile in order to arrive at the correct final destination 257 00:16:48,740 --> 00:16:50,800 where our mouse cursor pointed that. 258 00:16:50,810 --> 00:16:55,400 And the second one, we actually need to apply this to the physics enabled object. 259 00:16:55,400 --> 00:17:01,250 And as you can see, this object is actually the only projectile that has a rigid body and this is really 260 00:17:01,250 --> 00:17:04,200 needed because otherwise we cannot make it work. 261 00:17:04,220 --> 00:17:08,060 First we need the arc height and we calculate the velocity. 262 00:17:08,270 --> 00:17:14,660 And the velocity, as I mentioned, is a vector that actually stores how much power we need to apply 263 00:17:14,660 --> 00:17:16,910 in order to arrive at the correct destination. 264 00:17:16,910 --> 00:17:23,120 ARC velocity gets the position, it gets the final position, it gets the arc height, which is the 265 00:17:23,120 --> 00:17:29,720 actual height of the arc, how much we want it to go up and then the gravity and you'll see here some 266 00:17:29,720 --> 00:17:32,150 small values that they modified. 267 00:17:32,150 --> 00:17:36,350 And this is because the initial values didn't work properly. 268 00:17:36,350 --> 00:17:41,000 So I had to adjust them a little to make sure that it reaches the correct destination. 269 00:17:41,210 --> 00:17:42,560 And then the arc velocity. 270 00:17:43,190 --> 00:17:48,140 Basically, we calculate the velocity using a displacement. 271 00:17:48,740 --> 00:17:56,420 So here's some math involved, but the end result is basically a vector that has three components and 272 00:17:56,420 --> 00:17:59,750 the final two still needs some, some little adjustments. 273 00:17:59,750 --> 00:18:09,230 So we do need to modify the up vectoring and then the X and Y and Z one, and this will assure that 274 00:18:09,620 --> 00:18:12,620 the arc nicely arrives at the destination. 275 00:18:13,550 --> 00:18:19,160 So once this happens, the last thing we do is add the central force, which is the final velocity. 276 00:18:19,160 --> 00:18:26,210 We also set up the material for this projectile to reflect the color of the parent and the damage is 277 00:18:26,210 --> 00:18:28,160 similar to the previous one. 278 00:18:28,160 --> 00:18:34,730 The only difference here is that if the body doesn't have an HP system, then it's most likely a building 279 00:18:34,730 --> 00:18:37,610 or it's an empty space. 280 00:18:37,610 --> 00:18:43,400 So if this happens and this code is called, so what this does, it gets the reference to the parent 281 00:18:43,400 --> 00:18:46,100 script and then it calls this on Projectile Miss. 282 00:18:46,100 --> 00:18:53,210 And this is important for the tank that handles artillery because for example, if it goes behind a 283 00:18:53,210 --> 00:18:58,220 big building, let's say this one, because it can position itself here. 284 00:18:58,640 --> 00:19:02,600 And when it starts firing, oh, it it always goes into the building. 285 00:19:02,600 --> 00:19:03,860 So this is how it knows. 286 00:19:03,860 --> 00:19:05,190 Oh, I'm fine here. 287 00:19:05,210 --> 00:19:08,510 The building is not hitting anything, so it will adjust position. 288 00:19:09,720 --> 00:19:16,980 Still fire the building just position again, still far the building just again until eventually it 289 00:19:16,980 --> 00:19:18,270 goes past the building. 290 00:19:18,480 --> 00:19:26,310 So this is how this artillery tank unit gets information about if the projectile hit the correct target 291 00:19:26,310 --> 00:19:26,760 or not. 292 00:19:27,450 --> 00:19:34,500 This is important for just this projectile and the time span, which is similar to every other projectile. 293 00:19:34,590 --> 00:19:36,030 This is the last projectile. 294 00:19:36,030 --> 00:19:38,070 I hope you enjoyed this section. 295 00:19:38,400 --> 00:19:40,830 I'm going to change the projectile of the player. 296 00:19:40,830 --> 00:19:42,510 Back to the projectile one. 297 00:19:42,780 --> 00:19:46,260 By the way, this is how you can change the projectiles for the enemy as well. 298 00:19:46,410 --> 00:19:48,600 Next, they're going to other parts of the project. 29578

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