All language subtitles for 005 Wall Slide System[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,080 --> 00:00:04,910 Now that we have prepared this wall, we can finally work on the wall slide and wall jump. 2 00:00:04,939 --> 00:00:09,290 The way a wall jump works is actually quite different from game to game. 3 00:00:09,290 --> 00:00:13,130 And the method we're going up for is that it's broken down into two parts. 4 00:00:13,130 --> 00:00:19,310 We have the part where you just jump on the wall and we start sliding down, and we have the other part 5 00:00:19,310 --> 00:00:23,480 that if we press a button while we are sliding, we jump to the other side. 6 00:00:23,480 --> 00:00:27,890 Some games don't have the sliding part, and they simply make you jump if you press while you close 7 00:00:27,890 --> 00:00:28,730 and jump again. 8 00:00:28,730 --> 00:00:32,990 But we're going to break it down into the sliding and take care of that first, and then go into the 9 00:00:32,990 --> 00:00:33,950 jumping part. 10 00:00:33,950 --> 00:00:39,200 And the way this works is that while we have to detect if the wall is nearby and if we are falling, 11 00:00:39,200 --> 00:00:44,120 and to do that, we're going to shoot out a line trace to trace for the wall and check if the wall is 12 00:00:44,120 --> 00:00:49,670 close enough and if that is the case and we are falling down, we clamp the downward velocity of the 13 00:00:49,670 --> 00:00:52,580 player to make sure we just slide down very slowly. 14 00:00:52,610 --> 00:00:57,350 Most tutorials I've seen on this topic actually use a different method that doesn't clamp velocity, 15 00:00:57,350 --> 00:01:02,480 but lowers the gravity and I also looked into that method by actually found it buggy. 16 00:01:02,480 --> 00:01:07,970 And it doesn't work as well as the clamping velocity method because this covers more edge cases. 17 00:01:08,270 --> 00:01:10,100 Now let's open up the BP player. 18 00:01:10,100 --> 00:01:14,510 We can close everything else and we want to find the tick event. 19 00:01:14,510 --> 00:01:19,100 So on the event graph if we can't find it here, just control F and just look for tick. 20 00:01:19,640 --> 00:01:21,020 And we don't have the tick yet. 21 00:01:21,020 --> 00:01:23,810 We actually haven't implemented the tick yet for the player. 22 00:01:23,810 --> 00:01:25,100 So that's what we can do. 23 00:01:25,100 --> 00:01:31,040 Now I like to have the tick close to the beginplay, so we can just open up some space here and just 24 00:01:31,040 --> 00:01:34,580 right click and write tick event tick. 25 00:01:34,580 --> 00:01:38,360 And again we want to make sure to call everything on the parent first right. 26 00:01:38,360 --> 00:01:42,410 So right click here and call Add call to parent function. 27 00:01:42,710 --> 00:01:45,290 And just plug this in here also the delta time. 28 00:01:45,290 --> 00:01:47,450 And now we just execute everything on the parent first. 29 00:01:47,450 --> 00:01:51,740 And then we put in our own implementation for the BP player. 30 00:01:52,070 --> 00:01:56,120 The first thing we want to do on tick on every frame is a line trace. 31 00:01:56,120 --> 00:02:01,580 Because on every frame we want to check if we are close to the wall so we can latch on to it or not. 32 00:02:01,580 --> 00:02:04,940 And the line trace is pretty much like a sensor in the game world. 33 00:02:04,940 --> 00:02:08,750 And you can just like draw a line forward and check if you're hitting something. 34 00:02:08,750 --> 00:02:12,530 So here just right click and type in Line Trace. 35 00:02:12,530 --> 00:02:15,860 And you can see there's multiple types of line traces. 36 00:02:15,860 --> 00:02:18,710 In this case we do not need a multi-line trace. 37 00:02:18,710 --> 00:02:23,180 Multi-line traces for example would be in a shooter game if you want to shoot through a wall. 38 00:02:23,180 --> 00:02:27,950 So maybe if you shoot through a wooden wall it would still hit the person behind it, but maybe deals 39 00:02:27,950 --> 00:02:28,670 less damage. 40 00:02:28,670 --> 00:02:31,100 And for something like that, a multi-line trace is perfect. 41 00:02:31,100 --> 00:02:32,990 However, we just need something simple. 42 00:02:32,990 --> 00:02:35,000 So we just need a line trace. 43 00:02:35,000 --> 00:02:38,480 We can have by channel, by profile or for objects. 44 00:02:38,480 --> 00:02:42,770 And the one I want to use in this case is line trace for objects. 45 00:02:42,890 --> 00:02:44,960 And everything kind of works the same. 46 00:02:44,960 --> 00:02:45,230 Right. 47 00:02:45,230 --> 00:02:47,780 All of these different types have the start, the end. 48 00:02:47,780 --> 00:02:53,870 But the difference here for objects is that we get this object array where we can set the object types. 49 00:02:53,870 --> 00:02:58,490 And using object types is the easiest way to detect a wall or something in the stage. 50 00:02:58,490 --> 00:03:00,440 Then just connect this here on tick. 51 00:03:01,440 --> 00:03:03,600 And first let's look at the object types right. 52 00:03:03,600 --> 00:03:05,850 So here we can just make an array. 53 00:03:06,560 --> 00:03:07,580 Of object types. 54 00:03:07,580 --> 00:03:11,960 And here we can pick all of the different object types we want to check for. 55 00:03:11,960 --> 00:03:15,200 But for the wall slit, of course we don't want to check for projectiles. 56 00:03:15,200 --> 00:03:16,760 We don't want to check for pawns. 57 00:03:16,760 --> 00:03:19,460 We only care about walls for the wall slide. 58 00:03:19,460 --> 00:03:22,400 So the only thing we need is world static. 59 00:03:22,820 --> 00:03:24,230 Next we need to set. 60 00:03:24,230 --> 00:03:27,980 Where do we want to start the line trace and where should it end? 61 00:03:27,980 --> 00:03:31,610 For now, we just want to start directly from the middle of the player. 62 00:03:31,610 --> 00:03:31,880 Right. 63 00:03:31,880 --> 00:03:34,730 So we can just get actor location. 64 00:03:34,730 --> 00:03:36,560 Get actor location. 65 00:03:36,560 --> 00:03:40,130 And this is just the start position of our line trace. 66 00:03:40,920 --> 00:03:43,380 And we want to trace forward. 67 00:03:43,380 --> 00:03:49,770 So the end location should be our current location of the player and forward a little bit. 68 00:03:49,770 --> 00:03:54,930 And the way we can do this is by get actor forward vector like this. 69 00:03:54,930 --> 00:03:56,580 And this just gives us a direction. 70 00:03:56,580 --> 00:03:59,280 So it's going to be a vector of 100. 71 00:03:59,280 --> 00:04:01,080 For example, if we're looking to the right. 72 00:04:01,080 --> 00:04:07,020 And we can then multiply this by the amount of distance that we want to check. 73 00:04:07,020 --> 00:04:08,460 And here we get a vector. 74 00:04:08,460 --> 00:04:12,390 But we actually want to right click this and to float single precision. 75 00:04:12,390 --> 00:04:19,440 And here for example we could just put in like a 200 units to check 200 units forward. 76 00:04:19,440 --> 00:04:24,630 So all this does is it gives the forward direction and it multiplies it to check 200 units forward. 77 00:04:24,630 --> 00:04:27,330 And we need to add this to our current location. 78 00:04:27,330 --> 00:04:31,470 Otherwise if we just connect this this would just be from the zero position in the stage. 79 00:04:31,470 --> 00:04:34,710 But we want to relate this to the actor location right. 80 00:04:34,710 --> 00:04:36,330 So here we can just plus. 81 00:04:36,940 --> 00:04:38,350 And plug this in here. 82 00:04:38,350 --> 00:04:40,570 And this is our end location now. 83 00:04:40,570 --> 00:04:45,640 So this might look a bit confusing, but if you work with line traces more and more, this is actually 84 00:04:45,640 --> 00:04:48,400 quite simple and it's going to start making more sense. 85 00:04:48,400 --> 00:04:50,170 But let's just have a look at it. 86 00:04:50,170 --> 00:04:56,020 And to be able to see what actually happens here on the draw debug type, we want to set this for one 87 00:04:56,020 --> 00:04:56,860 frame. 88 00:04:56,860 --> 00:04:58,540 And now let's just try this out. 89 00:04:58,540 --> 00:04:59,470 It should already work. 90 00:04:59,470 --> 00:05:00,460 Compile and save. 91 00:05:00,460 --> 00:05:01,240 And I go here. 92 00:05:01,240 --> 00:05:03,490 And you can see this red line in front of the player. 93 00:05:03,490 --> 00:05:05,830 It might be a little bit small but you can see it right. 94 00:05:05,830 --> 00:05:12,580 And if we hit something you can also see this red block where we hit the wall and on this side as well. 95 00:05:12,580 --> 00:05:12,760 Right. 96 00:05:12,760 --> 00:05:15,550 You can see this red block and you can also see this green line. 97 00:05:15,550 --> 00:05:15,970 Right. 98 00:05:15,970 --> 00:05:18,670 So the green line on the other side is just the length. 99 00:05:18,670 --> 00:05:20,020 But we already hit something. 100 00:05:20,020 --> 00:05:22,060 So we don't really check anything after. 101 00:05:22,060 --> 00:05:23,950 But it just shows us the length still. 102 00:05:23,950 --> 00:05:24,160 Right. 103 00:05:24,160 --> 00:05:28,780 And you can see we are already correctly detecting the wall which is exactly what we want to do. 104 00:05:29,710 --> 00:05:32,500 And it also works that we do not detect the enemy, right? 105 00:05:32,500 --> 00:05:33,520 It doesn't show this block. 106 00:05:33,520 --> 00:05:37,030 It ignores the enemy and it only checks for this world static. 107 00:05:37,210 --> 00:05:39,400 But of course the trace is way too long. 108 00:05:39,400 --> 00:05:42,790 We don't want to start sliding if we are this far away from the wall. 109 00:05:42,790 --> 00:05:45,520 This was just for showing you how this works. 110 00:05:45,520 --> 00:05:50,500 So now we actually want to make sure it is of a reasonable length and it is not 200. 111 00:05:50,500 --> 00:05:53,590 And what we want is that it starts in the middle. 112 00:05:53,590 --> 00:05:53,950 Right. 113 00:05:53,950 --> 00:05:57,910 And it should be a little bit wider than our capsule. 114 00:05:57,910 --> 00:06:03,880 So we can actually look at the capsule and we can see that the capsule radius is 34. 115 00:06:04,300 --> 00:06:08,740 And since the radius is the half of it, it means from the middle point to the side of the capsule, 116 00:06:08,740 --> 00:06:10,390 it is 34 units. 117 00:06:10,390 --> 00:06:13,120 And our trace should be a little bit bigger than this. 118 00:06:13,120 --> 00:06:16,300 So I think about 40 units is a good value. 119 00:06:16,300 --> 00:06:17,680 And we can go back here. 120 00:06:17,680 --> 00:06:21,820 And now just type in 4D like this and compile and save. 121 00:06:22,350 --> 00:06:24,030 And you can see it is much shorter now. 122 00:06:24,030 --> 00:06:27,960 But still, if we close the wall, you can see the red block shows up. 123 00:06:27,960 --> 00:06:33,270 And I think this is about the right amount where we should start to slide down the wall. 124 00:06:33,270 --> 00:06:36,120 And now of course, we just want to turn this into a variable. 125 00:06:36,120 --> 00:06:40,620 So promote the variable and call it wall trace length. 126 00:06:41,680 --> 00:06:42,370 Like this. 127 00:06:42,370 --> 00:06:44,770 And this is the first step we need. 128 00:06:44,770 --> 00:06:47,650 And here we then get the output of is true or false. 129 00:06:47,650 --> 00:06:47,830 Right. 130 00:06:47,830 --> 00:06:50,170 So we can print true or false. 131 00:06:50,170 --> 00:06:53,680 And this shows us if the wall is next to us or not. 132 00:06:53,770 --> 00:06:54,280 Right. 133 00:06:54,280 --> 00:06:56,650 So false false false true true true true true. 134 00:06:56,650 --> 00:07:01,030 And we can then use this to set us to wall sliding or not wall sliding. 135 00:07:01,120 --> 00:07:01,480 Right. 136 00:07:01,480 --> 00:07:02,170 So let's do this. 137 00:07:02,170 --> 00:07:06,040 Now instead of the print string we can just have a branch here. 138 00:07:07,190 --> 00:07:07,790 Like this. 139 00:07:07,790 --> 00:07:12,950 And we want to create a new variable and it's called is wall sliding. 140 00:07:13,680 --> 00:07:14,910 And it should be a boolean. 141 00:07:14,910 --> 00:07:15,630 This is fine. 142 00:07:15,630 --> 00:07:16,620 Compile and save. 143 00:07:16,650 --> 00:07:17,940 Default value is false. 144 00:07:17,940 --> 00:07:18,750 This is fine. 145 00:07:18,750 --> 00:07:21,690 And now here we want to set it. 146 00:07:21,690 --> 00:07:24,630 So if this is true, we know that we have a wall next to us. 147 00:07:24,630 --> 00:07:26,010 We are checking the wall. 148 00:07:26,010 --> 00:07:27,240 So we want to set this to true. 149 00:07:27,270 --> 00:07:28,530 We are wall sliding. 150 00:07:28,530 --> 00:07:30,390 And we can just copy paste this here. 151 00:07:30,390 --> 00:07:33,600 And if this is not the case well we want to set this to false. 152 00:07:33,600 --> 00:07:34,170 Right. 153 00:07:34,170 --> 00:07:38,730 Because we should not be wall sliding if the trace doesn't hit anything near us. 154 00:07:39,120 --> 00:07:41,340 And this boolean by itself doesn't do anything. 155 00:07:41,340 --> 00:07:46,650 But this is what we're going to use in the animation graph to show the wall slide animation, and also 156 00:07:46,650 --> 00:07:48,780 check if we are able to wall jump. 157 00:07:48,780 --> 00:07:54,510 The velocity clamping is the most important part, but this is actually very simple to implement. 158 00:07:54,840 --> 00:07:58,410 So in the case that we have the wall next to us we are wall sliding. 159 00:07:58,410 --> 00:08:02,160 We just want to get the character movement component. 160 00:08:02,160 --> 00:08:05,250 And here we set velocity. 161 00:08:05,880 --> 00:08:06,900 All the way at the bottom. 162 00:08:06,900 --> 00:08:10,080 So this lets us manually override the velocity. 163 00:08:10,080 --> 00:08:15,390 It lets us overwrite the physics to pretty much just set our own velocity that we want it to have. 164 00:08:15,390 --> 00:08:16,800 And what do we want to do here? 165 00:08:16,800 --> 00:08:20,580 Well, we do not want to change the x and y velocity. 166 00:08:20,580 --> 00:08:21,990 So left, right, back, forward. 167 00:08:21,990 --> 00:08:23,280 We don't want to change anything. 168 00:08:23,280 --> 00:08:27,090 We just want to put a limit on the downward velocity. 169 00:08:27,630 --> 00:08:30,420 So here we can right click and split struct pin. 170 00:08:30,950 --> 00:08:35,510 But we need to know our current x and y velocity because if we just leave this as zero, it is actually 171 00:08:35,510 --> 00:08:38,090 going to set it to zero, which is something we don't want. 172 00:08:38,120 --> 00:08:42,559 So again, we can copy paste the character movement and get velocity. 173 00:08:42,799 --> 00:08:44,330 Get velocity. 174 00:08:44,510 --> 00:08:50,840 And here we split the struct pin and we just plug in the velocity x and the velocity y. 175 00:08:50,840 --> 00:08:53,870 So we just plug in the current velocity for the new velocity. 176 00:08:53,870 --> 00:08:56,510 And this is just the way you usually do this. 177 00:08:56,510 --> 00:08:59,420 But we also want to take the z velocity. 178 00:08:59,450 --> 00:09:01,370 We don't want to completely overwrite it. 179 00:09:01,370 --> 00:09:03,170 We just want to put a limit on it. 180 00:09:03,170 --> 00:09:04,490 And how can we put a limit. 181 00:09:04,490 --> 00:09:06,320 Well we can use clamp for example. 182 00:09:06,320 --> 00:09:09,950 Sorry, not this one a clamp float for example. 183 00:09:09,950 --> 00:09:12,380 We can use this and put a max and a min value. 184 00:09:12,380 --> 00:09:16,040 But in this case we actually only care about the minus value. 185 00:09:16,040 --> 00:09:20,030 So instead I think it's better to just use the max node. 186 00:09:20,120 --> 00:09:20,480 Max. 187 00:09:20,480 --> 00:09:21,680 Sorry Max. 188 00:09:21,680 --> 00:09:23,990 Float and connect this here. 189 00:09:25,760 --> 00:09:26,630 Go like this. 190 00:09:26,630 --> 00:09:30,710 And here it's then going to pick the biggest value. 191 00:09:30,710 --> 00:09:31,940 So it's going to pick Z. 192 00:09:31,940 --> 00:09:39,110 If z is bigger than 0 or 0, if z is a smaller than zero, but zero is too small because zero means 193 00:09:39,110 --> 00:09:40,310 we're never going downward. 194 00:09:40,310 --> 00:09:40,640 Right. 195 00:09:40,640 --> 00:09:43,640 So if I show you this, we just get stuck on the wall, right? 196 00:09:44,030 --> 00:09:49,460 So we just do this and we kind of almost get stuck because we cannot override physics 100%, but we 197 00:09:49,460 --> 00:09:52,130 just kind of slowly go down. 198 00:09:52,310 --> 00:09:54,830 Um, but we want to give it a little bit more speed. 199 00:09:54,830 --> 00:09:56,630 So here we can actually go -20. 200 00:09:56,780 --> 00:10:01,370 And this is going to be the fastest value we can go downward like this. 201 00:10:01,980 --> 00:10:03,660 And this is a little bit better. 202 00:10:05,080 --> 00:10:09,070 But if you want to slide even faster, you could adjust this value to, let's say, -100. 203 00:10:09,820 --> 00:10:12,880 For example, and you slide faster. 204 00:10:13,650 --> 00:10:16,800 But I think -20 is a good value for now. 205 00:10:17,310 --> 00:10:20,460 And we can then of course set this to a variable. 206 00:10:21,060 --> 00:10:27,120 So just drag off here and promote the variable and call the wall slide speed. 207 00:10:27,840 --> 00:10:28,650 Like this. 208 00:10:29,820 --> 00:10:34,050 We might adjust the actual value after we have the animation, everything else in, and we can get a 209 00:10:34,050 --> 00:10:35,850 better idea of how it feels like. 210 00:10:36,270 --> 00:10:41,070 Now we want to make some adjustments, because one thing I don't like is that even if we jump upwards, 211 00:10:41,070 --> 00:10:45,000 it also kind of like puts us into the wall sliding state already. 212 00:10:45,000 --> 00:10:48,990 We only want to be able to go into wall slide while we are falling, right? 213 00:10:48,990 --> 00:10:52,290 So not while we go upward, just while we are falling. 214 00:10:52,290 --> 00:10:53,790 And there's an easy check for this. 215 00:10:53,790 --> 00:11:00,300 So on the tick, before we do any of this, before we do all of this, we just open up some space. 216 00:11:01,580 --> 00:11:03,290 And we add a branch. 217 00:11:03,290 --> 00:11:05,330 So here we just add a branch. 218 00:11:06,550 --> 00:11:08,560 And we just check for our velocity. 219 00:11:08,560 --> 00:11:14,140 So on the character movement get velocity all the way at the bottom. 220 00:11:14,830 --> 00:11:16,840 We only want to check the z velocity. 221 00:11:16,840 --> 00:11:23,530 So here we can split the struct pin and we simply check for smaller equals and not zero. 222 00:11:23,530 --> 00:11:26,470 Well we want to be falling at a certain speed first. 223 00:11:26,470 --> 00:11:28,930 We don't just want to snap right to the wall. 224 00:11:28,930 --> 00:11:31,420 So I think about -50. 225 00:11:32,080 --> 00:11:35,950 So if we're going -50 downward it's going to start to actually line trace. 226 00:11:35,950 --> 00:11:39,520 And then only then allow us to go into the wall slide state. 227 00:11:39,520 --> 00:11:41,080 So let's check this out. 228 00:11:43,310 --> 00:11:45,800 I go here and I jump upward. 229 00:11:45,800 --> 00:11:46,700 It's fine. 230 00:11:47,120 --> 00:11:48,740 Only like after we go down. 231 00:11:48,740 --> 00:11:53,630 And this might be a little bit hard to tell because this is going to make much more sense once we have 232 00:11:53,630 --> 00:11:54,620 the animation in. 233 00:11:54,620 --> 00:11:59,960 But this is just a lot smoother for gameplay reasons than just clinging onto the wall even while you're 234 00:11:59,960 --> 00:12:01,400 still going upwards. 235 00:12:01,490 --> 00:12:03,620 That just doesn't make any sense for our game. 236 00:12:03,620 --> 00:12:09,830 And yet another addition is that I don't want the wall slide to be active unless I keep holding towards 237 00:12:09,830 --> 00:12:10,460 the wall. 238 00:12:10,460 --> 00:12:13,730 Now I just let go of the button, but we still are in this wall slide state. 239 00:12:13,730 --> 00:12:18,950 I only want the wall slide while I keep holding towards the left wall, and we need to add another condition 240 00:12:18,950 --> 00:12:20,090 for this as well. 241 00:12:20,770 --> 00:12:25,900 So back here where we do the check for the is falling and the easy way we can check for this. 242 00:12:25,900 --> 00:12:30,010 There are multiple ways you could do this to check for like the wall direction, all of these fancy 243 00:12:30,010 --> 00:12:30,490 things. 244 00:12:30,490 --> 00:12:36,460 But I think the easiest way to do this is to simply check if our input direction is the same direction 245 00:12:36,460 --> 00:12:41,590 that our character is facing, so we can get actor forward vector. 246 00:12:41,590 --> 00:12:48,010 Again, we only care about the x, we can split the struct pin, we only care about the x, and we also 247 00:12:48,010 --> 00:12:50,620 want to get I a move. 248 00:12:51,270 --> 00:12:53,940 So the enhanced action value right. 249 00:12:53,940 --> 00:13:00,420 So we have the eye move event right here on the event graph down. 250 00:13:00,420 --> 00:13:02,190 Yeah we have the eye move. 251 00:13:02,190 --> 00:13:06,180 And this is the event for our left and right input on the keyboard of course. 252 00:13:06,180 --> 00:13:11,520 But we can actually also get the current value anywhere else in the blueprint which is again a very 253 00:13:11,520 --> 00:13:13,590 nice feature of the enhanced input system. 254 00:13:13,590 --> 00:13:20,190 So just to show you how this works, let me just put this back here so we can always wall slide and 255 00:13:20,190 --> 00:13:21,390 just print string here. 256 00:13:21,390 --> 00:13:22,080 Right. 257 00:13:22,080 --> 00:13:23,100 Print string. 258 00:13:23,880 --> 00:13:25,140 The IA move. 259 00:13:26,760 --> 00:13:28,890 Now, if I start the game, you can see it's zero. 260 00:13:28,890 --> 00:13:30,750 Because I'm not pressing buttons, I press left. 261 00:13:30,750 --> 00:13:33,480 It's minus one, I press right, it is plus one. 262 00:13:33,480 --> 00:13:37,200 So again minus one is left, plus one is right. 263 00:13:37,350 --> 00:13:41,820 And the same goes for this actor forward vector on the x right. 264 00:13:41,820 --> 00:13:46,710 So I can print this I see right is one and left is minus one. 265 00:13:47,070 --> 00:13:50,580 So we just have to compare these and see if they are the same. 266 00:13:50,580 --> 00:13:56,940 But one problem with float comparisons is there are floating point rounding problems with all computers. 267 00:13:56,940 --> 00:13:58,770 This is again a computer science topic. 268 00:13:58,770 --> 00:14:04,470 I'm not going to go too much into detail in, but the thing is, you actually cannot compare a float, 269 00:14:04,470 --> 00:14:04,740 right? 270 00:14:04,740 --> 00:14:10,590 I could do equal, but in many cases it's not going to work because even if it says minus one in the 271 00:14:10,590 --> 00:14:15,120 computer, it might be -0.9999999997. 272 00:14:15,120 --> 00:14:18,090 And you never want to compare floats. 273 00:14:18,090 --> 00:14:23,610 We could use a nearly equal and put in an error tolerance. 274 00:14:23,610 --> 00:14:27,570 This would work, but there's actually an even better and easier way. 275 00:14:27,570 --> 00:14:29,310 We simply have to multiply these. 276 00:14:29,310 --> 00:14:30,630 So just multiply. 277 00:14:31,850 --> 00:14:36,770 And if both of these are plus, well, we're going to get a positive value that is bigger than zero. 278 00:14:36,770 --> 00:14:39,770 If both of these are minus we're going to get a negative value. 279 00:14:39,770 --> 00:14:44,990 And this is just a nice math shortcut we can use without having to use the nearly equal and put in a 280 00:14:44,990 --> 00:14:46,700 tolerance and deal with all of this. 281 00:14:46,700 --> 00:14:51,080 So here we just check for bigger or greater than zero. 282 00:14:51,080 --> 00:14:55,640 So if this is bigger than zero, it means we are pressing the button in the same direction that we are 283 00:14:55,640 --> 00:14:56,270 looking. 284 00:14:56,270 --> 00:15:01,100 If it isn't, it means that the direction we are looking and the button we are pressing is different, 285 00:15:01,100 --> 00:15:04,040 or we aren't pressing any button at all. 286 00:15:04,040 --> 00:15:07,400 And we can just connect this here and then use this and right. 287 00:15:07,400 --> 00:15:09,140 So these are our two conditions. 288 00:15:09,320 --> 00:15:11,270 And of course we also connect this here. 289 00:15:11,300 --> 00:15:14,330 Don't forget about this one and compile and save. 290 00:15:15,150 --> 00:15:18,870 And here I hold the button and I let go. 291 00:15:18,870 --> 00:15:19,680 And you see the line. 292 00:15:19,680 --> 00:15:20,310 Trace stops. 293 00:15:20,310 --> 00:15:23,190 We fall down normally again I hold the button, we slide. 294 00:15:23,190 --> 00:15:25,440 And this is exactly what we want. 295 00:15:25,440 --> 00:15:29,430 And I cannot show you this on the right side now because we don't have it. 296 00:15:29,430 --> 00:15:35,280 I actually can see a little bit, but it is hard for us to test on the right side yet because we don't 297 00:15:35,280 --> 00:15:36,390 have a right wall. 298 00:15:36,390 --> 00:15:37,260 Well, here you can see it. 299 00:15:37,260 --> 00:15:38,700 It also works for the right side. 300 00:15:38,700 --> 00:15:42,060 If I let go, we fall so it doesn't just work on the left side. 301 00:15:42,060 --> 00:15:43,350 It also works on the right side. 302 00:15:43,350 --> 00:15:45,870 And this is how we implement something like this. 303 00:15:46,850 --> 00:15:48,500 Now denotes look a little bit complicated. 304 00:15:48,500 --> 00:15:51,590 And if we look at this later we're going to be like what what was I doing here. 305 00:15:51,590 --> 00:15:55,970 So we can actually collapse these nodes and just give them a name to make it a little bit easier for 306 00:15:55,970 --> 00:15:56,420 us. 307 00:15:56,420 --> 00:16:03,410 So here we can select these three and just collapse nodes and just say is descending. 308 00:16:03,970 --> 00:16:05,470 So we know what we want to do here. 309 00:16:05,470 --> 00:16:07,600 And then in here we have all of this, of course. 310 00:16:07,600 --> 00:16:12,130 And here we just want to check for is holding towards wall. 311 00:16:12,130 --> 00:16:17,350 So collapse nodes and just say is holding towards wall. 312 00:16:17,350 --> 00:16:19,630 And all of this does still the same thing. 313 00:16:19,630 --> 00:16:24,070 It's just better to look it easier to understand what is going on here and next. 314 00:16:24,070 --> 00:16:25,810 We can also collapse all of this, right. 315 00:16:25,810 --> 00:16:27,310 All of this wall sliding logic. 316 00:16:27,310 --> 00:16:29,380 For now we are completely done with this. 317 00:16:29,380 --> 00:16:30,790 The wall sliding itself. 318 00:16:30,790 --> 00:16:34,690 So we can just select all of this, make sure to not select anything on the upper row. 319 00:16:34,690 --> 00:16:37,420 And we want to collapse this to a function. 320 00:16:37,420 --> 00:16:42,940 So right click collapse to function and just call try wall slide. 321 00:16:43,670 --> 00:16:45,230 And then drag it over here. 322 00:16:45,230 --> 00:16:48,380 And again, we cleaned up a lot of the space in our event graph. 323 00:16:48,380 --> 00:16:51,080 Everything is nice encapsulated in here. 324 00:16:51,290 --> 00:16:52,790 And these came with us. 325 00:16:52,790 --> 00:16:54,590 These nodes came with us. 326 00:16:54,590 --> 00:16:57,110 And I think these are just like small things. 327 00:16:57,110 --> 00:17:01,340 There's no point in putting these into a function unless we think we're going to reuse them. 328 00:17:01,340 --> 00:17:04,700 So this is why I chose to just collapse the nodes instead of making functions. 329 00:17:04,700 --> 00:17:06,770 But both are valid options. 330 00:17:06,770 --> 00:17:08,660 And here we just have the rest of it, right? 331 00:17:08,660 --> 00:17:09,530 Everything is working. 332 00:17:09,530 --> 00:17:12,800 We still want to keep the debug type showing. 333 00:17:12,800 --> 00:17:15,770 And this was pretty much all we have to do for the wall sliding. 334 00:17:15,770 --> 00:17:20,119 And this might have sounded like a bit of an intimidating topic, but I think you've seen that it is 335 00:17:20,119 --> 00:17:21,890 actually not that hard after all. 336 00:17:21,890 --> 00:17:26,359 It took me a while to figure out this really streamlined and good method, and I hope you learned something 337 00:17:26,359 --> 00:17:26,750 from this. 338 00:17:26,750 --> 00:17:30,800 And in the next lesson, we're going to implement the actual animations to make it look nicer. 30767

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