Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
0 Welcome to the main player functionality. 1
In this video we will dive deep into the player and how its main functionalities actually work. Here, 2
in the main scene there is the player instance, but the player is actually a scene in itself, so we're 3
going to head right into it. 4
What are the main functionalities of the player? 5
And this is important. 6
If I quickly play this. 7
You'll see that the player can rotate the turret. 8
It can move. 9
With W, 10
A 11
S 12
D 13
And also the arrow keys. 14
And also it can fire. 15
The turret will move to a specific position where the cursor is pointed at. 16
And if you press the leftmost button, the tank will fire. 17
Basically these are the main functionalities of the player. 18
There are a couple of hidden ones, for example, the turret animation. 19
As you can see, the turret slightly moves back and also the tank body slightly moves back. 20
And if I aim in the other direction, you see that it moves in the other direction. 21
So this is also in place. 22
This is basically a game polish thing. 23
It's not a functionality. 24
But we will also cover this in this episode. 25
Okay, so let's deep dive. 26
The player, as I mentioned, is a self-contained scene. Inside of it 27
there are two main parts, the dynamic one or the moving one and the static one. 28
And basically the moving one is the actual player mesh and the collision and things that the player 29
actually moves when they press the keys. 30
The systems part or the static one is the part that actually stays in place all the time. 31
I took this decision because in some cases, some systems and some functionalities do require a fixed 32
position in the scene, and instead of taking it out from the player, it's better to have it self-contained 33
because they're in fact functionalities of the player. 34
But we'll get into that a little later. 35
As I mentioned, the player body is the moving part. 36
What does it contain? 37
Of course it has the player camera. 38
And the camera is what actually makes the player visible. 39
But in this scene, we have two cameras that you can cycle through. 40
If I play it again and press [C] we have this big camera, which is actually a scene camera, 41
and this is the player camera. 42
This is your experience as the player camera. 43
This camera moves the the player. The movement is done automatically because the camera is a child 44
to the player. 45
So that's easily fixed. 46
Next we have the 3D mesh of the player. 47
This is basically the 3D models that make the player up. 48
We also have the collision shape, which is a box shape in this case. 49
This handles the projectile collisions with the player, but also the collisions with the building. 50
So we don't let the player go through the buildings. 51
It also has an animation, which is the turret animation. 52
We'll get into that a little later. 53
And also an HP system. 54
This will be discussed separately, but I aimed to have the systems as modular as possible so that 55
you can use them in your own project. 56
So basically this is just the drag and drop and basically you can do the same in your own project. 57
The HP system is basically the only system right now that is in the player body. 58
The other systems are in systems. 59
And this is mainly due to the fact that when a projectile enters the collision with the kinematic body, 60
it's easier to just get one of its nodes and check if it has the HP system. 61
Otherwise I would have to parse all this player tree and get the HP system from the other part. 62
And that would have been a little messy. 63
Note that this structure will be followed exactly for the enemy as well, so that the projectile code 64
doesn't need to change if it's the player that's hitting or the enemy that's hitting. 65
The static part consists of the three remaining systems which are the player mover: handling the movement 66
of the player, the targeting system: 67
When the player moves the mouse around, the intersection between the plane and the mouse will be where 68
the target is positioned. And the weapon system that handles the firing of the actual weapons. 69
Now that you have a basic idea of how the player is structured, let's go from top to bottom and deep 70
dive into each one of these and check them out. 71
At the topmost level 72
we have the player script, which is responsible for gluing everything together. 73
What we have in here is of course, some parameters. 74
And then one really important one is this meta "tag", which is type and player. 75
This will be used for projectile collisions. 76
There are two functions that handle the changing of the color of the player tank material. 77
So init_color() which gets the current material from the mesh, I made it so that most of the materials 78
are in the position zero. 79
Then it duplicates (the material). 80
One issue in Godot is the fact that the materials are shared between instances. 81
It's really important that it gets duplicated. 82
And then there is the second function called change_material(). 83
This will actually go through the tank mesh and apply the highlight material, which is our new duplicated 84
material to all the components. 85
Once this is done, the highlight material will get its color change based on the team color specified 86
in globals. 87
So basically this is just a tint of green. The change_material, 88
on the other hand, is a recursive function that means it calls itself and while calling itself, of 89
course, it may call to infinity, but in this case, since the nodes of the mesh are limited, it won't 90
call itself to infinity. 91
So we are lucky if that. 92
What it does, it takes the current tank mesh. 93
In this case this one, and then it parses its children. 94
The tank_turret_normal, tank_body and if the children is a mesh instance, then it will change the surface material 95
to the material we specified, which is our new duplicated material. 96
Note that there's one small hack here, and this is because one of my modelling mistakes: I assigned the 97
material that we want to change on index one instead of zero. 98
So this is not relevant if you do it correctly. 99
Just take this out and just use the first one. 100
Basically this is what it does and of course the change material calls itself, but it calls itself 101
for the nodes. 102
For example, we call it first here and then it's called for the tank_turret_normal and then for tank_body. 103
It goes through these children and through these children as well. 104
And once it doesn't have any more children, then these functions and all of the tree created by them 105
goes up and up and up until it ends and the function eventually stops. 106
Basically this is the logic for this one. Other than this, of course, we do have on_destroyed. 107
And as you see here, we get the HP system and the HP system has this nice signal on destroyed which 108
gets triggered when the HP system detects that the object that it's monitoring is finished, is done 109
on_destroyed here gets called, of course we remove it. 110
But before this we also remove the camera from the camera manager because we cannot allow the player 111
to change the camera to an invalid camera. 112
And here also the UI gets the show response screen, but this is just more visual stuff. 113
Basically this is what we have at the topmost level. 114
One last line here that I mentioned: that in on_destroyed the camera gets free from the camera manager. 115
Of course, the camera first when the player gets instantiated, it needs to be registered to the camera 116
manager. 117
And this is the line that does this. 118
Basically it tells the camera manager that's in the environment, hey, add new camera and basically 119
it adds this player camera. And the camera manager basically has the list of cameras and the player can 120
cycle through that list and choose the current camera via using the [C] (button). 121
By the way, all of the buttons are assigned in project/input map/ and here are all of the possibilities. 122
Move up, move down, left or right, fire, right mouse change camera, and hide_all. 123
Don't worry about the camera. 124
It will respond when the player gets respond and it'll call this again. 125
So you don't have to worry about that. 126
Now let's move to the next script, which is the camera script. 127
And in here most of the code, if not all of it. 128
And actually it's all of it is responsible for shaking the camera when a projectile hits the ground 129
or hits the player or hits an obstacle. 130
So basically, this is a shaking algorithm. 131
What it does, it just moves the offsets of the camera so that, for example, I'm going to use the 132
second camera so that I can show you. 133
So if I do the preview and I do the H offset and the V offset, you see it, it moves the parameters 134
like this. 135
So the primary experience kind of for shakiness of the camera. 136
So nothing fancy is just this. 137
You just shake the camera when the projectile collision hits something. 138
If you look into the tank mesh, we will find the components of the tank, the turret and the body they 139
contain the 3D meshes that make the tank up beside the meshes. 140
There are two other components that need to be there. 141
First, there is the Farpoint, and second there is the tank turret position. 142
Let's discuss a little about the fire point. 143
Basically, what the fire plan does is just the position 3D node. 144
It's nothing visual, but it tells where exactly the projectile should get spotted. 145
So this is really important because the weapon manager needs to know where it just upon the projectile 146
and it should not be the target position, which is you can see it's here. 147
So we don't want the projectile to be spawn here, Mr. Bond here. 148
And there are some other cases, like some other turret types. 149
We actually have more fired points and the weapon manager responsible for that will actually cycle through 150
each file point and fire the projectiles accordingly. 151
Lastly, we need the tank turret position to be specified on the body because the tank turret moves 152
a lot separately from the body and as one of the last steps of the adjusting the turret to its new position 153
is setting it up exactly on the body because as you see, the body also moves. 154
So it's not really that hard to get them out of sync. 155
And lastly, the collision shape is just the collision box. 156
And this also gets adjusted in code because the tank. 157
The body needs to be synchronized with the collision shape. 158
And the question shape needs to be the child of player body, because this is the kinematic body. 159
The animation player holds basically the animation of the turret moving. 160
But here instead of moving the turret on the z-axis, we actually move just the parameter. 161
And this is because for example, if the turret has this position and it moves on the z-axis, it's 162
not the local one, it'll be the global one and it'll move like this. 163
So to fix this, what I did was just the short here animator a parameter, and that parameter gets added 164
to the correct direction. 165
Now let's look at the systems that make the player work, and let's start with the mouse target, because 166
this one is the smallest. 167
So in here, as you see, it's just the 22 lines of code. 168
So nothing special. 169
But what it does here, it takes the current active camera. 170
So regardless if it's the top down camera or the player camera gets referenced here, basically what 171
the script does is create the array from the cursor on the screen to a position in the world and then 172
checks if there was an intersection. 173
So we first need to get the mouse position and we create the array out of that one. 174
And then we use the space state, which is good of functionality to be able to intersect the array. 175
And if there was an intersection then we need to put up the lookup position and this one will be used 176
to actually move the turret around. 177
But there's also a debug function and then this is just a small target. 178
It's invisible now. 179
But if we added a mesh, let's say cylinder mesh, it doesn't matter. 180
And save it. 181
We can see actually where the cursor points on the screen. 182
So this is just for debug purposes, it doesn't have any use. 183
Okay. 184
Now let's remove this because we don't want this functionality. 185
So now let's head over to the weapon system. 186
And what the weapon system does is basically first it gathers input from the player, which is the leftmost 187
button. 188
When it's clicked, instantiate a projectile at the tip of the turret. 189
It handles the cooling down or the reload rate and also plays some animations and effects. 190
Let's go into it and see how this all works. 191
So the first thing that this group does when it initializes, it takes all the turret children and checks 192
if they're five points, basically, if their name has five point in their name. 193
And this is because, as I mentioned, if the turret has multiple fire points, it will cycle through 194
each one of them. 195
And these are the two variables that handle this. 196
So the fire point is actually a list that will contain all the fire points. 197
And the fire point index is basically a number telling which fire point should be fired at this moment. 198
Next, we get the animation player, which is this one. 199
So we need to go up two levels. 200
So the first one would be systems and the second one would be player. 201
And then we need to go into the player body and then the animation player. 202
So this is how we get referenced in animation player. 203
Of course this is hardcoded, but since this won't change, it's fine. 204
Next. 205
We also hook the weapon. 206
Cool, long timer. 207
And the weapon called Long Timer is basically just the go to timer that has specified a wait time and 208
one shot. 209
It doesn't auto start because we want to make sure when the weapon coolant actually happens in the process, 210
which happens every single frame, we just need to check out. 211
If the fire was pressed and if it was, then of course we need to actually fire the projectile. 212
And what happens when we fire a projectile? 213
Well, first we need to check if it's not actually cooling down, because if it is cooling down, we 214
don't want to fire another projectile. 215
Otherwise the player can just spam the leftmost button and it will fire projectiles in. 216
Definitely one thing here, the action just press that means that it needs to be released. 217
If we use is is action press then we can make this work just by holding the most button so I don't have 218
to actually release it. 219
I can just hold it and the player will shoot at the fire rate that we specified in the timer, which 220
is 0.5 seconds. 221
Actually, this is better. 222
So I leave it like this. 223
So what happens when it's not cooling down? 224
Well, two things happen. 225
First, we instantiate the projectile, and then we restart the cooling down functionality. 226
So let's look at the instantiate projectile. 227
So here we need to take the projectile prefab, which is specified here. 228
So export variables are variables that are visible here. 229
And the projectile prefab is just another different good option that's being dragged up from the file 230
system into here. 231
And we use instance to create the new instance of that projectile. 232
Once you do this, the projectile is not actually in the scene. 233
So by using get three root get child, you actually get the main scene route. 234
And why don't we just add the child here? 235
Well, we could add the child here, and technically it should work. 236
But just to make sure it's better to edit at the root level because of the transforms and the position 237
and we have a deep hierarchy of nodes if one no changes the position, for example, when the developer 238
moves the player like this, well, the whole hierarchy inside will actually get position changes because 239
of this. 240
So in order to avoid any kind of issues, we just add it to the main route so that we know that zero 241
is always zero and vector 3.0 is hold is 000. 242
Next we get the current farpoint and as I mentioned, the Farpoint index cycles through all the five 243
points and we need to do the cycling as well. 244
So of course we actually increase the Farpoint index only if we have multiple far points. 245
And then if it reaches the five point position, that means the last one. 246
Then we need to go back to zero and then restart the counting from the beginning. 247
So once we have this in place, we can properly initialize the projectile. 248
And the the projectile in show zation has multiple steps. 249
Of course we need the current fire point, which will give the projectile its initial position and rotation. 250
It'll also give the lookout position, which is the most target. 251
And this is important because the projectile needs to be aimed at this position. 252
The damage can be specified at the projectile level, but it can also be specified that the player level 253
for simplicity. 254
So if you have multiple objects that get instantiated in the player, if you put it up to the player 255
level, then it's easier to customize everything inside. 256
Next, we also specify the color of the project that lands. 257
Since we know this functionality is just for the player we can hardcoded to green team color because 258
the player is green. 259
And lastly, we get the player body, which is the kinematic object. 260
And this is important because we want to avoid the collision from the projectile to the actual player. 261
So by checking for the collisions with the parent and removing them from the beginning. 262
Lastly, in this function, we do a smoke and a muzzle effect and those two are just the visual effects 263
and they spawn at the current fire point and the current fire point origin. 264
So basically nothing special, just the VFX manager handling some nice VFX for us. 265
Next we have the start cooling down and the start cooling down. 266
Basically a variable that tells, okay, now it's cooling down. 267
Then we do a random number generator and this is just for to make it a little different every single 268
time. 269
So this actual wait time doesn't matter because we specify the cooldown from 0.30 5 seconds to 0.70 270
5 seconds and they do a random between them and then we start to call them with that value in place. 271
Of course, we also play the animation turret fire. 272
This could happen at any point. 273
Of course not before this, but here should be also fine to be played. 274
And basically these are the functionalities that make up the weapon system handling the shooting for 275
the player. 276
Now that we know how the targeting and the firing works, let's have a look at how the player moves. 277
To do this, we need to head over to the player mover. 278
And this one is a little big, but don't worry because it's very nicely separated. 279
This will be easily accessible for everyone interested in finding out more how the player moves. 280
But before we dive deep into it, we need to understand what are the exact functionalities of this strip? 281
First it moves the tank up, down, left and right, and please note that these are no top down, left 282
or right for the tank. 283
But from the perspective of 45 degrees, you will understand what this means a little later when we 284
actually see the code. 285
It also applies the gravity. 286
In this case, it's not really necessary because the whole thing is flat, but it does apply gravity. 287
So in case your terrain has hills or valleys, it will work as good as on the flat one. 288
It also what is the turret towards the most intersection the world from the most targeting system and 289
also applies some nice rotations when the tank fires. 290
They're not important functionality wise, but they're important visual wise for the player to actually 291
feel the power when the tank actually fires. 292
So here we just get some parameters in the ready, but everything gets processed in the physics process 293
and it's nicely put in different functions and we'll go into each one of them and see how it works. 294
So first we need to process that direction and get it into this vector. 295
And the direction is basically where the tank is headed. 296
If the player presses one of the following keys, move up, down, left or right specified in the player 297
input in the configuration. 298
So here the tank doesn't move forward back from its own position, but rather if we go to the demo scene 299
and we go to the camera, you can see that here is the tank. 300
So it moves up from the screen, down from the screen, left and right. 301
And these adjustments are actually made in code like this. 302
So for example, if we move up, it's a combination between vector left and vector back divided by two. 303
What gets returned by this process direction is a normalized vector, and that means the vector fling 304
F1 specifying the direction or zero. 305
If the player doesn't press any key where the tank should move next, we need to process the turret 306
and this one does the turret rotation towards the target position. 307
Let's look how this happens. 308
So first we get the target position and as I mentioned, we get the most target and target. 309
And is this one we actually could have gotten it from the code since we have look at the position. 310
So instead of getting the target, we could just get the most target and value look at position. 311
And this is actually better. 312
So I'm going to. 313
Fix this right now. 314
And why is this better? 315
Well, it's because this is mostly for debugging purposes. 316
And if you say, okay, now I'm removing the debug stuff and this gets removed, then this won't work 317
anymore. 318
So it's very important to make it work without the debug as well as with the debug functionality. 319
We need to preserve the scale of the turret. 320
And this is important because all of the transforms that means the position, the rotation and the scale 321
do happen when using different functions on transform, and sometimes the scale might also get messed 322
up. 323
So we need to preserve it and then reapply it a little later. 324
So first we preserve it and then we generate the new transform. 325
So it's not actually we don't use the look that we use looking at which will actually give the new transform 326
to the target position. 327
And this is important because I'm using this interpolate we have, which makes the turret move slowly 328
or smoothly towards the final rotation instead of directly moving to that particular position. 329
And this gives a nice feel for the player. 330
Once this is finished, of course, we reapplied the skill. 331
And also unwanted rotations, because, for example, if we remove one of these and we point close to 332
the tank, the turtle also points down. 333
So we might avoid this. 334
But in case your game has heels and the third needs to rotate up or down, you might want to remove 335
these rotations, or at least the one that handles up and down movement so that the turret can properly 336
rotate. 337
The other one will tilt the turret. 338
So it should always be zero because the turret cannot possibly tilt. 339
Okay, Leslie, here. 340
Once we set up the look at position, as I mentioned, in the tank mesh, we have the tank third position, 341
which needs to be synchronized as the final third position. 342
So we need to set that in place. 343
This is the final third position. 344
But on top of this, we also have getting the turret forward vector which is this long line and multiply 345
this by the turret animation forward and this is the value that gets animated by the animation player 346
and originally it's just zero. 347
So all of this is not used. 348
So the turret gets positioned right on top of the tank body, but when the turret actually fires, then 349
the small animation gets played. 350
So this value changes from 0 to 1, so the turret slightly moves back and forth. 351
So if we quickly play it, you see that the turret doesn't doesn't move forward or back, but if we 352
fire, the turret starts moving forward and back. 353
So this happens because of this line. 354
So now that we have the turret rotation, we can move to the tank. 355
Rotation as well. 356
So the tank rotation. 357
What does it do? 358
It basically rotates the tanks, buddy. 359
So not the whole thing. 360
It just rotates the tank mesh. 361
And this part just the tank by the from the tank mesh because as I said, the turret rotates separately 362
and we don't want to get involved in the player body because some other systems are here. 363
So when does this rotation happen? 364
Of course, we need to make sure that the direction vector is actually a length of greater than zero, 365
because if it's zero, then that means the player didn't press any key. 366
And if a key was pressed, then the direction is either up or down, left or right relative to the tank. 367
And the player body needs to look at that new position and we do the same as with the turret. 368
So we use the looking at to generate the new transform and then we do nice interpolation of that. 369
We have a 2.5 multiplied by Delta. 370
This will assure a nice smooth rotation. 371
Of course you can change this value to make it rotate faster or slower. 372
Of course, to reset the zero rotation to make sure that the tank doesn't rotate up or down as well. 373
Though if would play this, if you look closely at the tank body, if I press up. 374
It doesn't move directly. 375
It moves. 376
It moves with a certain rotation speed. 377
You see how the body moves? 378
It moves so smoothly because of that interpolation. 379
So if you change the value from 2.5 to another one, it will move either slow or fast based on that. 380
So this this doesn't actually move the player. 381
It just rotates the tank, buddy. 382
The player movement happens in the next function. 383
So here, if we go back, this was the tank by the rotation and the move tank is actually what moves 384
the tank. 385
So here, of course, you know the drill. 386
If the lack of direction is greater than zero, then this means we actually have movement and this means 387
we actually have a velocity. 388
And I don't want the velocity to be instantaneously fast or slow. 389
So for this actually opted for acceleration and friction. 390
So what it does it linearly interpolate what the interpolation does. 391
It takes the current velocity value, which in this case should be zero. 392
And the maximum speed, the direction, times speed and the acceleration is what we are multiplying 393
with at every frame to get that velocity to that point. 394
So basically with this, the tank will accelerate to its maximum speed, which is the speed. 395
If there is no quick press, then it will decelerate with the friction. 396
Of course you could have used acceleration, but that would have been weird because as you know, a 397
car might accelerate at different rate as it slows down with the friction. 398
Of course, velocity on the y axis is always -15 or whatever gravity you want to put into this. 399
And lastly, we use the moving slide functionality from Godot. 400
And here we specify the velocity that we just calculated. 401
So this is just the vector three. 402
We have its x and Z components based on the direction and the Y component based on the gravity. 403
And also we need the up vector here. 404
So this will handle the tank movement. 405
And lastly, we have the preposition collision shape. 406
And what this does is actually move and rotate the collision shape to fit the new player position. 407
Why is this relevant? 408
Well, let's see if I comment this line. 409
And they use debug visible collision shapes. 410
Press F5 And as you see, the collision shape is okay right now. 411
But if I move it like this, oh, the collision shape is not in work. 412
So if we go for object, you see that the tank goes through buildings because the collision shape is 413
basically wrong. 414
So if I d comment this back and now we can see that the collision shape nicely moves with the tank. 415
So this is the behavior that we are looking for. 416
So how does the reposition collision shape work? 417
Well, we simply put the new origin of the collision shape to the player tank by the origin, and then 418
we move it slightly on the forward vector. 419
So please know that the fore vector is this with minus. 420
So I'm just putting the minus here in this case. 421
And this is not divide. 422
This is just to go to the next line, because we add this also on the Y axis, because otherwise the 423
collision will go for the floor and we need to be careful. 424
It doesn't do that. 425
We also need to sync the rotation. 426
So this is the slide for this is what makes the collision shape synchronized correctly with the tank 427
body. 428
And lastly, we do have the helper functionality which checks if that is on the on the tank side or 429
the other. 430
And this was responsible for the. 431
The tank body rotation. 432
So this is actually for visual purposes. 433
This is why I haven't been into this before. 434
But what this does, it checks if it's on one side. 435
So this is the X or minus X. 436
So basically left or right side. 437
And if it's one or the other, then it gets thanked by the rotate, which is also a value that gets 438
changed by the animate there when the firing sequence happens and the trot is the tank, by the way, 439
like this or like this. 440
So how does this work quickly? 441
Well. 442
It's a little complex, but I'm going to quickly show it. 443
So first it takes the thing by the opposition and then we get the target, which is the tank turret 444
position and then we get the forward vector of the tank turret. 445
So basically this is where the tank is pointing towards. 446
So now we have a position forward from the tank turret and the current position and this will give us 447
the reference vector. 448
So basically this is just the vector from the tank origin to where the turret is pointing towards multiplied 449
five. 450
And of course, you need to normalize this and the phrase the DOT product and this is a nice functionality 451
for Will because. 452
The DOT product will be zero for a straight angle and greater than zero for angles, narrower than 90 453
degrees and lower for wider angles. 454
So we can check this dot product result of the difference vector to see if it if it's between an angle 455
or not. 456
And what this does in and in practice is that, for example, the angle now is a position that we want. 457
But as we move inside, you'll see, oh, the animation stopped. 458
So here it's where the angle for this side stopped. 459
And then if I move. 460
If I move. 461
Now. 462
Now, the animation started. 463
So this is. 464
This is basically the value that you are calculating. 465
So this one is the value. 466
And if the normal that the product, the value of this one is within the range, that it will it will 467
give us the result we wanted. 468
If not, nothing will happen. 469
So basically this is what this function does as well. 470
So this is the player functionality. 471
I hope you liked it. 472
It's a little big and some of it is just for polishing. 473
So it's not for functionality. 474
But do remember that in finalized game products this is super important. 475
So make sure that your game has visual effects like these. 476
This is it for this video.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.