Unreal engine 5 blueprint Create Tank and artilleries Course | Navid Ansari | Skillshare

Playback Speed


1.0x


  • 0.5x
  • 0.75x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 1.75x
  • 2x

Unreal engine 5 blueprint Create Tank and artilleries Course

teacher avatar Navid Ansari

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

    • 1.

      00 Promo

      2:07

    • 2.

      01 Create and import

      3:43

    • 3.

      02 Tank gamemode

      2:19

    • 4.

      03 Wheel setup

      6:34

    • 5.

      04 Engine setup

      4:17

    • 6.

      05 Look up and down

      3:54

    • 7.

      06 Look left and right

      1:15

    • 8.

      07 Going forward

      3:37

    • 9.

      08 Going backward

      2:59

    • 10.

      09 Wheel animation

      3:05

    • 11.

      10 End wheels

      5:49

    • 12.

      11 Tank tracks

      9:09

    • 13.

      12 Tank track position

      6:39

    • 14.

      13 Going left and right

      3:07

    • 15.

      14 Track animation for turn in place

      5:42

    • 16.

      15 Handbrake

      1:50

    • 17.

      16 rotate turrent joint

      2:23

    • 18.

      17 Calculate delta rotation

      3:26

    • 19.

      18 Gun pitch

      2:51

    • 20.

      19 Crosshair widget

      3:32

    • 21.

      20 Crosshair location

      6:37

    • 22.

      21 Tank projectile

      3:15

    • 23.

      22 Fire gun of tank

      2:49

    • 24.

      23 Gun visual effect

      3:18

    • 25.

      24 Add torque when firing

      4:00

    • 26.

      25 Fire recoil

      5:25

    • 27.

      26 Reload progress bar

      7:14

    • 28.

      27 Projectile explosion

      5:30

    • 29.

      28 Engine sound

      8:33

    • 30.

      29 Tank tracks sound

      4:43

    • 31.

      30 Tank UI widget

      5:19

    • 32.

      31 Import Arty files

      2:44

    • 33.

      32 Blueprint for Arty

      2:34

    • 34.

      33 Distance to tank

      4:43

    • 35.

      34 Target in range

      2:25

    • 36.

      35 Rotate arty

      1:57

    • 37.

      36 Predict where tank will be after one second

      4:16

    • 38.

      37 Arty Rotation

      4:10

    • 39.

      38 Arty projectile

      7:07

    • 40.

      39 Arty fire VFX

      4:08

    • 41.

      40 Arty gun motion

      5:13

    • 42.

      41 Apply damage in radius

      3:58

    • 43.

      42 Tank Health system

      7:08

    • 44.

      43 Health bar

      5:56

    • 45.

      44 Destroy tank

      3:30

    • 46.

      45 Arty get radial damage

      3:12

    • 47.

      46 Arty get destroyed

      3:57

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

31

Students

--

Projects

About This Class

In this course we will learn everything about how to create a tank game that we start from defining engine , wheels and then we start with movement of our tank

we will add sound and lots of VFX to our game

then we will have some UI for having health bar and reload bar and rotation of turret UI

next we will add artilleries as enemy that can predict tank movement and shoot at it

Meet Your Teacher

Teacher Profile Image

Navid Ansari

Teacher

Hello, I'm Navid.

See full profile

Level: All Levels

Class Ratings

Expectations Met?
    Exceeded!
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. 00 Promo: In this course, we're going to create a tank game. First, we stop with the engine and the wheels. So we can move our tank. Next, we will have the wheels Animations. We will use animation blueprint and chaos plugin for our tank. So we have cool animations. We will have a turning place that have its good animation. We will have handbrakes. So whenever we are moving, we can stop much faster. We can do lots of maneuver with our tank. Next, we will go and try to shoot the gun of our tank. So wherever most is aiming at, we can shoot there. We will have lots of visual effects for shooting our gun. Some nagor effects and some recoil. So whenever our gun is shooting, the gun of our tank will go back and forward. And whenever we shoot our gun, there will be a force impulse force applied to the body of our tank. Next, we will go for sound. So whenever our tank is moving, we should have right sound. For example, if you start slowly when ortank is stopped, there should be idle engine sound and it is moving, based on the speed, the sound of the engine should show that. Sound like it's moving faster, right? The engine wraps up, right? We should have that sound. Next, we will go for some UI, for example, the crossir UI, at the right of it, we will see if our gun is reloaded or not, and at the left side of it, we will see the health of our tank. And on bottom left side of our game, we will see rotation of our turret or tank can be destroyed, so we will implement that as well. After that, we need an enemy to be able to shoot at us, right? So for doing that, we will create a artillery that can shoot at us. It can predict where we will be after four second, for example, and it will shoot there, so it will hit our tank, and we can destroy that artillery as well. In this artillery, we have lots of visual effects. For example, the shock wave that every time the artillery shooting, there should be a visual effect for the shock wave beneath it, and after that, there will be a recoil for this one, as well. So the gun goes down and up whenever the artillery shoot. And at we can't destroy the artillery. So without any further ado, let's begin this course. 2. 01 Create and import: This section, we learn how to create a tank game. For doing that, I'm using ARL Engine 5.5 0.3. So download that, and my recommendation is to use the same version as I'm using because ARL Engine developers change stuff, change the node names a lot, use the same version as I'm using. Open AIL Engine, go to Games, and in here, click on Blank. We want to start from blank. Put that wherever you want, and I want to call this project tank or whatever you want to call it. I don't need to change anything. The blueprint is more than enough, the quality preset maximum, the target platform, desktop, and we don't need the starter content. Head create to create the project. While it's creating at description of this video, there is a Zip file that is called Tang dot Zep, right? You can see it over here. Download it, put it on your desktop, right click on it, and head extract all if you are in Windows 11. But if you are not in Windows 11, you can just open it in Windows ten or use WinRAR to extract it or copy it, right? We have a folder that is called Tank, drag and drop it. Put it on desktop, so it will be extracted. Let's just put it over here. We don't need this anymore. Now, go to the project that it did create in here, go to Content drawer. Click on this content folder, right, click on it, showing explorer. So you go to content folder like this. Make sure you are in content folder. After that, you can click on this tank folder, control C to copy it, and Control V to paste it over here, and that's it. You have all the necessary acid in Aga engine. Go to tank assets. You can see we have some images. We have some sounds that you want to use. We have a vehicle. For example, it is this one. It has a skeletal mesh. So let me open it up in here. You can see this is the tank that you want to use, and there are some other stuff as well, like some Nia graphs. So know what else? We need to go to edit, go to plugins, and in here, search for chaos and go down in here until you reach chaos vehicle plugin, enable that, it s in here and make sure you restart the project completely. It's very important to restart the project. Another thing that I want you to do, go to Edit, go to Editor preferences, and in here, search for open and asset editor open location, I want it to be in the main window. So whatever we open, it will be open in here, not in another monitor or whatever, right? Next, in our level, head control is to save the level. And in here, I want to create a new folder and I want to call it levels. We want it to be organized. And in here, you can just call it whatever you want. I will call it new map, head save. And no over map will be saved as New Map, and it will be open. Now next thing, go to edit, go to project setting, and in here, go to maps and modes and change the Editor starter map and Editor template map override to New Map. Both of them to New Map. So whenever we open the project, it will be opening this level automatically. Now all the assets are inside ARIO engine, and ARIEL Engine is ready to create over tank game. We can do. 3. 02 Tank gamemode: No first thing to do, we need to create a blueprint for over tank. So we can put it there, right? So for doing that, go to Content drawer and in here in tank folder, I want to create a folder and I want to call it blueprint because I want everything to be organized. So in Blueprint, I want to right click, go to Blueprint class, and in here, go to all classes in here and search for wheeled vehicle punt. This is a part of the plugin, the chaos plugin that we enabled. So you need head slice, and I want to call it BP tank, right? Dot click on it to open it. And you can see the parent glass is wheeled vehicle pawn. And it has vehicle movement component inside it, and we have a mesh that we can decide which mesh to be there, right? So click on it, and in a skeletal mesh asset, choose over N O tank. And this is our tank, right? Make sure you are choosing NO tank because we have three of them. You need to just choose N one tank, not the other one. Now, with that done, let's just had compile, save. And what I want to do, I want to go to Content drawer and create a game mode. So right click in here, go to Blueprint class and in here, choose game mode base. I want to call it BP. Tank game mode. I'll click on it to open it. And the only thing that you need to do in here for default punk class, I want to change it to BP Tank. Now we have a game mode that we can use, right? So for using that, we can go to edit project setting and go to maps and modes and in here, change the default game mode to BP tank game mode. Now with that, if we go to save and save everything and close the project setting, no with that done, let's just head play. You can see the tank is in here. And if you eject, you can go and look at the tank. That doesn't look good, right? But we will fix that. Don't worry about it, right? No. Our game mode and our blueprint is working fine. Now, let's see how we can make it work. 4. 03 Wheel setup: First and first, we want to define the wheels. But the problem is, it has too much wheel. You can see it over here. What I want to do I want to open up the skeletal mesh first in here. Just open it like this. Dull click, and you can open up the skeleton from here or you can just see the skeleton tree in here, right? So in here, we have some wheels. If we search for it, it will be easier. So search for wheel and you can see we have this wheel. Let's just see this wheel that we can't see it completely, we have wheel nine. You can see it over here, we can rotate it, right? At the end, we want to do that, right and we have the right ones as well. This one was for left wheels and this one for right wheels. But we have track joints. You can see it in here that you can see, we can move it. It looks like this. We don't want to do that. But as a child of that, we have wheels as well, and this is the wheel. Again, we want to move them. So all of these wheels, we want to define it inside our blueprint, but not in vehicle movement component. A use chaos vehicle. So in here, click on ad and search for chaos chaos wheeled vehicle movement component. And these allow us to have more than four wheels. We can have as many wheels as we want. So in here, how much we have? We have one, two, three, four, five, six, seven, eight, and nine. T multiply by nine, it's 18, right? So let's just add 18 in here. In wheel setup when we click on KaoS vehicle movement, right? So let's just add it there. That's it. 18 wheels. And if you expand one of them first, we need a wheel class after that a bone name. For the bone name, we can just go here. Let's just do the left wheel first, left wheel, this one first, copy bone name and put it over here, right? That's it. Now, for wheel class, we need to create it. So for creating that, I want to go to tank in Blueprint. Right click Create Blueprint class again in here, chaos. Go down. Chaos vehicle wheel. Just choose that CVW four chaos vehicle wheel. I want to call it tank wheel. Okay, set. If we don't click on it to open it, we have some options that we can change. The collision mesh cylinder is more than enough, but the wheel radius, you can get it from blender, for example. But in here, I want to put 36. You can just play with that. After that, I want these wheels to be affected by handbrake because we need handbrake we wanted to be able to change the rotation with the engine, right, and we need the ABS enable as well. That's it. Let's just head compile, save. And another thing that I want to have in here, we have roll bar scaling that it is until rolling, so it won't roll really easy. So I want to increase that to one. At maximum, so it don't roll. That's all we need to do for this. No, we can use that inside or wheel set up in here. Just click on it over here and you can use this arrow in here to set it there. CVWTank wheel, right? We did that for this one. No, let's just do it for the other one. If you go here, we did that for left wheel 01. We want to do it for left wheel 02. I want to go after each other. One, two, three, four, right? So this one again, put it over here with Control V. That's it. This one is good. Now the wheel tree. Let's just look at it. The Wheel tree is here. Copy bone name, right click on, right click on it, copy bones name, and put it in here and click in here to put the wheels there. We done the three. We want to do the four. We can just increase it by this because the naming is good. So we can just paste this. We did that 43. Now, we can just change this to four and click in here. So it will be faster, right? This is the fourth one. This is the fifth one. So let's just do that fast and click in here. This one is done. We have nine of them. So we go until we reach the nine. This 16, click in here to put the wheels there, put it over here. This one is seven. Again, put the wheels there. Make sure you do this all right. Don't make any mistake in here because it will cause you a lot of problem. This one is for eight and put the wheels there, and this one is for nine and put the wheels there. No, we have done the left wheel. Let's just do the right wheel. For doing that, we need to do the right wheels now, right click on this one, copy bones name, put it over here. This is for the right wheel one. Put the class there, and that's it. No, this is two. So let's just put it there and put the class there in here as well. This is three class there. If you don't expand it, sometimes you can make some mistake. So just leave it as it is. This is four and put the class there as well. Again, put it over here. This 15 and put this one there. I did it for five. Now it is six. That there it. And let's just do it over here. Seven there. And now, in here, eight, and in here, this is nine, and it is finished, right? D check everything so you make sure you don't make any mistake. So you can see everything is good for the right wheels as well. Now with that done, the wheels are set up. We need to go to set up the engine and all of that. See if we can do that next. 5. 04 Engine setup: No, we need to do the engine setup. For doing that, again, click on the KaoS vehicle wheeled vehicle movement component. In engine setup, you can see we have a curve in here that we can tell it how torque can be changed, how the engine can v, right? So what I want to do, I want to add a key in here at time zero, let me make this bigger so you can see it better. At times zero, I want it to be zero and another key in here. At time five, I wanted to go to one. So what it means, if I click in here, you can see it better. So what it means, it means from zero to max torque, it takes 5 seconds because tank can't go that fast really hard, right? It takes time to go to that max torque max speed, right? I want to change the max torque to 2,500 because the mass over tank is a lot. That's why I'm putting this value there, but you can just test with that. And engine idle RPM, I want to put it on 800. Next, I want to go down until we reach the mass. Mass of this much is not a lot. That's why I want to change it to 5,000, right? 5,000 for this is good. You can increase it and test with it later, right? Next, I want to go to torque control. If you go down in arcade Control, torque control, make sure you enable it. And because we want to be able to change the ya I want to put some value in there, like 2.5. We can change it later and you can test with that. That's it for no for this one. No, next thing that I want to do, I want to click on or mesh, and in here, go to physics, simulate physics and tell it to simulate the physics. Now, let's just compile and go to our level and run. No, you can see, it's working better. You can see right now, the wheels are at the right place, and it's holding itself correctly. That's good. No next thing that you want to add, we want to add a camera, a spring arm, all of that, right? So click on Add first, add a spring arm. Just add a spring arm in here as a child of the mesh. Now, let's just go up in here. The target arm length, I want to increase that to, one, two, 50, right? So it will be back there, right? We can add a camera so you can see it better. Add the camera as a child of a spring R, you can see it. No, I want to add some offset to Y and Z, as well. Of course, you can decide what you want to do, but in this case, I think it looks better. And I want to bring the middle a little bit up. You can see it right now it is at the feet of or tank. So I will bring this spring arm up with location Z. A 100, for example, no, you can see it at middle of the tank. That's good. Next thing I want to use pawn control rotation. So whenever we change the control rotation, this spring arm rotation will change as well. So with the most, we can look around as well. Next, for making it looks better, I want to enable the camera and the rotation as well. So it looks much better. And that's it that's all we need to do. Let's just head compile, save and run over game. No, you can see it. That looks awesome, I think, right? We can bring it down a little bit. We did add a lot of offset to it. So offset Z, let's just decrease it, so we'll be able to see the tank better. Now, you can see, I think that looks good. I want it to look like that. But if you want to put it exactly at back of the tank, you can do. Just delete this offset. Delete offset Y, right? Now, if I run, you can see it's at the back of the tank, but I think this way it's looked much better like color of duty and battlefield game, right? R n or Tank is ready to write some code. Let's do it in next video. 6. 05 Look up and down: Next thing that you want to do with or tank, we need to be able to look around up and down left and right. Let's see if we can do that. For doing that, we need enhanced input. So let's just go to tank in here. I want to right click, create a new folder and I want to call it input. Okay? And in here, first and first, I want to go to input and create input mapping context. I want to call it IMC tank, right? And I'll click on it to open it. It will be open over here. We can just close these ones, right? After that, let's just go to Content drawer, right click, go to Input again and go to input action. I want to call this one I look up down for looking up and down with most. Do click on this one to open it the value type because either we are looking up or looking down, we need to change these to float or access one. You can just save it, close it. Now in here in IMC tank, we need to map it. Click in here to add the mapping, and the one that you want to add is look up and down. And how we want to do that, we want to do it with moose Y. So go to moose in here and choose Most Y. That's it. With that, I want to go to BP Tank. And at the begin play, I want to get player controller first because you want to tell the player controller. To use this enhanced input, right? So we get the enhanced input off of this like this and we add the mapping context to it, right? The mapping context that we create together. So let's just connect it there. Select acid, the IMC thank. Now with that, right click in here, we can just search for I L up, down, right? That's it. Now with that done. Let's just show it with the printers to see if it's working fine or not with action value connected to the inner string. If we run over game, no with the most, I can go up, down. You can see it gives us a value between minus two and two sometimes because it can't get more than one. So no with that, we want to change the pitch of our controller. So the a spring arm and the camera will change the pitch as well, because we clicked on a spring arm and we tell it to use pawn control rotation, right? So we can change the pitch of our controller to change the pitch of a spring arm. And the pitch, as you know, is rotation around the Y axis for looking up and down, right? So in here, we can just say add controller. Pch input, right? And the value, we can just connect the action value to here. Let's just compile and run. No, you can see, I can look up and down. But the problem with that is it's inverted. If you want it to be inverted, just stick with that, but I don't want it to be inverted. I can either multiply this by minus one, but I can go to IMC in here and in here, add a modifier of type of negate. This way is much cleaner to do. Now with that done, no let's just run or game, you can see, I can look up and down, and it's working fine. No, I want to give you a challenge. Try to do the look left and right. Just think about it. Rotation around the Z axis, that is called Ya. Create an input action and implement it in BP tank so we can look left and right. You try to do that. We'll do it in next video. 7. 06 Look left and right: No for looking left and right. As you know, we need to add input action for that as well. So right clicking here, go to input, create input action and I want to call it I look left, right, okay? And as you know, the value type, we want it to be axis one D float because either we are looking left or right. So Acess one d is more than enough. Make sure you save, go to IMC tank and add it there, map it there, right? So we want to do the left to right, and we want to do it with mouse X. That's it. Now we can go to our BP tank and in here, search for a Look left and right, the event of it. Now, for looking left and right, it is a rotation around the Z axis that is called Ya. We need to add controller Ya input with the value that this will give us. This event will give us. With that, let's just compile, run, now you can see, we can look left, right up and down, and that looks good. Now let's see how we can move over tank. 8. 07 Going forward: Now let's see how we can actually go forward. I can do forward and backward in one input action, but it will be hard for beginners to understand it. So that's why I want to use two input action, one of them for going forward, and one of them for going backward. So for doing that, I want to go to Content drawer and in here, I want to right click Go to Input and create input action. And this one, I want to call it a forward. That's it. D'll click on it to open it. The value type, we want it to be axis one d, a float right. That's it. Now, in IMC tank, we want to map it. So click in here to add a new mapping. Click in here. We want to map the I forward. So when do we want to go forward? Click in here, Heat. When we head TL you on our keyboard, we want to go forward with or tank. So let's see how we can do that. In here, if I write, click and search for I forward, I have a event for going forward, I forward when we hit W, right? So this action value will give us a value 0-1, and how we can go forward, there is a node inside chaos wheeled vehicle movement component that we can use. And it's called set Trottle input. You can see there is two of them in here. One is for vehicle movement component. Because we have more than four wheel in our tank, that's why we did use chaos wheeled vehicle movement component. So we have two of them. We need to use set rottle input for chaos wheeled vehicle movement component. So click in here and that's it. This is the one that you want to use chaos wheeled vehicle movement component, right? So the throttle, we want to use this action value. No, if you hover over this node, you see it set the user input for the vehicle trottle the range is 0-1. So it don't need a value between minus one and one. It needs just a value 0-1. If you put one, it will go forward. If you put zero, it won't go forward, right? So, no, but just check that out. If you run we game, no, if I hit W, you can see it's going forward, and you can see the speed is too much. And if I leave the input, again, it will go forward. Look at it. It's beautiful. It's flying now, right? So now, let's see how we can stop it. For stopping it, whenever we release dolly key on our keyboard, this completed will happen. And we want to set the throttle input with that to zero. So copy and paste this set throttle input with control C control V to paste it over here. Whenever we release the W key, we want to put the throttle to zero. That's it, head compile and run. Now, if I T, it will go forward, but if I release it, it will wait, right? So again, we can go forward, and if we release it, it will wait. And right now, it does look good, right? It's moving good, so that's it. That's what we want it to happen. Now, let's just see how we can go backward because right now, if we hit S on or keyboard, it won't go backward, but we can go forward, right? So in next video, we will do going backward. 9. 08 Going backward: No for going backward. Let's just go to content drawer and create input action for it. Go to input input action, and this one is for going backwards, so I will call it I backward, right I'll click on it to operate the value type, you want it to be aces one D because we are going just backwards, right? So that's good. Now add mapping or IMC and map D going backwards, I backward. In here, click in here, head S, so you put S in there. So whenever we hit S on or keyboard, this I backward will pass one to the output, right? So let's see how it happened. I right click in here, search for I backward, right. And now with that, let's just use a print test ring and connect these to here. You can see when I hit SN or keyboard, it will give us one. That's it. That's what we want it to happen. There is a node for going backward inside this chaos wheeled vehicle movement. So get this and the node is set break Input. I know it's for breaking, why we are using it for backward, I don't know why they name it break. So we can use it as break as well. So connect the execution pin, connect the action value, right? No, again, if you hover over this, you can see it is value 0-1. If you put one in there, it will go backward, and if you put zero in there, it will stop. It won't move anymore, and it can't get a minus value, right? So that's it. Let's just he compile, save and Runo game. Now, if you had SN or keyboard, you can see it's going backward. But it's going backward. Again and again and again, and it won't stop. Let's just fly with it a little bit, waiter. So we reach the mountains in here. Ah, you can see. That doesn't look good. So no, again, like we did it in here for going forward, we need to do it for backward as well. Whenever the complete happen, it means we release the SK on our keyboard. So we can copy this set break input with Control C control V pase it over here and change the break to zero. Whenever we release S on our keyboard, let's just compile and run. If I hit S, you can see, I'm going backward, and if I release S, you can see it will wait. Again, if I hit W, I can go forward. I can go backward and you can see the animations. It does look good. But no, it's time to actually rotate the wheels and these tracks, right? Right now, it's not moving. None of them is moving, so we need to move them. Let's see how we can move them in next video. 10. 09 Wheel animation: No over tank is moving forward and backward, but there is no movement in the wheels. So that's why it doesn't look good. Let's see how we can animate the wheels. For doing that, you can see, if you click on the mesh, this is a skeletal mesh that we can decide a anim class for it. So for doing that, I want to go to Content drawer, go to Blueprint folder in Tank folder, and want to right click create a blueprint class, go to all classes and search for vehicle animation instance. That's it. It's a child of an instance, but it's called vehicle Animation instance. Head select to create it. I want to call it ABP Tank. Okay? ABP for Animation blueprint. Do click on it. To open it, it will tell you that there is no skeleton in here. Do you want to choose? You say yes. And in here, choose our skeleton for our tank. Head to okay no, it will be open just like that. Make sure you save everything. Like always, we need mesh space, f pose. So we have access to all the bones informations. And after that, for these wheels to be able to move, we need to add wheel controller for wheeled vehicle. That's it. That's all you need to do. A Ao engine will do the rest for you. And know with that, make sure you save, go to BP Tank, click on the mesh and choose the anim class ABP Tank. That's no head compiles, save a run over game. If I go to the wheels, if I W, no, you can see all the wheels are moving, right? Everything look good. Let's just go backward. You can see. If I go backward, you can see it's working fine. One problem that you can see in here, if I W, and waiting here, all the wheels are not moving these two at the end of tracks. You can see they are moving and nothing we can do to stop them. If you go backward again, it's moving. If we are not moving, these are moving as well. So what is the problem? This is like a bug that's happened with this skeleton miss. What I want to do to fix it, I want to just go or a skeleton, go to animation blueprint, go to a skeleton, find out, do those two wheels. I search for wheel the wheel one and nine on the left side and wheel one and nine at the right side is not working good. You can see each rotating doesn't matter if you are rotating it or not, if we are moving or not. So we need to find a way to fix these wheels. For fixing that, I will create another video just for that. So let's see how we can fix it next video. 11. 10 End wheels: No, for fixing those wheels that are moving even if the tank is not moving, we can fix them. For fixing them, first, click on the chaos wheeled vehicle movement. Go to wheel setup. We have four wheels, two on left and two on right that has problem. So let's just find them. The left wheel 01 joint. And if you go down, the left wheel 09 joint. So the left wheel 01 and left wheel 09, it's not working with this wheel setup. So we need to delete it from here. For deleting it, you can just go to that index, click in here and delete it. Now, you can see it start from left wheel 02 joint, and we need to delete, collapse this this is two, three, four, five, six, seven, eight, nine, if we expand this, this is left wheel 09 joint. If you go here, you can see left wheel 09 joint and right wheel 09 joint should be deleted from this list wheel setups, right? So in here, again, go to Index seven at this time and delete that, right? With that, again, right wheel 01 joint. If you go here, we want it to disable it as well. I go to right wheel 01 joint. This is another one that is not working fine, and this is right wheel, 09 joint. These two should be deleted from this wheel setup as well. So right wheel, 01 joint, we want to go here and delete it like this. Now, at the end of this, let me clapse everything. We have right wheel 09 joint. Again, we want to delete that as well. Now with that on, if you head compile, save and Runo game and move, you can see all the wheels are moving, but this one is not moving. That's a good step in the right direction. Now, let's see how we can actually move these. For moving this, we need to go to ABP tank, and in here, I want to use some notes to do that. Know that if you run over game, all the wheels are moving correctly, but the two wheel at the end at both end is not working fine. So we can copy the rotation of these middle wheels and paste it for the end wheels. So let's see how we can do that. There is a node that is called copy bone. Okay? This copy bone needs a source bone, if you go here, source bone, and it needs a target bone. You can see it, right? But we need to just copy the rotation. Let's just do it for the right ones. After that, we will do it for the others. We want to copy the rotation of one bone, one of those middle bones for the end bones. We can do that, we can decide one of the middle bones. Search for wheel if we go here. For example, let's just use right wheel, 02 joint. Okay? And the target bone, the bone that we want to paste the rotation from this right wheel zero to joint to that is let me search for it Wheel. It's called right wheel 01 joint. And I duplicate this one time over here, and this time, I want to copy the rotation for the 09 joint RT wheel 09 joint. Now with that, let's just test it. We had compiled save and run over game. Now at the right side, if I had told you, you can see this bone is rotating with the other bones. This wheel this wheel at the end of the track is rotating like the other wheels that are in middle. That was working fine. You can see now the right one is working, but we need to do it for the left bone node. For doing that, we can just copy and paste these two node and do it for the left one. So this time, we want to search for wheels again. But this time, I want to do it for the left wheel, zero, two, joint, two, left wheel 01 joint. The one that doesn't work good, right? Again, for this one, we want to copy it from left wheel, 02 joint that we know it's working fine. And the target bone, you want to do it for left wheel, 09 joint. Just be careful about this LF for left and RT for right. If you make a mistake in here, it won't work that good, and it will be hard to find the cause. No, I need execution pencil. Let's just give it like this to here. And no let's just head compile. If you run over game, no for the left if I had, you can see, it's working fine, like the other wheels can see everything is working fine and beautiful. It goes forward and backward, like the other wheels, the middle wheels, everything is working fine. Just the problem that we have in here is that the tracks are not moving. The wheels are moving, but tracks are not moving. And moving them, actually, it's really hard. That's why we need to find a workaround for them. Let's see how we can do that next. 12. 11 Tank tracks: Now we want to move the actual tracks with wheels. How we can do that for doing that because our tank can go over things, and these tracks can have flexibility. There is no clear way to do this kind of stuff. The tricks that animators do this kind of stuff is with materials. So if I click on the mesh, you can see there is element one and element two, just for tracks, one for right track, and one for left track that by Default, it did it wrong. Let's just click in here. We have the left track as well. So element two is for left track and element one is for right track. So make sure you fix this because by default, both of them was the right track. And if you open up these elements, for example, the right track, let's just click on this magnifying glass, and I'll click on this in here, you can see there is a offset we RT for the right one because we are in the right one. With this offset, we RT, we can move over tracks. So it looks moving. Right now in here, every time that I'm changing this, for example, to two, you can see it good, but there is a way that we can fix that. Let's just put it on zero. I don't want to save anything in here. For you to see it better, what I want to do I want to right click on one of these and create a material instance off of it. You don't need to do that. I just want to show you something. Don't click on it to open it. Now in here, if you go to Global Scholar parameter values, you can change the offset VRT. And with this, if I change the value, you can see the tracks are moving. So that's how we want to move the tracks with parameters on the material. You don't need to do this. I just wanted to show you. You can just delete this if you have done. So now with that done, let's just see how we can use it. For doing that, I want to go to event because at each frame, we want to change the offset VRT or offset VLT, right? So for doing that, I want to create the Custom event because I don't want to make a mess in here. So I will go down in here and right click search for Custom event. And I want to call it Track. Animation, okay? Trac animation. And now with that hint here, we can call it in even tiqu. So we can say track animation. It exactly like put whatever we want to connect to here to even tik. It's exactly the same. It is just cleaner to do it this way. So no, with that done. Based on the speed of our tank, we want to change the offset VRT and offset VLT, right? So, no, with this, first, we should get the speed of our tank. For doing that, we can get the chaos vehicle movement component, and we can get forward a speed in MPH, right? That's it. Let's just use a printer string to show it to you printer string. And connect it like this to here. If you run over game, you can see if I had told you, the value can get really big. For example, right now, it's 43, right? The maximum speed of over vehicle or tank. So if we just put this value there, let's see what will happen. We need to get the mesh. Okay? And in it, we say set scholar parameter value on material. That's it. Let's is connected to execution pin, and the parameter name is very important. So let's just find that out really fast. Go to one of these. Let's just do it for the right track first. D'll click in here. It's called offset VRT. We can just copy it like this, control see copy it and paste it over here. By just connecting these two here, let's just look at it. If you go forward, you can see if I had told you, you can see it's moving, right? Knowing here, you can see if I move, it's moving with over wheels. But if you increase the speed, let's see what happen. If you increase the speed, you can see the tracks, it's like it's tottering, right? It's not working fine. Why this is happening, it's happening because this offset VRT needs a changing value. Always, it should be changed so you can see the fix. And for doing that, I need to create a variable. So in here, let's just create a variable. I want to call it track, offset. Okay. And the type I want it to be a float and with that, by default, it is zero. If you compile, you can see, I can add this value always to the track offset, add it like this to this value, and set the trach offset again in here with this new value that every frame will be changed, and connected like this to here and use the trach offset at the end for the parameter value. Now let's see what will happen. If you run and go forward. You can see if I had told you. Again, it's moving, but the movement is a lot now. You can see. Again, we have a little bit of structuring as well. It does look better. The left one is not working. It does look better, but the movement is too much. If we stop, you can see I'm stopping, but again, it's moving. Can see it's moving. The reason is this value that we add to track offset is too much. Sometimes it's get to 42. We need to limit that. How we can limit it, we can map it. For example, in here, I can say map in range with a clamp. No, I want to say if the value was between -70 and 70, give us a small value -0.5 and 0.5. What will happen if we connect these to here? What will happen? If the SPD is 70, it will give us 0.5 at the output, right? But if the SPD is -70, it means it's going backward full throttle, right? The value that this node will give us A will be -0.5. So we limit the value that we add to the track offset based on the speed, each frame. So this way, we can manipulate it more. Let's just compile, save and run over game and know if I hit W, you can see it does look much better, and we don't need to get to that higher value. And if we stop, let's just look at it. If we stop, it's like in reverse. You can see, it's like in reverse. So we need to reverse this value. So whenever the maximum speed is happening, we need to pass -0.5 in here. And whenever the forward speed is 70, we want to pass 0.5, right? This way, it will move correctly. If you run run over game again and had told you, no, you can see it's working fine. And it does look good. It's like in sync, right? If you stop, you can see, it's more in sync. If you want to work with it more to add more detail to it, you can change these values. For example, if I put 0.4 in here for the maximum and minimum -0.4, for example, you can see the effect. With this range clamp, we have more control over it. Now, you can see it does look a little bit better. You should work with these values until you reach the result that you want. With this, we done it for the offset VRT but we want to do it for the offset VLT, for the left one as well. So that's why I want to copy and paste this over here, connected like this. And this time we want to do it for offset. LT. So put L in there. Now, you can see it is offset VLT. No, let's just head compile, save and run. Now for the left, look at it. You can see it does look good. Both of the tracks are working fine. Now, you can see, everything looks good. No, I want to show you another thing. Another problem. And next we 13. 12 Tank track position: No, I want to show you something else. I want to make the tracks much better. For doing that, I want to go to our level, and this is where other players start happen, right? Let me add, for example, a shape, for example, a cube, right, and put it over here. I want to position it right because right now, we can't go right and left, so it needs to be with tracks. So now, if you run over game and go forward, you can see the wheels are going up, but the tracks are not. You can see it over here. The wheels can go up, but the tracks are going into the cubes, so that is a problem. How we can change the tracks position based on the position of the wheels. Or we can do that. We can do it in admission blueprint. So in here, before doing all of this, I want to create some space. What we want to do in here, we want to change the position of the tracks with wheels. So for doing that, let me in here, bring this up a little bit so you can see everything. Now, you can see each of these tracks. You can see, for example, this one. Let's just go to the left side. If this wheel go up like this, we want the tracks that is connected to it, we want it to go up as well. So these tracks we want it to go up, right? So let's see how we can do that. If you go to animation Blueprint, there is a note that is called bone driven controller that with that, we can tell it to which part of or track should move with which wheel. So in our skeletal mesh, you can see each of these wheels have a track as parent of it, right? So we can get the Z location of the wheel and change the tracks with it, change the Z position of tracks with it. So we can do it with this first thing first. I need the source bone. The source bone, for example, let me search for it. We'll in this case, wheel 02 joint. We want to get the Z location of that. So translation Z is the Z location of that, and we want to paste it for the destination or target bone. The destination bone is called let me search for wheel again in here, is called left wheel 02 track joint. And in here, we want to tell it to paste it for Z of it, right? So the left wheel 02 track Z will be changed, will be equal to left wheel 02, joint translation Z. Basically, we are changing the Z location of the tracks based on the Z location of the wheels. So we did that for the left one. Let's just do it for right one as well. Control C, Control V to paste it over here like this and connect the execution pin to here as well. So this time, we want to do it for the right one. So search for wheel. We want to do it for the right one. I want copy the Z location of right wheel 02 joint, the Z location, the translation Z, Z location. Want to paste it for right wheel 02 track joint, right? That's it. Let's just compile, save. Let's just go forward and you can see, based on the wheel on the right, you can see the tracks are going up as well. That looks good, right? Now, we need to do it for the other ones as well. So we have how many of them. Let's just check. These middle ones we want to change. One, two, three, four, five, six, seven. So we need six more on each side. So what I want to do I want to control C control V to paste it over here six time. This is three. We can just copy this three and paste it over here. So we have six of them. And we need to put a execution pin to them like this. And I will do some of them. You can do it in your own time because all of them are exactly like each other, right? Let me kind these two here. And for example, this one, we want to do it for wheel three. So in here, we can just choose left wheel tree. We want to change the Z location of left wheel tree track, right? That's it. No, the left wheel tree will works as well. Again, this one, we want to do it like this. We want to do it for left wheel fore joint and go down the target bone. We want it to be left wheel, 04 track joint, right? Do all of these for the other tracks. No, let's just go here. We did it for the fourth one. Let's just do it for fifth one in here. But the source boone, we want to do it for five. So left wheel five joint, and we want to paste it for left wheel five track joint, right? That's it. We need to do it for the others as well. The sixth one. So that's it. We go down in here and left wheel 06 track joint, right? We need to do it for the others as well. I will do it in my own time and I will get back to you. Now, you can see I did all of them. You can just look at it. The 02 track Z is equal to Wheel 02 translation Z, and I'm I did it for all of them, three, four, five, six, seven, eight. And after that, I did go for the right wheel, as you can see it in here, two, three, four, five, six, seven, eight. Now, for testing that, I want to add more of this in here with holding out and duplicating with dragging and dropping on one of these axes. Now, let's run or game. If I go forward, you can see it will go up and down, and that does look good, right? So that was it for this video. 14. 13 Going left and right: No, we want to be able to go left and right. Let's see how we can do that now. For doing that, first and first, we need the input action. So go to Tank, go to input. And in here, right click, go to Input and create a input action. I want to call it I go left. Right. Okay? Do click on it to open it the value type, we want it to be axis one d because either we are going right or left. That's more than enough. You can save it and close it. No, we need to map it, so go to IMC tank and here add the new mapping and here click and no we want to map, go left and right. For going left and right, we want to use D and A keyboard, right? So whenever we hit Dan here, we want to go right and we need another one. So for A, whenever we hit A, we want to go lift. So by default, we no, whenever we hit D or A, the IA go left and right, it will pass one. But whenever we hit D, we want to pass one, and whenever we hit A, we want to pass minus one. So we need a modifier for A in here. So click in here, add modifier of type of negate. So it will give us a negative value when we hit A. That's more than enough. Let's just go to BP tank. Want to create some space in here. And after going backward, what I want to do I want to right click in here, search for A, go left and right. Go left and right. No whenever we head D or A, we want to change the ya of our tank, right? So it is rotation around the Z axis. And how we can do that, there is a node inside chaos wheeled vehicle movement component in here that is called set Ya input, right? And we can just connect the trigger to it with the action value. But whenever we release D or A on our keyboard, we want to put the Ya to zero. So we can just copy and paste this and put it to zero whenever we release D or A on our keyboard and put it to zero. That's it. It's just test that. If we run over game, you can see, we can go left and we can go right. That working good. But you can see when we go right in place and go left in place, you can see the tracks are not moving at all, but the wheels are moving. So that's good. We can use the wheels movement to move the tracks. But if we move like this and try to go right and left, you can see, we can do that, and that looks awesome, right? So no oil tank can go left and right. But the problem that we have in here is that the tracks is not moving whenever we turn in place. Let's see how we can fix that next video. 15. 14 Track animation for turn in place: Now let's see how we can move over tracks when we are turning in place. For doing that, first, we need to know when we are turning in place, right? So how I want to do it whenever we head deep or A on our keyword, we want to save this action value for going left and right. So right click on this one and promote it to a variable. And I want to call it Ya value. Right? This ya value, we want to save it whenever we had D or A on our keyboard, right? Just with this ya value, what I want to do. In this track animation that we had before in here, let me make some space like this, bring it a little bit to the right, and bring all of them down a little bit, so we have more space. Now, in here, we want to check the ya value. If the ya value was equal to zero, what it means, it means we are not hitting D or A on our keyboard, right? So if it is equal to zero, do all of this. Do all of these normal things that you were doing before, right? Let me bring this up here. But if this ya value was not equal to zero, it means we are hitting D or A on our keyboard. In this case, based on the wheel motion, how it's rotating, we want to rotate the tracks as well. And all we can do that, we need these nodes as well, these nodes, right? So first, let's just do it for the right one, offset VRT that is for right track, copy it and paste it over here. In case of falls, it means we are hitting D or A. For the right track, I want to get one of the wheels that are inside this wheel setup and get its rotation angle and use it for the right track. Which one do we want to use? You can use whichever that is saying right on it. This is for left one. We can go down, for example, the tenth one, the right in here. So we can get this wheel, check its rotation angle and put it for parameter value in here. Let's see how we can do that. Or doing that because this chaos wheeled vehicle movement component has the wheel set up inside it. It is just an array that we can get it wherever we want, right? So get this chaos wheeled vehicle movement in here, get wheels. You can see it is just an array. These wheels is exactly these wheels that we set up in here. It will give us all of that. And we need to get one of them. The number ten is more than enough. So let's just get just number ten there because we know that the wheel number ten in the extend is the right one for the right side, right? So with this, if we get rotation angle, what will happen, it will give us the rotation angle of our wheel on the right side. So we can just connect it over here. Let's see what will happen. If we run and go close, if I go right, you can see the wheels are moving, but it's moving too fast. You can see it's moving too fast. So for it to not move this much fast, what we can do, we can multiply this by a value, for example, 0.01, right, and connect it to perimeter value. Now, if you compile and run, no, let's just look at it. If you go right, no, you can see it is more at sync. But again, the speed of it is too much right now, we can decrease it more. So if I put another zero by four, for example, 0.004, let's see what will happen. If you run over again, it will be a slower, can see. No, it looks much better. We can decrease it more by putting 35 in there. So it is 0.00 35, right? So if you again run, you can see that does look much better, but you can play with this value until you reach the result that you want. So now we have done it for the right track, we want to do it for the left track as well. So we can just copy all of these and paste it over here, right? And connect the execution pin to here. First thing that we want to change the VRT, we want to change it to heel t because this time we want to do it for the left track, and this time, the wheel that we want to get, we want to get a wheel on the left side. So if you click on this chaos wheel vehicle, for example, the index one, it is left wheel. So we can put one in here to get this wheel rotation angle. So no, just with that, let's just run. If you go right, you can see it's working fine. If you go left, it's working fine. And on the left side, again, it's working fine. You can see it. For going right and left, it's working fine and beautiful. That's good. No, we can move. We can go right. We can go left. And if we stay a ceiling here, we can go right. We can go left and everything working good. That looks beautiful. 16. 15 Handbrake: Next thing that you want to do, we want to be able to hand brake, use a handbrake, so we tank weight much faster, right? So for doing that, again, we need another input. So go to inputs in here, right click, create the input action. I want to call it IA hand break. Okay? You don't need to change anything inside it. We can just map it. So in here, let's just go up, add a new mapping, go down, so you can see it in here. I handbrake and when do we want it to happen whenever we hit space on our keyboard? That's it. Let's just go to our BPT, make sure you save everything. In here, let's just implement the IA hand brake, a hand brake, right, the event. And in here, there is a node inside or chaos wheel vehicle movement component that is called set hand brake input, right? So just connect the start whenever we press the spacebar, this start will happen, and we want to use handbrake. Again, copy and paste it over here. Whenever we release the spacebar on our keyboard, this complete will happen, and we want to release the handbrake. That's it. Let's just hit compile, save and run over game. If we go forward and hit the space in here, you can see it's waiting much faster. Again, you can see it. We can do lots of things with this spacebar. Let's just do a some rotation, right? So drift. If we hit the space and go left and right, you can see, and it will be stopped. That looks good. Now, we have a hand brake as well. 17. 16 rotate turrent joint: No next thing that you want to do. We want to be able to shoot the gun of our tank, right? But for doing that first, we need to be able to move it. So for moving it, let's just go to a skeletal mesh to look at it. First, I want to search for gun. Okay? We have a gun joint in here. That with that, we can rotate it, right? We can rotate it up and down. So for going up and down, we need to change gun joint pitch. This green one is pitch, rotation around the Y axis, right? So first thing first, bring it up and down, we need to change the gun pitch. But for going left and right, let's just search for Turretno there is a turret joint that we can use for looking left and right. You can see it. We can look left and right with this turret joint. So we need to change the turrent joint, or rotation around the Z axis. So for doing that, as you know, we need to go to ABP tank in the animation blueprint. First and first, let's just see how we can do the left and right. For doing that, let's just make some space over here. We need to use modified bone, right? Modified bone to change the bone stuff. First, the bone that you want to modify is called turret joint. So search for Turret and put Torrent joint there. We don't want to change the translation, so don't expose it as a pin. We don't want to change the scale, so don't expose this as a pin, but we want to change the rotation, right? I want it to add it to existence. So whatever rotation it has, we add to it, right? And next, I want to right click on this rotation, split a stroke pin. That's it, head compile. Now, if you change the ya or rotation around the Z's 90, you can see you will see it over here. So again, if you change this to 45 and head compile, you can see it is 45. So with this node, we are doing it, but how we can calculate what this rotation should be. I will create another video just for that so you can go back to it whenever you need to remember it. So I will see you in next 18. 17 Calculate delta rotation: No for calculating what the turret joint rotation should be, how it should be, we should go to event graph. And first thing first in here, we need to get the tank itself, the BP tank. So we should see where we camera is looking at and we change the ya of over turret, so it will look at there that we are looking at it with our camera, right? Or with our controller or with our mouse. So with that, we need a begin play to get the tank. So search for event begin play, and we can get our pawn owner in here and cast it to BP Tank, right? And now, with that, we have access to BP tank. If we just right click on it, promote it to a variable. No, I want to rename it to BP tank, not as BP Tank, right? And in here, first thing that I want to do, I want to get it and check if it is valid. This is really important to check if it's valid. If you don't do this, it will give you lots of errors always. First thing that I want to do in here, I want to get the control rotation, get the control rotation. What this get control rotation gives us, it will give us the rotation that our camera is looking at. And after that, I want to get the actor rotation, right? So what this get actor rotation will give us, it will give us the rotation of our actor, of our attic mesh of our tank, where it's facing at, right? So with these two nodes, we want to get the difference between them. The difference between where our tank is looking at and when our camera or our mose is looking at, right? We want to get this difference and put it there so we have the correct rotation, right? So the node is Delta rotator, Delta rotator from A to B. It will give us the difference between the rotation of our tank and the rotation that it should have that our camera is looking at it, right? So with that, I can just grab this, break it. Okay? We need the ya for our turret. So I will right click on it, promote it to a variable, and I want to call this turret Ya. Okay? Turret ya. Now, we check if the BP tank is valid. We want to set the turret ya, save it over here, and know in ring graph, we can use it in here with this node, just connecting it to rotation Z of our turret joint. Let's just check that if you run over game, if you look left and right, you can see, looking right, looking left, we are moving over turret with the mouse and the camera. You can see how good it looks. The next thing that we want to do we want to go up and down. For doing that, again, we can use this Delta rotator, the pitch of it. Because we want to go up and down, rotation around the Y axis. So you try to do that. We'll do it next ido together. 19. 18 Gun pitch: No, for changing the gun pitch for going up and down. For doing that, we have a pitch in here that we can right click on it, promote it to a variable, and I want to call it gun pitch, right? So what it will give us, it will give us the pitch difference between where over aesthetic mesh is looking at and where over camera is looking at. And with that, we can use this pitch difference to change the gun joint of over tank, right? It needs the execution pin. So let's just give it that like this. I hold Control and grab it like this and put it over here and connect it like this. This is much cleaner to do it this way. Now, we should go to anim graph and use one of these notes. Control C Control V to paste it over here. What we need to change on this copied note, we need to change just the bone. We can just search for gun and put the gun joint there. That's it. We need to change the pitch so we can get the gun pitch and put it over here and organize a little bit. No, let's just check that out. If you're on our game, no, you can see, or gun can look up and down. You can see. But the problem is, if you look at it, if you go to our map and look at it this way, had a fate. No, you can see the gun is inside the body of our tank. So we need to clamp it, right? This way is not good. So how we can clamp it. If we go here, I want to make this bigger a little bit so you can see it better. I want to go to an previewer editor and change the gun pitch. You can see it can go up to this point, for example, that the value is 39, so we can clamp it to 40, for example. 40 is good. No for going down, let's just go down. We can go to this, right, -13. So 40 to -30. And with that, we can just clamp in here, use a clamp. Clamp. If we go up, clamp float value, right? And the minimum is -13, and the maximum is 14. So we don't allow it to go less than -13 or bigger than 14, right? Let's just head compile and know with that, if I go to our new map and run and go down, you can see it won't go through the body of our tank, and it can't go up that a lot, you can see, it won't go up that much. That is working fine. But no, for firing or gun, we need a cross hair. Let's see how we can create a cross hair. 20. 19 Crosshair widget: For us to be able to shoot or gun in our tank, we need to have a crosser. Let's see how we can create that. If we go to Content drawer, I want to go to Tank folder, and in here, right click, create a new folder, and I want to call it Widgets. And in here, right click, go to user interface and create a Widget Blueprint. With this Widget blueprint or user widget, we want to create or crosser. So click on user Widget, and I want to call it WBP crosshair, okay? Doll click on it to open it. And here we want to create our crosshair. So first and first, we need to go down add a canvas panel to our hierarchy, right? Now, you can see we have a canvas panel, and the only thing for no that you want to add in here is an image. So drag and draw an image inside this Canvas panel, and the image that you want to put in there, we can just click on it in appearances in brush in image. We want to choose the crosshair image. You can see it is in here, but it is stretching. You can see the size of it is not good. We can tell it to size it to content. Now, you can see it over here. Next thing, I want to change the size because right now, the size of it, you can see it's too big. For changing the size, we have image size. We can divide it by two. In here, we can say divide by two, and it will calculate it for us, right? Divide Y by two as well. No, you can see the size is much better now. Next thing that I want to do, I want to put it at the middle of screen. Right now, it is a top left corner. For putting it at the middle of a screen, we need to first change the anchor point to the middle and change the position X to zero and position Y to zero as well. But as you can see, it will align itself to the anchor point, but the top left corner. You can see we want to align it to the middle. How we can do that, we can do it with alignment. If you put 0.5 and 0.5 for alignment, it will put it at the middle of a screen. Now, you can see it is at the middle of a screen, right? Just with that, let's just see how we can use it. Head compile, save. Now, if you go to our BP tank, I want to click on or mesh and add a widget blueprint. So add a Widget in here. I want to call it crosshair, right? With that, click on it, the first thing that you want to change is the space, we want it to be a screen, so it won't go behind things, we can always see it if you put it on a screen. The widget class that you want to create is called LUBP crosshair. Search for it and put it there. Now with that on, let's just run over game. You can see the crosshair is exactly here. It's not at the middle of a screen, but you can see it over here. If I go here, you can see it better. And that's it if I hit F, you can see it over here. No, we want to change the positioning of it to be exactly where our gun is looking at. You can see right note or gun is looking at that way. It's looking at that way, but our cross is here. So first, we want to check where we gun is looking at and we want to change the position of this crosser to that position. Let's see what we can do that. Next. 21. 20 Crosshair location: No for positioning or cross hair, we need a line trace to see where gun is looking at, right? So we put the cross hair there. For doing that, I want to go to our BP tank, and in here, I want to click on Ormsh, open up the animation blueprint. We don't need it. What I want to find from this animation blueprint is it's a skeleton because we want to see where gun is looking at, so that's why we need a socket at the tip of this gun. If we search for gun in here, you can see we have a gun on joint sockets, right? So you can see it facing where our gun is looking at. So we want to use this socket, rotation and location to see where this gun is facing at or looking at. So we change the position of or crosshair with it, right? So the name of this socket is really important. So right click on it, rename and right click on it again and copy the name. We need the now, if you go to BP Tank, I want to update the cross hair position each frame. So that's why we need to do it with eventq. But I don't want to do it in here because we can mess up the eventqEecution path. That's why I want to go down and create a custom event, right? In here, let's just create custom event, and I want to call it update cross hair position, right? Now that we have this event. I want to go up and put it at event T. So in here, after track animation, I want to say update. Crosser position. That's it. No, whatever we connect to the update crosser position, it's like connecting it to the eventi, right? With this, we need a line trace, line trace by channel, right? This line trace help us to see where our gun is aiming at or looking at, right? I need a start and end position. For the start, we can get our mesh, and with that mesh, we can get the socket location, right? The socket location that you want to get, we did copy it from skeleton is it's called Gun one Joint socket, and we can put it for a start. But for the end location, this is really important. For the end location, we want to see what is the forward vector of our gun one joint socket and add to it, right? So we can see what is at front of this gun joint socket. So for doing that, first, we need to get the forward vector of gun one joint socket. This socket in here. We need the forward vector of it, right? So we can get the socket rotation, okay? And the socket rotation that you want to get is gun one joint socket, right? With a rotation, we can get the forward vector. What this will give us, it will give us the forward vector of this socket where our gun is aiming at, right? Because a forward vector is a length of one. It's not enough. That's why we want to multiply it by a big value, and I want to multiply it with really big value. I don't want to do it like this. I can right click on this one and change it to a float. No, I can put a value like 1 million, right? Now with this, it will give us a location alongside our gun one joint socket. But the next thing that you want to do with this is to add it to the gun one joint socket location. We added to it, so it has the offset because by default, it is from 000 location of our word. So that is our end location for you to see it better. I want to enable draw the book type to one frame. And with that done, if you run over game, no, you can see it is starting a line trace from the tip of or gun to where it's looking at. You can see it, that looking good. Either it is hitting something or if you go to a sky, it's not hitting anything, right? If there is that red square at the end of it, it means it hit something, but if there is no red square at the end of it, it means it didn't hit anything. And we can check that with this out hit. So dragon drop, break it. No, we have a blocking it. We can check it with a branch to see if it did hit anything or not, right? So if it hits something, this true will happen, and we can get our crosshair and set the word location of it, set word location of it, right? To what location to the location that it hit that thing, right? So this impact point is the location that this line trace hit something. But if it didn't hit anything, what do you want to do we want to again set the crosshair location with Control C and Control, we copy these two if it didn't hit anything, we want to set the location of this crosshair to trace end, that end location, this end location, right? This is exactly the same as this one. Now with that done, if you hit compile and in here, change the draw debuc type to none and run over game, you can see the crosshair is moving with over gone, and that looks awesome where if you go to Sky, again, it will point at where our gun is looking at. And if we go down, it doesn't matter where we are looking at. The crosshair is changing its position correctly. You can see, we can go up down, and you can see it good, right? 22. 21 Tank projectile: No, for firing or weapon, we need actual projectile. So for creating that, let's just go to Content drawer in Blueprint folder, I want to right click, create a blueprint class of type of actor, and I want to call it BP tank project tile. Okay, BP tank projectile. I'll click on it to open it. First thing that I want to do in here, I want to add a sphere collision, right? I want to put this as root in here. The sphere radius, I want to decrease it to 16, right, because it's too big by default. And with that, click on the sphere collision, and in here, click on add and search for a sphere static mesh, right? That's it. The size of it is too big. Let me rename it to sphere static mesh, right? And the size of it, I want to decrease it. By clicking in here, I want to decrease it to 0.25, so it will be inside that collision section. No, what I want to do I want to make this look much better because right now, it's just a white static mesh, right? So for doing that, I want to go to content drawer, go to Tank folder, and in here, create a new folder, and I want to call it material materials, right? Double click on it to open it. Right click in here, create a material. I want to call it tank projectile. Okay? Dog click on it to open it. Now in here we have our material. For changing the base color, we can just click in here and change the color. But the best way to do it is with constant tri Vctor that is like a color, and we can connect it to base color, right? Now in here, changing the color to red, we can change this to red, and it will give us red in here, right. Now with that, let's just head save and go to our tank projectile and change the material to tank projectile. No, you can see it is red, but I want it to glow a little bit. For something to glow inside a material, we can multiply the base color by really big value, like 100 and connect it to emissive color. A missive color will give us a glowiness. Make sure you hit Apply and save. And know if you go to Tank projectile, you can see it is glowing. No with that done, the looks are good, but it's not moving. Let's just add a projectile movement in here so it will move. Search for projectile movement and put it there for initial speed, I want to put it on 25,000 and the maximum suit want to put it on 30,000, right? That's it. Make sure you head compile save. Just with that. If you click in here, you can see the forward vector with that. If we click on simulation, no, you can see how it looked like. You can see. No, we have a tank projectile. 23. 22 Fire gun of tank: Know that we have a projectile. Let's see how we can use it. For using it, we need input action. So let's just go to Content drawer, go to input, and in here, right click create a input action, right? I want to call it a fire, right? Don't click on it to open it. You don't need to change anything in here, save it and close it. No, we need to map it. Let's just open up the IMC tank and in here, add another mapping, go down because it will create it down here. You want to do it for IAFre when do we want to happen whenever we hit Leftmost button. Leftmost button, put it there and save it. Now, if you go to BP Tank in here down here on right click search for AFire, right? With that, whenever we press the IFR, we want to spawn or projectile. So search for a span actor from class. The actor that you want to create is called BP. Tank projectile, right? The positioning of it that you want to create it is at the tip of our gun. And how we can get that, if you remember, we did use a socket there, so we can get our mesh in here as well, get or mesh and get the Get socket transform. Search for Get socket transform, the transfer space should be word, and the socket name, we can just copy and paste this go one joint socket. Control C to copy it and paste it for this one, right? The transform of it is really important for us with that if you had compiled save a Runo game, no, let's just hit leftmost button. You can see that's cool. But we can do it really fast, and there is a problem. You can see whenever we shoot or weapon, the crosshair position is changing as well. The reason is because this crosshair is colliding with the projectile. So let's see how we can fix that. For fixing that, where we are setting the position of our crosshair, we want to ignore the projectiles. So how we can do that, we can get all actor of a class of type of BP tank projectile. It will give us an array of all of the projectiles, and we can tell this line trace to ignore them. Just with that, if we compile and run, no, you can see when we shoot the crosshair is not changing its position at all. No, we are shooting or gun, but there is a problem. We can have lots of them. That is a problem. 24. 23 Gun visual effect: There is lots of problem with firing or gun. One of them is that we can shoot it really fast after each other. So we need a reload system. For doing that, I want to create a boolean and I want to call it can shoot. And with this variable that is a Bollen, we want to check if we should be able to shoot or not. By default, we want it to be on. So we'll be able to shoot, right? Let's just create some space. First, we check if can shoot was true with the branch, okay? If we can shoot case of true, you can shoot, right? But after you shoot, you shouldn't be able to shoot anymore. So we set it to false, but we need to make it true at some point, right? So we use a timer. So use a timer by event, right? After 2 seconds, we want to say, you should be able to shoot again, right? It need a event. So let's just create custom event for that. And I want to call it can shoot again or whatever you want to call it. No, after 2 seconds, this event will happen, and we want to set the can shoot through again, right? Just with that, if we hit compile, save and run, no, you can see if I shoot, after 2 seconds, we can shoot again. You can see each two second, we can shoot. That's all we need to do. No next thing that we want to do. Whenever we shoot, there is no visualization of the gun shooting, right? We need some smoke. So for doing that, after we spawn or projectile what you want to do. Let's just make some space in here. And in here, what I want to do, I want to spawn a Niagara fix. So let's just say spawn system attached. This time, I want to use attached. Now with that, we need to choose our Nagara system to spawn. And the Nagara system that you want to spawn is called NS is ten T 72 B. Just put it no, we want to attach it to something. I want to attach it to our mesh. So grab the mesh and connect it to attach to point. No, it need attach point name, the socket name that we can get from here, right? Gun one, joint socket at the tip of our gun, put it over here. And with that, the location type, we want to change it to keep word position, and we need to change the location and rotation. And how we can get this, we can get it from the get socket transform of the tip of orgun the socket that is at the tip of orgun, right so we can break this, break it and use the location and rotation of it in here. That's it. That's all we need to do. Let's just compile and run. Now, if you shoot, you can see, there is a smoke attached at tip of over gun. So after that, if we change the rotation of over turret, you can see the smokes looks really good. You can see it. That looks good. Every 2 seconds, we can shoot over gun, and no we have visual effects for. 25. 24 Add torque when firing: No, I want to add more affix for firing or gun. Let's see how we can do that. For doing that, I want to make some more space in here. First thing, I want to add a sound, and I want to use span sound at location. The location, we can just use the location of our actor. Get actor. Location, that's more than enough because it's the sound. We don't need to put it at tip of or gun. Of course, you can do that, as well. The sound that we want to play is called IS Cannon Fire signal, right? That's it. No, with that, 'is compile. Save and run. Sure And that that sound awesome, right? That's it. Now I want to add more effects to it. Whenever we far over goone, we want to add some torque in backward, right? Let me show it to you. You will understand it. Again, we need more space in here. The node that we can do that with is called at Torque in radius with or mesh. So we add torque to over mesh, right? No, first, it needs a torque. Let's just say each time 100, right? To what bone? Let me go to Okeleton. I want to add it to the card joint. So right click on it, copy bone name, and add it over here. And with that, we want to change the acceleration. So enable this. Now, with that, if we head compile and run, if we shoot you can see it go forward. It's in the wrong direction, but it's working fine. If we go right, again, you can see because we put 100 for the y, doesn't matter where we are shooting. It will go forward. You can see we can change that to -100 and at compile. No, with that, if we should, no, you can see it will go backward whenever we should. If we go right and shoot again, it will go backward, right? That doesn't look good. If it's good for you, it's okay. You can use it, but I want to show you check the direction where we are shooting at and add some torque in backwards, right? So for doing that, we need to calculate this torque from where to where it should be, right? For doing that, again, I want to use over mesh, okay? I want to get socket transform. I want to get the transform of the socket of over turret to see where over turret is looking at. In here, I want to search for turret to copy the name turret joint, copy bone names. With this, we get the transform of over turret joint. Where is its jaw, where it's looking at. Now with that, there is a node that is called transform direction. Search for transform direction. And with this, we want to add some torque to the Y, for example, -25 because 100 is too much, and use this as a torque. Just with that, if you had compile, save and run, no, if we are looking forward and shoot, you can see it will go backward a little bit. But if we go right and shoot, no, you can see it's going this way. Again, if we go backward and shoot, you can see it will go forward. Again, if you go on the left side, it should go right. Can see? No, in the directions as well, if you it will add some torque to the body of our tank. And that, I think, looks awesome. 26. 25 Fire recoil: No I want to make or firing of Ogun looks much better. And who I want to do that, I want to do it with animation blueprint. Let's see. If we go to our skeletal mesh and search for gun joint, let me show something to you. In here, what I want to do each time that we far over gun, I want to change the position of gun like this. So every time that we fire, we want this gun to go back and forward like this, right? That does look good, right? Let's see how we can do. For doing that, I want to go to ABP tank, and again, let's just make some space. I want to use one of these nodes. So it's called modify bone. We did use it a lot. I don't want to change the rotation. So let's just go to rotation and don't expose it as pin. I don't want to change the scale, so don't expose it as a pin. I want to just change the translation. So add to existence and change the translation space to parent bone space. I want to choose or bone to modify that is our gun. Gun joint. Now, with that, what I want to do I want to right click on translation, split the striping. We want to change the X. Let's just see. Go here, we change the X two -20 and head compile, you can see it will go inside. After that, if you put 20 in there, it will go outside. You can see if you put zero in there, it will go at the right position. So we want to change the X location of that, right? So we need to change the translation. X whenever we are firing over gun, and how we can do that, we need a variable for translation, X of this gun, right? So for doing that, I want to go to BP Tank. And whenever we fire over gun, in here, I want to use a timeline, so add a timeline to change the position of this gun, right? So at the timeline, I want to call this recoil. Recall timeline. And each time that we fire, we wanted to play from start, not just play, play from start, right? And, no, let's just go inside this timeline and create it. The length of it, I wanted to be 0.12, right? It's more than enough. Add a flow track, and in here, it's just 0.12. Right click add the key at time zero. We want it to be zero, right? And add another key frame in here. And at time 0.12, we wanted to get to one. And for it to look much better, let me click in here to Zoom on it. I want to select both of them, right click on one of them, and click on Auto. So it will give us a curve, beautiful curve like this. Now, the name of this track, I want it to be recoil value, right? And now, the timeline is good. Let's just go to event. We have recoil value. We can right click on it, promote it to a variable, and the naming is good. Let's just give it the execution pin, and that's it. We have a recoil value that it will change 0-1 in 0.12 seconds, right? So just with that, let's just compile save, go to ABP Tank. We need to get it first, go to event graph. And in here, we have the BP tank at the end, we want to get the BP tank in here and get the recoil value. Recoil get the recoil value. And with that, I want to promote it to variable. The naming is good. Recoil value is more than enough. Let's just give it this and know with that done, we know that the recoil value is the value 0-1. So we need to multiply it by some value. So I will get the recoil value, multiply it by for example, -25 and connected to translation. Now, let's see what will happen if we compile and run. Now, if we shoot, you can see the gun will go backward. Just look at it. You can see. If we shoot it in here, of course, you can see it properly, but it's happening. You can see it now. If we shoot, it will go backward, right? Whenever we shoot, it will go backward. No, that looks good, but we can add more to it. So if we go to our BP tank and in this recoil we can add more to it, right? For example, let's change it to 0.3, right? So in 0.12, second, it will reach one, it will go back. And after that, we want to take some time to go back to zero. So add another key. So at time 0.3, we want it to go back to zero, and it has a curve as well. And you can see we just adding another point on our timeline, we can add more animation to it, right? So now, let's just says that if you run over game and shoot you can see? No, that does look much better. It will go backward and after that, go forward. You can see it? That looks awesome. 27. 26 Reload progress bar: Next thing that you want to do, whenever we shoot or gun, it looks good, but we don't have any reload system, right? We don't know when we can shoot or gun, so we need to add a reload system. For doing that, I want to go to our WBP crosshair and add it in here, a reload system. For doing that, I want to use a progress bar. So add a progress bar to our Canvas panel, and you can see it is at top left corner. We need to put it at the middle. So put it at middle, change the position X and position Y to zero. Again, the alignment, we want it to be at middle. So 0.5 for both X and Y of alignment, you can see, No, the progress bar is at middle or screen. I want to change the size X to 15 and size Y to 100, right? And I want to position it 90 unit to the right. That's it at the right side of it. Now, with the percent, you can see, it will change from left to right, if it is zero to one, right? If it is zero, it means it is empty. If it is one, it means it is full, right? But I don't want this bar fill type from left to right. I want it to be from bottom to top, right? Now, if you change this percent, you can see how it looks like. In appearances, I want to change the color. I want to put it somewhere over here. So gray color like this. No, I think that looks good. Let's change the percentage. That I think looks good, but you decide what color you want to use. No, I want to name this progress bar to reload. And we want it to be a variable so we can change it inside our BP tank. No, we have our progress bar for reloading. I want to go to graph, and in here, I want to use interfaces to update this reload progress bar, right for interfaces, I want to go to content drawer, go to Tank folder and right click in here, create a new folder, and I want to call it interfaces, right? Do click on it to open it in here, right click, go to Blueprint, and I want to add the Blueprint interface. I want to call it BPI for Blueprint interface, and I will name it crosshair interface. Okay? Crosshair interface. Do click on it to open it. I here. The function that you want to create is called set reload progress. Bar. Set reload progress bar, and it needs an input. So let's just add an input of type of float. And I want to call this input reload value, right? Reload value. So what is this interface? This interface is a way of communicating between two blueprint Blueprint tank and Blueprint Crosse, right? So let's see how we can use it. For using it, we need to implement this interface inside the target blueprint. For example, DBP crosshair, in here, we need to go to class setting. We have interfaces in here. We need to add it. It's called BPI crosshair interface. Now with implementing or BPI crosshair interface, it will create event for us that is called SetoadPgress Bar that we created over here. So with this interface, we can add it to whatever blueprint that we have, and with it, we can communicate between two blueprint. Let's just click on this set reload progress bar. It will create a event for us that is called event, set reload progress bar. And with that, we can get the reload progress bar and set a percent on it. Set percent, right, with the value that we get from this reload value. The percent, as you know, is a value 0-1. No, with that done, if you go to our BP tank, let's just go to Avent graph. And in here, we had a timeline for recoil. I want to create another timeline for reload. So I will add a sequence node in here. So we have multiple execution pin, and then zero, we are just playing timeline or recoil and then one, we want to add another timeline. For reload, just name it reload, right, that you want to play from a start. So hold Control and disconnected from play and put it on, play from start and inside in here because the reload time is 2 seconds, the length should be 2 seconds. Add the track flow track I want to call this reload value, right? And I want to add a keyframe at time zero, we want it to be zero. Add another keyframe at time two, we wanted to go to one. If you click in here and here, you can see it correctly. We want it to be linear, so that's more than enough. Now, let's just go to event graph again. No with it, it will give us a reload value. And with that, we can get our crosshair because the reload progress bar is inside or crosser in here, right? It's in here. No. We want to get the user widget of this, user widget, get the user widget first. And after that, we can set the reload. Progress bar, right? The function that we create inside we interfaces. With this, we can communicate between these two blueprint the BP tank and WBP crossing. Both of them is like a blueprint, right? On update, we want to update the reload value with this reload value that we create inside this timeline, right? Now, let's see what will happen. If we run over game, no, we can see a progress bar at the right side. If we shoot can see, it will take a little bit time to go to one. Again, shoot you can see we can see the reload time. That looks awesome, right? No, you can see when we run our game at default, it is zero. So we need to put it at one at default. So it will always be at one when we play our game. So for doing that, there is lots of ways to do it, but we can go to WBP crosser in the graph of it. We can set this person to one at event construct or event preconstruct doesn't matter which one you use, put one in there. That's it. Now, if you run over game, at default, you can see it is one, and if you should, it will go to zero. That looks awesome. We have a reload progress bar 28. 27 Projectile explosion: No, we are firing or gun or over tanked, but it's not having anything. Let's see how we can do that. For doing that, I want to go to BP Tank Projectile, go to event graph, click on the projectile movement. I want to go down until we have unprojectile stop. When this unpjectile stop happened, it means it did hit something. It will give us impact results. Let's just break it to see what it has. Doesn't matter if it hit anything or not, it is stopped. And in that stop location, we can spawn system at location, right? And the inaugural system that I want to spawn it's called dust Explosion one. Right, put it there. I need a location. I can get the location like this and it needs a rotation. We can get a rotation from the impact normal can say make rotation from X, for example, right, put it there. Now, if you run over game, you can see when you shoot something, it's not stopping and it will go under the ground. It's because when we click on or a sphere, we didn't set the collision preset. It's overlapping everything, but we want to tell it to block everything. Now with that on, if you compile, shoot. No, you can see, there is an explosion. You can see. Cool. No, with that done, with that explosion, we need to play some sound. So for doing that, again, in here, I want to spawn sound at location, right? And this time, the sound that we want to play is called ES grenade Explosion, right? And the location of it this time is really important. We can get this location and connect it to here, but I want to add the attenuation setting as well. So if we shoot far away, we shouldn't hear it sound, right? So for creating this attenuation setting, we want to go to content drawer go to tank, and I want to right click, create a new folder and put sound there, right? No, I want to right click, go to audio and create a sound attenuation. I want to call it S A for sound attenuation. Explosion, right? Explosion. I'll click on it to open. The only thing that I want to change in here is fall off distance. I want to put it on 50,000, so we can hear it a little bit from far away, right? It has inner radius that if we are inside that inner radius, we will hear it completely. But 400-50 thousand, it will linearly decrease its volume, right? That's it. Let's just go to our tank projectile and put it there. Or you can just click in here and put it there, right? Now, with that do, let's just head compile and run. If we shoot, can see we hear the sound, but if it is far away, we can't hear it. But if it's a little bit away from us like here, you can see we can hear it, but with lower volume. Now you can see there are some projectile there and it's not destroyed. So what we need to do we need to destroy it after everything, right? So destroy actor and know if you run over game, shoot, and you can see, No, it is destroyed, and it won't be there, but the explosion will happen, right? Shoot, can see. We are shooting and everything works fine. But we want to do other things in here as well. We want to be able to apply some damage. So before destroying it, we want to apply this time a radial damage with fall off, right? So the explosion of a tankshell is like a sphere, right? So this radial damage is more than enough. The base damage, I want to put, for example, 25 there. The minimum damage I want it to be ten. Then damage in a circle, it means if you are inside that inner circle, it means it will apply damage like 100%, right? The inner radius, I want to put 100 there like this, and the outer radius, I want it to be 500, right? So if you are inside this out radius, what will happen, it will damage like ten unit, right, the minimum damage. But if we are 100 unit close to the explosion, it will give us 25 damage. And there is a damage fall off in here as well, that it is exponent of a damage from damage inner radius to damage or radius. How much when we get to the or radius, less damage it causes? I want to put one in there for nothing will happen because we don't have me yet. No, with that, if we head compile, it will give us an error because we need to give it a location, the origin that this aploed damage should happen. And we can use this location for this one, as well. That's it. No, if we head compile, it will compile successfully. 29. 28 Engine sound: No, we want to make a tank better with some sounds. I didn't do the sounds till no because when there is a sound, you can't hear me right. That's why no I want to add the sound. So when we are moving, we should have some engine sound, some track sound, and all of that, right? So for doing that, let's just go to BP Tank. What I want to do I want to right click in here, close other tabs, so it will be a little bit cleaner so you can see everything. Now, in here, we need to create an engine sound. For doing that, I want to go to Content drawer, Tank folder sound, and right click in here, go to Audio, create a Metasund. I want to call it MS for metasundEngine, or Tank engine. It's better to call it tank engine. Dot click on it to open it. And in here, first and first, we want to create a wave player. With player mono is more than enough. We need to connect the OT mono to OT mono. And now for the wave that you want to play, I want to play the engine idle. Just with that, if we hit play, we can see the it is an engine idol, right? But first and first, I want it to be on loop, so it will always be played and with changing the pitch, we want to mimic the revv, mimic the increasing of the speed, right? So if the speed increase, we can put ten we can put ten for pitch shift, and now if you play, you can see, it's like we are moving fast, right? So, based on the RPM of W engine, we want to change the pitch shift, right? So for doing that, we need an input. And we can create an input in here. I want to call it RPM for rotation per minute or round per minute or whatever. This is the RPM of our engine. All cars have it, right? So we can get this RPM, and with that, we can change the pitch shift, right? But let's see what is the engine RPM, Maximum RPM. For doing that, let's just go to BP Tank, click on chaos wheeled vehicle movement. And in here, search for engine, and you can see, Max RPM of our engine is 4,500. So the RPM of our engine is 0-4500, right? Now, you can see, we can change it 0-4500. It's just for testing. No, whenever the RPM is zero, we want to play the pitch shift of zero, for example, right? But whenever the RPM is 4,500, we want to change the pitch to ten. We don't want to get more than ten. So what we can do, we can clamp it in range or map it in range, map range. That's it. Now, if the in range was zero like this, like this, we want to put zero to output to pitch shift, right? But if the Input, this input, this RPN was 4,500. If it is 4,500, we want to put ten as output. Okay? So, no, let's just test that out. If we run, you can see if we put this to zero, it will play at pit of zero. But if you increase the RPN, you hear it? It's like the RPM is increased, and no we want to use this RPM to change the pitch shift. And another thing that I want to do with this RPM is that we want to change the volume. And how we can change the volume, we can use a mixer in here, mixer mono, right? And we can connect the ot mono to here and connect the output of it to here. Now, we want to check the RPM again. We can get the RPM again over here. And again, we want to map it, map a float value. If the value in ranges 0-4500, right? But the volume, we want to change it from 0.3 to one. That's it. Now, if you connect it to gain zero for changing the volume of this in zero, whenever let's just say that if you run over game RPM to zero, so the gain will be 0.3. But if you increase the RPM, you can see the pitch will be increased as well because both of these are the same, and the volume of it will be one as well, right? By default, we want to put it on zero. No O metasund is ready, we can save it and use it in our BP tank, right? So now in here, I want to click on our mesh and add audio in here, and I want to call it engine, right? So with that, if you click on our engine, we can click in here and choose our Ms tank engine. Just with that, if you hit compile because we are not changing RPM, it's always play this sounds at pitch shift of zero and volume of 0.3. If you move, nothing change. You can see but we want to check the RPM of our vehicle and change the RPM inside this engine sound. And how I want to do it, we want to do it in E&T. So each frame, we check what is the RPM and change the sound as well. For doing that, like we did it for track animation and update crosshair position, we want to create another event, a custom event for sound management. So in here, I will right click search for Custom event and I want to call it sound management. Sound manager, right? And after that, we want to put it in here at the event tick. So in here, dragon drop, search for sound management, right? So it's like whatever we do in this event, this custom event, it's like connecting it to event tick. It will happen 60 times or 30 times per second, right? So no with that, we get the engine. And because the RPM in here is just a float, we can say set a float parameter. There is two of them in here. One is for audio parameter controller interface, and one is for target is audio component. We want this one. The target is audio component, right? That's it. Make sure you select the right one. No, I need a name. The name is RPM. That's it. The exact name that we use in here, and now we want to change the float this RPM float with this value. But how we can get the RPM. We can get our chaos wheel vehicle movement component, and with that, we can get the engine rotation speed. That is exactly the RPM, right? Get engine rotation speed. If you want to see it better, I will use a printers ring in here to see how RPM is changing like this with the printers ring. Now, if you run over game, you can see, by default, the RPM is 800 if we move it will increase until it reached 4,500. You can see it will get really, really close to it. Now with that done, you can see when we stop and the pin decrease, the sound is decreased, as well. The volume of the sound is decreased and the pitch shift is decreased, as well. If we move, you can see the volume is increasing and the pit shift is increasing as well. So that is working fine. And you can see if we go back, again, it will work fine because the RPM at going backward is working as well. It will change as well, right? No, next thing, we want to play the track sound as well, right? Now, we have just engine. 30. 29 Tank tracks sound: No, we want to do the track sound. It's a little bit different because we want it to be based on the speed, not our PM. So first thing first, let me read this printers ring. We don't need it anymore and make some space, right? No, we have a metasund for engine. The metasund for tracks, it's exactly the same. So click on it, Control D duplicate it, and I want to name it MS for metasundtank, track, right? Doc click on it to open it, the input I want it to be speed speed, not RPM anymore. And the value of a speed, it's not 0-4500. So let's see what is the maximum speed. If we go to BP Tank, what I want to do I want to use a printer ring in here. On eventiq because this sound management is at eventiq. No, I want to get the chaos wheeled vehicle movement component, and I want to get the forward, the speed of it, forward, a speed in mile per hour, right? And because we can go backward and forward, I want to get the absolute of it, and after that, show it with this printers ring. Let's see. If you go forward, you can see the maximum speed is like 44, right or 43. Know that we know the maximum speed, let's just go to MS tank track. And in here, let's say the speed is 0-45, for example. But the OT range, I want it to be between 0.9 and 1.5. I don't want to change this pitch shift a lot, right? And for the volume of our tank track, we know that it is 0-45, for example, right? It's close enough. I want the output range to be 0-1. So what will happen by this? If the speed is zero, it will give us the volume of zero. There is no tank track sound at all, right? But if it is 45, the volume will be one. But it doesn't make sense this way, right? What I want it to happen, I want the in range to be 0-10. So if the speed is 0-10, the output range will be 0-1. But if the speed get more than ten, the range, the volume won't change more than that. I want when the speed is ten to 45, I want the volume to be one. That's why I put the in range 0-10, right? It will sounds much better. If you want to put it 0-45, you can do that and test with that as well. Now with that done, we need to change the wave act from the engine idle to tank track, right? Now, if we hit save, we know that the speed is 0-45. Let's just say so. If we run, you can see, when the speed is zero, we won't hear anything. But if you increase this, see? No, we can here. 0-10, the volume will change, and after ten, the volume won't change anymore. And that's how we want it to be. Now, let's see how we can implement this. For doing that, let's just go to BP Tank. And in here, I want to click on the mesh, add a audio in here, and I want to call it Track. Okay, track sound. And with that, what we want to do we want to choose our metasund tank track, right? Just put it there. Now we want to change the speed parameter inside this track sound with the forward speed. We don't want to just show it. Let's just delete this prints sring and get our track and inside it, we want to set float parameter in there. The float parameter that you want to change is called the speed, right? And we want to change it with the forward speed in mile per hour, right? Just with that, let's just compile and run. You can see because the speed is zero, we don't hear any tank track sound. But if you move, no, you can see, you can't hear tank tracks. You stop. You can see the tank tracks doesn't have any sound. No. You can move. See how beautiful it is, how good it sounds. 31. 30 Tank UI widget: No next thing that I want to do I want to show the tank turret rotation with an UI. For doing that, I want to go to Content drawer, go to widgets and right click in here, go to User Interface and create a Widget blueprint. A type of user widget. I want to call it WBP Tank UI, right? Don't click on it to open it in here. First thing that you want to do we want to add a Canvas panel to our hierarchy, right? And know we want an image. This image, let's just choose the image. If we go down, just search for Tank. We can just search for tank body. We want to put it there. Now you can see it's stretchy. We can put it on size to content. And I want to anchor it to bottom left corner. Change the position to zero and zero for no. I want to align it to bottom left corner. So put one in Y in alignment in here, so you can see it over here. No position X. I want to put it on 40 and position Y, on to put it on -60, right? So it has some space from these sides, this border, right? No, with that done, we need to name it. I want to name it tank body. Image. I want to duplicate it with Control D, and I want to call this one tank Torre. No, with this tank turret, first thing that I want to change is the image itself. I want to put tank top there, right? You can see it. No, I want to position it to be at the middle in here, right here, right? You can just position it like this, and I think that looks good, right? No. Based on the rotation of our turret, we want to rotate this, but how we want to rotate it. If we go down, there is a render transform in here that I want to use this transform to rotate it, right? We have an angle that we can rotate it. But you can see it will rotate it from this point. I don't want to do that. I want to put this on 180 and change the pivot point, right? No, the pivot point is like here, right? So I want to increase this pivot point to increase it a little bit, like here, right? Now if we change this angle, it's like it's at middle. The pivot point is like at middle. You can see, No, that looks good. So now we changing the angle in here, can say, what is the direction of our turret? That's it. How we can do that. First thing to do, we should click on Tank Turret and make it variable. So we have access to it in our graph. Now, like we did it in animation Blueprint, we need to get access to our BP tank, and how we can do that on a vent construct, I want to get the player pawn, with this, we want to cast this to BP tank, okay? And it needs an execution pin. We need to promote these to a variable, and I want to name this variable BPI tank, right? Now with this variable on Eventq, we want to update that angle, right? So we can get over BP Tank. First thing first, we want to check if it is valid or not. So check if it is valid. If it is valid, first, we want to get the control rotation. And after that, we want to get the actor rotation, okay? We did the same for animation blueprint with Delta rotator. We want to do the same in here with Delta rotator, it will give us the angle, right? Connect control rotation to A and actor rotation to B. Now with that down, we can break this and with the ya of this, we can set this tank turret rotation. So get the tank turret, and in here, we want to set the render transform angle. We want to change the angle, right? Connect the East Valley to here with this Ya over here. No, let's just say that. We can go to our BP tank at the event begin play in here at the event begin play. We can create that widget. So search for Create Widget, right. And with this Create Widget, we want to create the Tank UI and right away, we want to add it to viewport, right? That's it. Now let's just it compiles, save and round over again. Now we can see if you look right, you can see the image is showing going right and left. You can see? No, we know if we are moving forward or backward. No, we are looking backward, and we can see the image. The NQI is showing it to us as well. That looks us 32. 31 Import Arty files: No tank can move, and it has some effects. I can shoot but doesn't have health. Why doesn't have health and it can't be destroyed because we don't have any enemy. So we need to add an enemy in here. For doing that, there is Zip file in description of this video that is called art dot zip. It's artery or something like that, so it can shoot at a tank, right? So download it. Put it on your desktop right, click on it, extract it, or you can just click on it. If you are in Windows ten or 11, you can do that. And after that, there is RT folder, and after that, there is AsssSFolder inside it. You need to drag and drop it so you extract it, right? And with that done, you need to go to AL engine, go to content drawer, go to content folder. You can just right click on Content folder and tall it to show it in Explorer. Now, we have a content folder of our tank game, right? No. Let me minimize this one. We can just drag and drop the RT inside the content folder. It should be exactly like this. In content folder, after that, the RT folder and after that assets folder, it should be exactly the same. Because the paths are important in here because there are some effects particles, you can see, we have some particles, we have some visual effects that the path of them should be correct. Just with that, if you just close this, you don't need it anymore. We go to rreLEngine. Now in content drawer, you can see art folder there. There is nothing inside it. It's a bug. You can just close rreLEngine and open it up again. And with that, if you go to content drawer, no in RT folder, there is Assets folder, there is a vehicle in there, you can see a skeletal mesh. If you double click on skeletal mesh, you can see it. That's or skeletal mesh that we want to use it to shoot at or tank. There are some visual effects as well. If you go to affix, you can see it is in cascade, it's not augur, so you will learn the cascade as well. If you go back, there is a damaged static mesh as well, you double click on it. So whenever we destroy this artillery or RT, right? It's called artillery, I think. So we call it RT and this is the destroyed one. So whenever we destroy the artillery, this will happen. So now, we have enough asset for creating our enemy for our time. Let's see how we can do that. 33. 32 Blueprint for Arty: No, for creating artillery or RT, we call it RT from no. So let's just go to RT folder. We have a asset folder already there, but we want to right click, create a new. I want to call it blueprints, right? I'll click on it to open it or head inter to open it, right? Right click in here, create a blueprint class of type of actor, and I want to call it BP RT, right? Because it's easier to call it RT. I'll click on it to open it. In here, the only thing that I want to add is a skeletal mesh, right? And I want to put it over here. Now, for a skeletal mesh, click in here and choose over K west RTM 777, right? Just choose it and put it there. That's it. That is our artillery, right? We don't need to add anything because we want to have some animation with this. We want to create a anim class. So for creating that, I want to show you a new way. You know that from before, we right click, go to Animation and create Animation blueprint. But this time, I want to click on the skeletal mesh and click on adding here to create a animation blueprint for art, right? Or skeletal machine. So it will tell you where do you want to create this new blueprint, you want to say in art in blueprint, and we want to call it ABP because it is animation blueprint. Art, ABP art, head save, and head yes. So we select the skeletal mesh for it. So select the skeletal mesh for art, head okay, and it will create it for us and open it for us as well. That's cool, right? And by default, it will put it there because we had plus in here. That's it. Now, inside our animation blueprint, like always, we want to save mesh space, pose. So we have access to all the bones information, right? Connected to output pose, nothing will change, but now we have animation blueprint, right? Let's just put one of them inside the level. For doing that, I want to go here and put one in here, right? You can see it's not facing us. Everything will look good. Let's just make sure you save everything, right? So now we have a BPRT that we can start coding so it can shoot at our tank. 34. 33 Distance to tank: No, for art to be able to shoot at our tank, it needs to know about target. For doing that, there is lots of way, but no, I want to show you a new way to do it. I want to check the distance between our artillery and the tank. If it is 5000-20 thousand, for example, we can shoot at it, but if it is too close to us, we don't want to shoot at it, and if it is too far away from us, we can't shoot at it, right? So it looks more natural, right? So for doing that at event begin play, what I want to do I want to get the player pawn. Get player pawn. And we want to check if it is the tank, so we can use a cast to BP tank because we know that this artillery, this art should shoot at tanks, right? So we check. If the player pawn was the BP tank, it is our target. So we can right click in here, promote a variable, and we can call it target, right? So this is our target. Now that we have our target, we want to set a timer so we can shoot at it, right? So in here, I want to set a timer by event. And this time let's just put five in there. We will change that later and we want it to be on loop, right? Each five second, this event will happen so we can connect it to a custom event. So create a custom event, and I want to call this event fire. So every five second, it will fire at a target. But this time, I don't want to fire right away. I want to check the distance between our artillery and the target to see how much is the distance. And for doing that, there is a node that is called distance, right? It's up here, distance vector. It needs a V one and in two, and it will give us the distance between them, right? So V one can be just actor location, get actor location. What this will give us, it will give us the word location of our artillery or art, right and for the V two, we want to get the target actor location. So get actor location on over target. So what this will do, it will give us the distance between the artillery and the target that is over tank, right? So every 5 seconds, I want this event to give us the distance. So let's just use a printer string. This time, I want to show you a trick. I want to use a note that is called format text, okay? And in here, I want to say distance to target is a value, right? We want to put this value over here. How we can do that, we can do it with some curly braces. And inside here, if we say distance, right, it will create a pinning here that we can connect these two to it, right? And it will replace these curly braces with distance inside it with this value. This way, we have a clear way of debugging, right? And inside this printsting what I want to do, I want to add a key so it will stay and I can call it dist or whatever, right? You can call it whatever, just a attic name in here. If you run over game, no, you can see, no every 5 seconds, it should give us the distance. Right now, it is 3,000, right? If we go far away, it will be more look at it this way. It is 5,000 now. If we go away, again, you can show it to us, right? The distance right now it's 9,000. And after 5 seconds, again, it will give us the distance. Right now, it is 10,000. So because this artillery is pacing up and it should be like that, we don't want it to be able to shoot at our tank at the close range. If it is far away from the artillery, it can fire at tank, but if we get too close to it, it shouldn't be able to fire at us, right? And we should have a maximum range as well, because it shouldn't be able to shoot at the tank lots of miles away, right? Now, let's see how we can do. 35. 34 Target in range: Know that we find the target based on the distance, and we want to check based on the distance if we should shoot at it or not, let's just do that, right? So in here, we are just showing the distance, right? After this, what I want to do I want to use a branch in here to check. If the distance is 5000-20 thousand, it can shoot at us, but if it is not between them, it can't shoot at us. So we can get this distance and check if it is in range. We check if it is in range 5000-20 thousand, right? So if it is between these two range, we can shoot at it. So in here, let's just say print ring and fire. And let's just give it the color of green so you can see it better. And in case of falls, again, let's just use another printestring, to say not fire. Okay, and I want to put it to the red. So it means you can't fire it because it's too much away from us, right? So no with that, which is wrong with game. Right now, let's just see what is the distance. If we weigh, it's 3,000, so it says not fire, right? Again, not fire because the distance is 3,000. Go back no, go back a little bit more or no, the distance is 6,000 and it says fire. Again, fire, the distance is 6,000. And if we get way up again after 20,000, it won't fire at us. We know distance. And right now it's 22,000 and more than that. It's 27,000 and it won't be able to fire at us. You can just change this value to, for example, 30,000, right? So you decide what values you want to put in here. No, with that done, we need to be able to shoot, right? And we don't need these two printes 36. 35 Rotate arty: Know that we have a valid target in firing range, we need to first face the artillery toward the target and after that, shoot at it, right? So for doing that, I want to go to ABP RT in anim graph. And in here, there is a node that is called modify bone. And with this, we can rotate any bone that you want, right? So we did it several time. But first, let's see which bone we want to rotate. If you go to a skeleton of artillery, you can see if you click on card joint with rotating this, we can tell it to rotate which direction, right? Just with rotating carve joint. So for doing that, we need this modified bone. In here, the bone that you want to modify is called **** joint so let's just put it there. Next, we don't want to change the translation, click in here, don't expose it as a pin, and we don't want to change the scale, so don't expose this as a pin as well, but we want to change the rotation. And the rotation mode, we wanted to add it to existence. That's more than enough. No, what we want to change in here is just the Ya rotation around the Z axis, right? So right clicking here, split a stroke pin, and for testing that, what I want to do I want to dig this promoted to a variable, and I want to call it Ya value, right? So with this, we can test the rotation of this artillery, right? No, for testing it, go to Anim preview Editor and change the ya value. And with that, you can see the rotation of our gun is changing correctly. So now we are rotating this, but what do we want this artillery to face at? Let's think about that and we will do it in next video. 37. 36 Predict where tank will be after one second: No, let's talk about where the artillery should face at. So we have some options. First, it can face at the target, right? But if our tank is moving and our artillery is facing at the target, when it shoot, it takes four or 5 seconds to reach the target, right? Because the target is moving, it won't be able to hit it at all. So that is a problem. There is a no denari engine that will predict where over vehicle or moving object will be with this constant speed after four second, for example, there is a node for that. So what you want to do, we want to predict where the tont will be after four second and shoot there. And that's what we want to do. So for doing that, let's just go to BP RT and in here, I want to go to Eventiq. Let's just make some space. There is a node that is called suggest projectile velocity moving target. It will need a projectile start location and a target actor, and with these two, it will predict where over tank will be after 4 seconds. It will predict that for us, right? So the projectile start location, we know that we want to spawn over projectile, a tip of over art, right? So let's see. If we go to a skeleton, there is a socket in here that is called gun joint socket a tip of over gun that we can use that to tell it that this is or start location of over projectile, right? And we want to spawn over projectile from here. So for doing that, we can get the skeletal mesh and get a socket location off of it. Of which bone or socket you can go here and right click in here, rename it, Control C to copy its name and paste it over here. Now, this is our projectile start location, but the target actor is this target actor, right? You can just put it there, and before using this target actor, we need to check if it is valid or not, right? It's very important to check the external object that if it is valid or not. If it is valid, you can use it, right? Just with that, I want to enable the debug option in here. So click in here. And tell it to do it for one frame so we can see where it's facing at, right? Now, let's just head compile, save and know if you run word game, you can see there is a red cube around over time, right? And if we go and move, there will be a red dot at the front of our tank. You can see the red dot there. It means the location that it will be after 1 second. Why 1 second? Because the time to target is 1 second. So what this will not do, it will predict after 1 second where the tank will be, right? So again, if you run we move, you can see there is a red dot at front of us that at each frame, it will predict after 1 second where the tank will be. And with this red dot, we can change the rotation of our artillery, so it will face that red dot. And if you shoot at front of our tank, so whenever the tank reach that position, the projectile will reach, we'll reach that position as well, and it will head over tank. That's what we want to do. So first step is to change the rotation of our artillery based on the information that this note gives us. Let's see how we can do that next video. 38. 37 Arty Rotation: No, we are predicting where our tongue will be after 1 second, and we want to face over artillery to that predict position. So for doing that, this node, what it will give us, it will give us a launch velocity for our projectile, right? So this launch velocity have a rotation as well. It will give us the rotation as well. This node, basically it's giving us the direction to where our tongue will be after 1 second. And with that, we can get rotation from X. That's it. It will give us the rotation that this node calculate for us, predict for us, right? No, this is the rotation that our artillery should have. And if we say get actor rotation, this is the rotation that it already has. And we want to get the difference between these two so we can change the rotation of our artillery based on that. And for doing that, we need to use Delta rotator, right? We did it several times till no. So the A should be the rotation that it should have, and the B should be the rotation that it already has. And what it will give us if we right click on it, split the stroke pin. So the only thing that we need, we need just ya. We need to change the rotation around the Z axis. That's more than enough. So we can right click on this one, promote it to variable, and call it Ya value, right? It need execution pin. So let's just give it that like this. Now that we have a Ya value. Let's just go to ABPRT. We have Ya value in here. We need to connect them together. Right now, this Ya value inside over ABP RT and BPRT doesn't know about each other. So we need to connect them together. H we can go to event graph. First thing first in here, I want to get the Blueprint begin play. And in here, we want to get the owning actor and with that, it will give us the owner of this animation blueprint that is our BP RT, so we can cast this to BPRT, right? Now with that done, let's just connect the execution pin to here. We need to promote these two variables, so we have access to it everywhere. Now with this BPRTF thing that you want to do always, we want to check if it is valid or not. So let's just put it over here. If it is valid, we want to get the yo value from over BPRT. So search for Get Ya value, and with that, we change the value of this ya value inside over animation blueprint, right? We are connecting this ya value that is from over BPRT and this ya value that is from animation blueprint together, right? That's it. Now with that done, let's just compile and run over game. Right now, you can see over artillery is facing toward us. If it move, it won't move at all. But if it changes bit, you can see it is facing the position of that red dot that will be predicted by that note, that suggest node, right? So, based on the red dot that you have, you can see it, the rotation of over Artillery is changing as well. See, I you predict after 1 second, where we tank will be. Go forward. You see? It's facing that, not the tank itself. So we can shoot at it. You can see that looks awesome, right? See it. It's facing the right direction. Now that we are predicting where our tank will be after 1 second, and we are facing to that position. Let's just see how we can fire at it. 39. 38 Arty projectile: Know that our artillery is facing the right direction at front of our tank so it will shoot at it correctly and it can hit it. No, we want to have a projectile for our artillery. For doing that, I don't want to go from start. What I want to do, I want to use the one that we create for tank. The right and drop this one and put it on blueprint folder of or art folder, right? When you release it, it will tell you, do you want to move it or copy it. We say, copy it, right? Now, there is a copy of or BPI Tank projectile in here. We want to just call it BPI art projectile, right? That's it. She's called it art projectile. Now, with that, let's just double click on it in here. On projectile movement, we want to put the initial speed and max speed to zero. That's it. We don't want to do anything with it. We just want to have some velocity. So for doing that, first and first, we need to know about the target. So in here, add a variable and call it target, and the type of it, I want it to be BP tank because or target should be tank, right? We know what is the enemy of this RT projectile, right? Now, with that, let's just compile, what we want it to happen with this, we want it to be instance editable and expose on a spawn. No, let's just use this BP RT projectile and pass a target to. For doing that, I want to go to BP RT. You remember, if you go up every 5 seconds, the fire custom event will happen, and we will check. If it is in range, we want to shoot at it, right? So in case it is in range, this true will happen, and we can spawn or actor from a class, right? The actor that you want to spawn is called RT Projectile, right? So search for RT Projectile, put it there. It needs a spawn transform where to be a spawned, we can just spawn it at tip of the gun. So this gun socket is really important. So copy the name. And in here, we can get our skeletal mesh and say Git socket, transform, right? And the name of socket that you want to get it's transform is called Gun Joint socket. Control V to paste it there and connect it to span transform, right? Now, with that done, it needs a target, as well. This target is exactly the variable that we have it in here because we make it exposed on a spawn. That's why we see it over here, and we can pass the target to it, right? Know with that done. Let's just test that out. If you run our game, right now, it won't spawn any, right? But if you go backwards until you reach 5,000 C, it should and you can see it. I did spawn it, and because it has physics, it did go down. You can see it? No, it's spawning correctly. But let's see what velocity we should give it, right? So for giving it the velocity, we need to go to BPRTPjectile in here. First thing first in here, we want to get our target and check if it is valid. So check if it is valid at begin play. If it is valid, we want to change the speed of this projectile, so it hit the target. I hit the tank, right? And again, this time, I want to use the node that we use in here for such a projectile velocity moving target, right? To predict where our tonk will be after 1 second, right? So we can just copy this and paste it over here. With this, it will give us a velocity that we can use it to fire or projectile at the right direction. So if the target is valid, it needs a projectile start location. We can just get the start location of our projectile. At begin play, it will give us the start location if we search for get actor location. Okay? So this is the start location, and the target we know that is this but the time, I don't want it to be 1 second. I want it to take four second to reach the target. I don't want to have any debugging in here, and with that, it will give us a velocity so it can hit or tank correctly at the right spot, at the right position, right? So we have a velocity that this node gives us. Now, we can get our projectile movement. There is a variable inside or projectile movement that is called velocity. So search for set velocity down here. And we can give it this velocity and connect the execution pin to it just with that, if you head compile and run and go back, we'll see what will happen. Now, you can see it will shoot at us and after 4 seconds you reach that dot point in front of us. Just look at it, see? You see, can see it is shooting at us, and it will hurt us as well. We don't change the speed, right? And you can see, it will hit us again. That looks awesome, right? Again, if we go at the straight line, you can predict where we will be after 4 seconds, right? And if we shoot there you can see the tasting of it is good, as well. That looks really good. But if you change the speed, suddenly, it won't be able to shoot at us. You can see we shoot at front of us, right? Again, if we change the speed again, you can see, we can dodge the project times directly, and you can see by moves like this. You see won't be able to pet us, but if you go at the a straight line. You can see if you'll be able to help us. Just look at it. Beautiful it's helping us. So that is working fine. Or a projectile is working fine. But what I want to do now, if we go to BPRT, I want to change the range in here to zero to 30,000. I want to show you something if we get close to it. Just look at something here. When it shoot, there is no visual effects on this artillery. You can see there is no visual effect. There is no particle. There is no shock wave. There is no movement on the gun, and it doesn't look good. Now, we want to add lots of visual effects to the artillery. Let's see what we can do that. Next. 40. 39 Arty fire VFX: Now we want to add some visual effects to artillery when it's for something, right? So first thing first, let's just see what visual effects we have. If you go to RT folder, go to Assets, go to vehicle, go to West art, go to Effex. You can see there is three of them. One is a shock wave that will happen at the bottom of artillery whenever we fire. It is like this, right? The next one, if you do click on this one, you can see this will happen at the tip of artillery when we fire, right? You don't need to know all about this. We want to just use them, right? So for using them, let's just go to BP RT. And in here, I want to say a spa a meter. This time we should say a meter, right? A meter at location. What meter, I want to spawn the shock wave, right? The location of it is really important. Where do we want to location it? If we go to our skeleton, you can see in here there is a cog joint socket that is over here, and we want to use that socket. So let's just right click on it. Rename it controversy to copy its name because the name is important and get to Schele talmag and get socket location off of that. Get socket location, off of the **** joint socket and put it on location. Right? Now, let's just see if you had compiled and run, let's just look at it. When it fire, you can see there is a shock wave at the bottom. You can see it, can see it. That's cool. Right? Now next thing that you want to use is the explosion at tip of or gun. So again, for that, because it is a cascade e meter, we should say span a meter attached this time because you want to attach it at tip, right? The emiter that you want to spa is called cannon explosion, right? The component to attach is or skeletal mesh. And the attached point name, if you go here, is called Gun Joint socket to copy its name with Control C and paste it over here. For the location, again, we want to get the skeletal mesh and get socket, transform off of it, right? Off of the gun joint socket, and with it, we can right click on this one, split a stroke pin. Now we have the location and we have the rotation. We don't need to change the scale at all, but the location type, I want to change it to keep word position. Now with that, let's just see compile and run. Let's just see what will happen. It will shoot, and you will see it looks beautiful. Let's just go for rotation again. You can see that looks awesome. No, we have another visual effects there. No next thing that I want to do. I want to spawn a sound as well. So spawn a sound at location. And the sound that you want to spawn is called is Cannon Fire Single, right? That's it. And the location we can use the location of TipovOGun. That's it that we get from here, right? Now, again, let's just with no. If it should, let's see what will happen and no, you can see it there is a sound and built. Then you can see how beautiful it is. No next thing that we want to do. We want to do the gun movement. So whenever it's fired, the gun should go down and up like we're tack, right? Let's see if we can do that. Next 41. 40 Arty gun motion: Know that we have some visual effects for firing the gun, we need to add some visualization for the gun itself as well. So we move it whenever we fire, right? So for doing that, we need to go to animation blueprint in anim graph. In here, again, we want to use modified bone, but which bone. Let's just go to a skeleton, and in here, we have a gun joint. In here, whenever we fire or gun, this gun joint, we want to go down like this, go down and upright. Wanted this motion to happen. So how we want it to happen first thing, conjoint, right? Let's just go here. We need to add the modified bone in here. We did use this node a lot, right? First thing first, we don't need to change the rotation. So don't expose it as pin. We don't need to change the scale, so don't expose it as pin. We want to just change the translation. So we add it to existence. And for the translation space because we can have different rotation of this, I want to put it on bone space, right? Just with that, let's see which direction we should change this in direction of X. You can see, this is the direction of X. In here, first, let's just choose over gun joint, gun joint, and change the X. For example, let's say -50 go down, head compile, and now you can see it did go down, and after that, we want to go back to zero again. You can see it. So in here, I want to right click split a strike pin because we want to just change the X. Now how we want to change the translation. I want to do it with a variable. So in here, I want to create a variable and I want to call it recoil value or whatever you want to call it. The type want it to be a float. No, it is connected to translation X. And with that, if you head compile and in here, change the recoil value, can see it will go down and up. You can see how good it's working, right? Know what I want to do. I want to create a timeline for changing this recoil value. And where I want to do that, I want to do it in BP t. At the end of this execution chain when we fire over gun, right in here. So we need to create a timeline and I want to call it recoil. We did that for tank as well. And every time we want to start from the start, play from start, right? Hold control, disconnected from here, and connect it to here, right? Do click on it to open it. The length I want it to be 0.3, and I want to just add a flow track. I want to call it recoil value. Okay. And in here on the right clicking here, add the key at time zero, I want it to be zero. Add another key in here at time, let's just say 0.1. I wanted to go to one and add another key again. At time 0.3, we wanted to go to zero again, right? For you to see it better, I will click in here, click in here as well, so we can see all three key frames. I want to select all of them, right, click on one of them, and click on Auto so we have some curves. This will looks much better. Just with that, we can just close it. And in here, we have the recoil value. We can right click on it, promote it to a variable, and the naming is good, and we want to update it on each update of this timeline. That will happen 30, 60 times per second until it stop playing it after 0.3 second, right? No, we have a value that will change 0-1 and to zero again. We want to use that in our animation blueprint. But how we can connect this recoil value variable inside our animation blueprint to this one that we have it in our BPRT. You know that how to do it. Let's just go to ABP art, go to Avent graph, and we can get the recoil value from BPRt. So search for recoil. Get the recoil value. And in here, we want to set the recoil value variable that we have in here with this value that we get from PRT, right? That is coming from timeline. Now with that done because this recoil value, right now, it's value 0-1. So that's not enough. We need to multiply it by some value. For example, -100, so you will see it better and connect it to translation X. Now, if you run over game whenever it should just look at it. And you can see it did go down and after that, go up. You see, look at it. You can see how beautiful it is, no. We have some good visual effects on our artillery, art, right? That looks awesome. No, next thing that you want to do. We want to we artillery to be able to damage the tank. Let's see how we can do that. Next 42. 41 Apply damage in radius: No, the visual effects sound and the movement of our gun is okay. It looks good, but it's not hurting or a tank. It's not damaging it. Let's see how we can add some damage. For a damage, let's just go to RT projectile. When the projectile stop moving, we spawn some explosion, some sound, and at the end, we apply radial damage with the fall off, right? So in here, I don't want to put it at the end because this visual effects will block it. That's why I want to bring all of these to the end and control to pace that radial damage at the beginning. This is really important to add the damage first and after that, add the visual effect, right? So no, this radial damage needs a location, the origin, right? We can give it the location. Next, it needs actors to ignore. We should tell it to ignore itself, right? Ignore itself completely. So in here, we can create a reference to sell, okay? This is this self, it means this whole class, right? We wanted to ignore itself. It needs array. So with that, we can make array, right? Just make array with one input that it is itself and connected to ignore actors. So it will ignore itself and it won't damage itself, right? Because it shouldn't? No, there is a damage cause. The one that is causing this damage, again, it is self art projectile. So we can connect these two here as well. No, with that done. We have a damage inner radius and damage out radius. What it means, if the tank is inside 100 unit away from the impact point, it will deal 25 damage. But if the distance of the where projectile hit and where our tank is is 100-500, it will linearly decrease the base damage to a minimum ten, right? So with this, it's applying damage in a radius, in a sphere, right? For you to see it better so you can visualize it. I want to bring all of this to the right. And in here, I want to use draw debug, sphere down here, right? It needs a location. We can just use this location in here. And the radius I want it to be this inner radius for no 100, that's more than enough. The duration, I want to put it on, for example, five second and the thickness, I want to put it on ten so you can see it good, right? This is the inner radius that the radius of it is 100. I want to copy and paste this with control C control V, right? And this time, again, the location I want it to be the same. So let's just get the location from here and connect it to here as well. It's just for debugging, so you will understand it better. This one is for outer radius. This damage or radius, that is 500. So let's just put 500 for this one, as well, and I want to change the color to something like this, right? So we have two debugged sphere. Let's see what it will show. If we compile and run when the artillery hit us, just look at the and you can see there is an inner radius that if we are inside that, it will al 25 damage. And if we are inside outer radius, it will damage us something 25-10, right? 43. 42 Tank Health system: No herb artillery or art projectile, apply radial damage, but our tank doesn't get any damage. Let's see how we can make the tank, take some damage, right? For doing that, I want to open up the BP tank, so go to content drawer, open up the BP tank. And in here, find some space down here, for example, right? Right click in here and search for event, radio damage, right? So it will give us the damage received. It will give us the location that it received it. It will give us who caused this damage, and it will give us head info as well, right? But for now, I want to just use a printer string to see if it's working or not. With this printer string, I want to use format text. And in there, I want to say Tank got open and close curly braces, and I want to say damage inside it, and thank God, for example, ten in damage, right? So because we did put the damage inside the curly braces, it will give us an input with the name of damage right that we can replace it with this value or whatever value, right? And we can just show it with the print test ring. Now, let's just test it with that. If you run over game, you can see, let's wait until it hit us. No, it hit us. It says thank God 25 damage. You go back. You can see no Tank good 24 damage. If we go back more like this, it won't hit us at all. But if we get really close to us, the damage will be increased. Of course it's not easy to get less damage because the outer symbol is not good. So in here, for example, and no and now you can see the tank got ten damage because we are inside the outer rages, see? So our apply radial damage is working fine, but we don't have any health system to pres it with, right? So for doing that, I want to create a variable, and I want to call it health. And the type of it, I want it to be afloat. And after that, add another variable. I want to call this one MX health. No, let's just test some value. For example, the McElf, I want to put it on 100 and the health, I want to put it on 50, right for testing. No, with that done because I wanted to show the health always what I want, do I want to go to Event tick. Let me find Eventik. For finding it easy, you can go to Event Craft and in here, click on Event tick in here, and it will highlight it for us, right? At the end, in here, I want to add a printer sting. We will delete it at the end. But for no, we want to just show the health, right? And with this, again, I want to use a format text, format text, and I want to say health is equal to open and close curly braces in here, I want to say edge or health or whatever. We want to replace the curly braces edge pin that it did create in here with actual health and show it with the printer string at the end. Now with that done, we need to expand this and give it the key. For example, edge or health or whatever. Just static string is more than enough. Now if you run over game, the help is 50, and it will stay there because we give it a key. But if it did hit us, nothing will happen to help because we are not decreasing it, right? For decreasing it, whenever we get event radial damage, what we want to do we want to get our health like this and decrease it subtract it with the damage received, right? And after that, save it inside itself and connect it like this. And update the health with this new updated value, right? No, just with that. Let's just check if we run over a game, the help is 50. If the artillery hit us, let's see what will happen. Back a little bit. No, you can see the health is 26. And again, if it hit us, the help is one, right? Again, if it hit us, you can see the health is going less than zero, so that's working fine, right? The health is decreasing. But when we decrease the health, we want to check with the branch. If the health, we can get the health again over here. If the health is less or equal to zero, it means the tank is destroyed. And in here, we can use a printer to show that for no, right? And I want to say tank destroyed, right? And what I want to do I want to change the color to red, this time we don't want to show the print testing. We don't need it because we are showing the health. So let's just delete this. We don't need it and connect the execution pin directly to here. And now with that, change the position of all of this. A little bit of organized will be good. We can just select this after that hold control, select this head Q, and we will have a straight line in here. We can do it for this one. Select this one, hold control, select this one, head Q, and now you can see a straight line in here. Again, we can do it for this one. We can do it for all of these. Select this one after that, this one, head Q. You can see we have a straight line no everywhere, right? That looks awesome. We can select some things, and with the arrow key, we can change the position of them as well for organizing them, right? No, the health is decreasing. Let's just test that one more time. The LP is 50. If it hit us, it's showing the distance to target, we need to delete that as well. TheELp is 25 because it hit us in its inner sample. You know, we can see the health is one, and if it hit us one more time, the tank will be destroyed. So that's good. No, we have a health system, but we are showing it with just some text. Let's see how we can actually show it with a progress bar. 44. 43 Health bar: No for showing the actual health bar with the progress bar. I want to use this crosshair user widget. Just click on crosshair. Click on this magnifying glass to find the widget class like this. It's called WP crosshair click on it. You remember we had a progress bar in here that was for reloaded. So we can click on it, Control D to duplicate it and use it for health bar. So I want to name it Health, right? What I want to change in here, I want to change the position X and position Y to zero for no. Let's see what is the position X of this one. It is 90. I want to click on this one and change the position X of this one to -90. So it is on this side, right? The default percent, I want to put it on one, but I want to change the color. So click in here, change the red to zero, green to one, and blue to zero, right? That's it. Head okay. Now, we have a green bar that we can use it for health, right? But how we can update it? First, it should be a variable. After that, we should go to graph. How we did update the reload. You remember, we did it with interfaces, so we need to add another function to that interface to update the health as well. Click on Content drawer, go to interfaces folder to click on this one, and I want to add another function and I want to call it update health like this, update Health. And we need an input that I want to call it health, right? And the type of it, I want it to be float. That's it. Now, if you go to WP crosshair, we have update Health in here, right? Because we did add it to interface, and because in class setting, we did implement the BPI crosshair interface, it will automatically be added in here. Do click on update Health to create its event. And what I want to do I want to get the health and like we did it in here, we want to set the percent on it. Set percent, right? And the percent is a value 0-1. So we should make sure this help is a value 0-1. We pass value 0-1, right? Now that we have this event or function implemented, we can use it inside or BP tank, right, like we did it for updating the reload, right, reload value. So in here, when we change the health, we want to update the cross hair widget blueprint that does have the health bar inside it, right? So before checking if the tank is destroyed, we want to update this crosshair, right? We want to get its user widget, so get user widget and with it, we want to say update health, right? But as you know, the health is updating the percent on OrwBP crosshair, the percent, right? So it should be a value 0-1. But the health right now is a value 0-100, for example, right? So how we can change this health from a big value to a value 0-1. First, let's just connect the execution bin so we don't forget that. First, we have a health and we have a max self, right? So if we just divide them together, divide the health by mac self, it will give us a value 0-1. So for example, if the health is zero, 0/100, it will give us zero, and it will be zero. It is 0-1, and person will be okay. If the health is 50, 50/100, that is or max health, it will give us 0.5. 0.5 is the value 0-1, and it's okay, right. But if the health is 100, 100, divided by 100, that is the max self, it will give us one. And again, it is a value 0-1, right? So if we just divide the health by max self, we will get a value 0-1. It will work correctly. Now with that done we need to update our health at the begin play as well, because if you run a game, by default, you can see it is 100 in here, but the help is 15. So it's not working fine, but if it shoot us, it will update the help. Now, you can see the help is 25, and you can see it the 25 in here, 25%. And now you can see the tank is destroyed and health is decreased, right? It's empty. It's happening because at begin play, this DUBP cross here is at 100. So at the begin play, we need to update first with the current health of our tank. For doing that, we can just copy all of these and put it on event begin play in here. At the end of this execution path, we can just connect it like this. Now, if you run our game at default, you can see the health is 50, and we can see the health 50 in here. That's working fine. If it hit us, just look at it. It will increased by 25, and we can see a 25% of the health work after that tank is destroyed and you can see, it's working fine. Our health system is finished, no. But when the health of our tank is reached zero or less than zero, we need to destroy our tank. We need to have some visualization of our tank being destroyed. Let's see how we can do that next video. 45. 44 Destroy tank: Let's see how we can actually destroy our tank. For doing that, I want to go to content drawer, go to Blueprint folder inside the tank folder, and in here right, create a blueprint class of type of actor because it is more than enough. I want to call it BP, damaged tank, right? Don't click on it to open it. And in here, I want to add a static image, so click on add an add static mesh and put it as a default synroot. You don't need to do that, but it's cleaner this way. Change the static machine here to SMS tank damaged. This one, just select it there, and that's it. Now, I want to add a Niagara system. So add a Naga particle system. And this time again, I want to use the damaged tank. That's it. That's all we need to do. We have a blueprint class that we can use it as destroyed tank. Go to BP Tank, and in here, I want to delete this printer ring. We don't need it. We have a progress bar for that. We have a health boar. And in here, we don't need this printer ring, as well, because we want to destroy your tank completely, right? So in here, in case of true, it means the health is equal to zero or less than zero. So in this case, we want to spawn actor from a class. What actor it has damage inside it, so it's called BPI damage damage tank. Just put it there. For the span transform, we can get the actor transform that will give this BP tank transform to this span actor, right? And with that after it, we want to destroy this tank, right? Destroy the tank, so it will be replaced with this damaged one, right? If we had compile and run, let's wait until it hit us twice, right? At once, and it hit us. You can see the health. It's 25, I think. And again, it did hit us. Now, you can see or tank is destroyed. So what I want to do now, I want to go to damage Tank and in its event graph on its event begin play, I want to set a timer set timer by event, right? So in here, I want to say, after 2 seconds, reload the game, right? So we need to create a custom event for it, and I want to call it reload. Level or whatever you want to call it, it will be okay. So after 2 seconds that we spawn this damaged tank, this reload level will happen, and we want to open up the level that is called new map. So let's just put new map there. No, with that, let's just test it. If we run over game, let's wait until it hit us. This is the first time it will decrease our health by 25. And again, if it hit us again, and we are destroyed and after 2 seconds, it will be reloaded. The game will be reloaded. No, our artillery can hit us. But what we want to, we wanted to be able to hit artillery as well. So let's see how we can hit the artillery and damage it. 46. 45 Arty get radial damage: No, we want to be able to destroy the artillery. Let's see how we can do that. For doing that, if we go to content drawer, we have a BP Tank projectile. Let's just open it. You remember, I did say this aploy radio damage needs to be at the beginning of this unpjectile stop because if you don't do that, this response system at location, it will block this aploy radio damage. So let's just use Control X to cut it and connect these two here directly and create some space in here. And with that, I want to use Control V to paste the apply radio damage connected like this, like we did for RT damage, apply radial damage. In here, we want to do the same for the location, and for ignoring actor, we can create a reference to self, get a reference to self, right, and make array with it, make array, and with that done, we can just connect it to ignore actors, and we can tell it the damage causer is self, right? That's it. Now with this, we should be able to at the BPRT. So we should go to BPRTFind empty space in here, and we need to implement the event radial damage, right? Again, I want to use a printer sting. This time, I don't want this artillery to have help. I want to say RT destroyed. That's it and the color of it. I want it to be red so you will see it better. Now, with that on, let's see if it's working or not. If we shoot at it like this, you can see, it's not saying artillery Destroy, right? It's like it's not hitting it at all. It's because if you click on or Skeletalmage and go to collision section of it, let me go down. It says no collision. So we need to change this to block everything. Now, if you run game and shoot at our artillery, you can see he's hitting it, but again, it's not saying the artillery destroyed. And the reason is, if you go to this collision preset, the type of this object is a word aesthetic, and that is a problem with radial damage. For you to be able to apply some radio damage to something, this object type shouldn't be word estatic. So that's why I want to change this to custom, tell it to block everything. But the object type, I wanted to change it to word dynamic or something else, right? Now, with that, done, if you run or game and shoot, no, you can see it says, Artillery destroyed. And if we close to it, again, it's affected, right? No, we are getting the event radial damage in our BP RT. No, it's time to actually destroy it. You try to do that. We'll do it next video. 47. 46 Arty get destroyed: No for creating a blueprint for destroyed or damaged RT. For doing that, I want to go to Content drawer, go to ART folder, go to Blueprint folder. I want to right click create a blueprint class of type of actor, and I want to call it BP, damaged RT or artillery right I click on it to open it in here. We want to add a static mesh. We did it several times till now. I want to make it as default scene route. No, I want to choose a static mesh for our SMS, RT damaged, right? That's it. No, I want to add a cascade this time, cascade particle system. The visual effects for destroyed RT is in cascade. That's why we add cascade in here. No, I want to choose Ps wreckage west RT, right? Just put it there. Now you can see, it's exactly like Niagara pot, it is in cascade, right? Let's just head compile save. And now we want to go to BP RT. Instead of saying, Art destroyed what you want to do? We want to spawn. Actor from a class, and I want to search for damaged RT. Just put it there, and we can get the actor transform for the transform of our span actor, right? With that, it will be a span, but we need to destroy the actor itself, the BP art. Now, with that on, if you had compile and run and shoot it, you can see, No, you can see it is destroyed, right? That looks awesome. No with that done. I want to go to BPRT and in here, just check somethings out. We don't need this printer sring. So what I want to do, I want to grab this withholding Control and connect it directly to here. We don't need this printer sring at all. We can organize a little bit, right, like this. We can bring all of this a little bit to the left, as well. So it's not necessary. But what I want to change in here, I want to change the minimum range as well because it doesn't look good if the tank is close to artillery and it can hit us. This artillery is facing upward, right, and it won't work like this facing at us directly. So I want to put 6,000 in here. So if the tank is in range of 6,000 to 30,000, it can hit us. If you run over game, right now, it won't be able to hit us. But if you get away from it, you can see it will be able to hit us. You can see, it's everything s, right? I thought maybe we are there, but we are not there. So you can see, it's working fine. And the help is working fine. No, next thing that I want to do I want to add one more of these artillery, create another one, right? For example, here, right? No, with that done, we have more enemy to shoot at. And the next thing that I want I want to go to let me see the RT projectile. And in here, delete this draw debt because we don't need them anymore. We know it's working fine. No, or game is much cleaner. With that, we can have two enemies that are shooting at us, right, and it can destroy us. See both of them are shooting at us and let's one of them, it wouldn't destroy because and destroy one of them, go to other ones. If it go straight to it, it will be able to hit us once, right? Yeah, praise for help, and it did destroy it, as well. That looks awesome. Or artillery is working fine, or a tank is working fine.