Unreal engine 5 Create FPS game with a Boss battle | Navid Ansari | Skillshare

Playback Speed


1.0x


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

Unreal engine 5 Create FPS game with a Boss battle

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 FPS Promo

      1:41

    • 2.

      01 Create project and import files

      3:18

    • 3.

      02 FPS Blueprint

      4:45

    • 4.

      03 Look around

      4:16

    • 5.

      04 Go forward backward

      2:47

    • 6.

      05 Go left and right

      1:39

    • 7.

      06 Add gun

      2:19

    • 8.

      07 Sprinting

      2:53

    • 9.

      08 Animation blueprint

      3:15

    • 10.

      09 Get character speed

      2:24

    • 11.

      10 Blend spaces

      5:49

    • 12.

      11 Crosshair UI

      3:17

    • 13.

      12 Crosshair wings

      2:42

    • 14.

      13 Aiming

      4:19

    • 15.

      14 Start aiming

      4:19

    • 16.

      15 Aiming animations

      3:12

    • 17.

      16 Aim walking

      6:12

    • 18.

      17 Anim montages

      4:52

    • 19.

      18 Muzzle flash

      4:34

    • 20.

      19 Firing sound and shell eject

      1:58

    • 21.

      20 Line trace when we are aiming

      6:48

    • 22.

      21 Line trace for not aiming state

      3:30

    • 23.

      22 Return results

      2:33

    • 24.

      23 Fire tracer VFX

      4:47

    • 25.

      24 Fire Impact VFX

      3:59

    • 26.

      25 Gun burst mode

      4:10

    • 27.

      26 Print string tip

      3:25

    • 28.

      27 Ammo manager

      3:17

    • 29.

      28 Reload gun custom event

      3:06

    • 30.

      29 Fill up the magazine

      4:32

    • 31.

      30 Use Rest of the ammo in storage

      1:53

    • 32.

      31 Reload manualy

      4:21

    • 33.

      32 Reload animation

      5:14

    • 34.

      33 Reload sound

      1:58

    • 35.

      34 Firing when sprinting

      3:29

    • 36.

      35 Fix running and gunning

      2:03

    • 37.

      36 Ammo UI background

      3:02

    • 38.

      37 Horizental box widget

      4:26

    • 39.

      38 Ammo UI for magazine and storage

      4:59

    • 40.

      39 Update ammo UI

      4:30

    • 41.

      40 Ammo Item

      4:20

    • 42.

      41 Kraken blueprint

      3:30

    • 43.

      42 AI controller

      4:24

    • 44.

      43 Kraken Move to

      5:23

    • 45.

      44 Check if player is in range

      3:07

    • 46.

      45 Kraken chase player

      3:27

    • 47.

      46 Kraken get damage

      2:38

    • 48.

      47 Kraken health system

      3:32

    • 49.

      48 Kraken Health UI

      6:12

    • 50.

      49 Kraken Health bar Visibility

      2:32

    • 51.

      50 Kraken animation blueprint

      3:58

    • 52.

      51 Kraken death animation

      2:57

    • 53.

      52 move to decorator

      3:11

    • 54.

      53 Kraken Attack task

      3:57

    • 55.

      54 Kraken attack animations

      4:50

    • 56.

      55 Kraken damage player

      2:18

    • 57.

      56 Player health and shield system

      4:50

    • 58.

      57 Player health UI

      6:01

    • 59.

      58 Update health UI

      3:27

    • 60.

      59 Item type

      3:17

    • 61.

      60 Item pickup

      4:53

    • 62.

      61 Game over UI

      3:33

    • 63.

      62 Fottstep sound

      3:44

    • 64.

      63 Input not working after reset

      1:08

  • --
  • 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.

16

Students

--

Projects

About This Class

In this course we start from creating our FPS character that can move around look around at aim at things

next we will add some UI to our character so we now where we are aiming then we add a ammo system to manage how much ammo we have

next we will add firing weapon mechanics and add visual effects (Niagara system) and sound 

next we add some UI for both ammo manager and health and shield UI with widget blueprint

then we will have a reload system 

then we start with animations to play the reload animations walk and sprint animations and event firing animations

then we go and create a AI to be our enemy and we use a kraken skeletal mesh for it that can attack player and get to be killed as well

next we create a modular Item blueprint that can be ammo item , health item or shield item

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 FPS Promo: In this course, we're going to create a FPS game. We start with how we can look around and move around. After that, we will add a gun to hand off or character. Next, with some tools in the widget blueprint, we will add a crosser without using any texture or image. Next, we go for the animations, so we can run, we can walk, and we can walk and shoot as well. And we have AM down site, so we can look at the scope and shoot. After that, we will add some visual effects, some sound whenever we fire over gun. Next, we go for reloading over gun, as you can see, it looks awesome. The reloading will have a full sound as well. Next, we go through in depth UI design for our ammo system, and after that, for our health and shield bar as well. Next, as an enemy, we will import a crack skeletal mesh, and we use a AI controller to control over cracking so it can chase the player, attack the player, and kill the player as well. And we can kill the racking too. Next, we will have some items, for example, ammo, health, shield, so we can pick them up. And for that, we will create a modular blueprint for the item. So if you put one of these items in the level in there, you will decide what this item should be. So let's just start this course together. 2. 01 Create project and import files: For creating an FES game, we need to create a project, and I'm using ARL Engine 5.5 0.3. Please, if you are a beginner, just stick with this version because a newer version, they will change some name of the nodes, and it will confuse you. So install ARL engine, 5.5 0.3 and open it up. And in here, go to games and in here, create a blank project, right? We want it to be in blueprint, the desktop maximum, and we don't need any starter content, and I want to call it FPS, right? Head create and it will create or project. Now while it's opening our new project, in description of this video, there is a zip file that is called fps dot zip. Download it. Put it on your desktop, like I'm doing in here. And don't click on it to open it. You can see there is FPS file there. You need to drag and drop this and put it on your desktop. The paths of the file inside it is really important. So if you open up this FPS folder inside it, there should be assets folder. That's it. It shouldn't be none other things. Changing the names in here is not write for no. You can change the names or reposition things in ARL engine. You shouldn't do it in here. No, open up ARIO Engine project. Go to Content drawer, right, click on Content folder, go and click on showing explorer. That's it. No, it will open up the content folder of our FPS project, right? You can just drag and drop this FPS folder inside it, and know with that done if we go to content drawer, there will be FPS folder, but there will be nothing there. We need to close an open Ale engine, but for no, just leave it as it is. We need to change some settings, and after that, we will go and close an open Aureo engine, right? First thing to do, go to Edit, go to Editor preferences, and in here, search for open. And in asset editor open location, change it from default to main window. So whatever we open, it will be open over here. It will be easier to work with. Now, you can just close it. Next thing, head control is on your keyboard to save this level. You can just save it in content folder. Head save, and it will be saved. No, next thing that you want to do we want to go to edit project setting, go to Maps and modes, and change the editor starter map to the new map that we save. After that, go here for game default map, change it to new map as well. That's it. After that, you can just close it. Everything will be good. You can just close Are engine. And go and open it up again. No, we don't rear engine open. You can go to Content drawer. In FS folder, you can see there is all of these assets and we want to use them to create over FPS game. There is some no graphics, some textures, and some skeletal mesh that you want to use for creating over FPS game. 3. 02 FPS Blueprint: No first step to create our FPS game is to create a blueprint. But before doing that, I want it to be organized. So inside this FS folder, I want to right click, go to New folder and create a new folder, and I want to call it blueprint. So all of our blueprints will be here. Go inside the blueprint folder, right click in here, create a blueprint class of type of character because it has character movement component inside and it will be easier to create a FPS game, right? So create a character class. I want to call it BP FPS. That's it. I'll click on it to open it and you can see it will open up here. That's okay. No, because we want to create a FPS game, first person game. That's why I don't want to use this mesh that we have in here. The first thing that is important in FS game is the camera. So click on the capsule and click on AD and add a camera. So search for camera. Put it there. This is our camera. Next, as child of this camera, I want to add a skeletal mesh. If I just deride and drop this, put it as a child of that, it will be awesome, but we can't do that. We can just leave this, but click on the camera, click on add and add a skeletal mesh. Search for skeletal mesh and add it there. I want to call it arms because in FBS game, we will see just the arms. That's why I'm calling it arms. And with that, I want to click on the arms and go to skeletal mesh acid and choose Sk mannequin. And you can see it over here. Right now, the position of things is not good in here, so I want to change the position of camera first. I want to bring it up like this. I think that's good at top of or collision, right? Right now, you can see whenever we change something, it goes ten unit up, right? Or we can just change that by clicking in here and put it to one or we can just disable it completely. No, we can position it better. For example, over here at top of the capsule component. No, the positioning of overhand is not okay, so click on the arms and we need to bring it down like this. Like, let me bring it down until it reached the end of this camera, right? So again, it needs to go down like. Right? No, for you to see the hands, what I want, do I want to choose animation in here? For example, click in here, change the use Animation blueprint to use animation asset. And with that, we can just choose a ideal animation, right? Arms idle. Now, you can see, we didn't need to rotate it at all. So just with this, everything is working fine, right? It's always a good idea to sit animation like idle and after that, change the position. It will be easier like this. Now, for you to see it better, what I want to do I want to go to Content drawer in here, right click, go to Blueprint class and create a game mode base. And I want to call it GM BP for game mode. Blueprint, and I want to call it FPS. I'll click on it to open it. The only thing that I want to change in here is default punk class. Click in here and change it to BPPS Head compiles save know with that, if you go to our new map and go to wordsetting in here, we can change the game mode overr from non GMBPFPS. Just with that, if you run over game, no, you can see the arms. Of course, we can't move anything because we didn't write any code for you to see it better. I want to click in here and open it in new Editor windows. Pi, right? You can see it. One problem that we have in here is that we can't see the arms, right? For us to see it, we can change the position of the arms. For example, bring it up a little bit, like this. Of course, we'll change it in future. But no, you can see it better. Again, let's change it, bring it up a little bit and run. No, you can see it better. I want to bring it a little bit to the left as well. Like this. If you run, no, you can see the arms better. Of course, this is not the end position that you want to put there just for no leave it with these values, and we will change it later. For no it is good. 4. 03 Look around: No first thing that you want to do, we want to be able to look around. And for doing that, we need an input. So let's just go to Content drawer and in here, go to FPS folder, right click in here, create a new folder and I want to call it inputs, right? Do click on it to open it, right click in here, go to input and create the input map in context. I want to call it IMC FPS, right. Do click on it to open it. Next, we want to create input action. So right click in here, go to input and create input action. I want to call it I look around, right. With that, because we want to look up down left and right, that's why I want to change this to axis to the. Make sure you save, and after that, we need to map it inside or input map in context. So in here, create a new mapping, and what you want to map is I look around and how we want to look around with most X and Y. So click in here, go to most and change it to most X, Y to the axis, right? Just with that, we need to go and implement this IMCFPS inside our blueprint, right? So go to event graph in here, get the player controller first, get player controller. And off of that, we need to get the enhanced input component off of it and add or input mapping context to it. Add input mapping context, right. Connect the execution pin to it and click in here and choose IMCFS. Now with that on, if you head right click in here, search for a look around, you can see there is action event in here. That with that, it will give us X and Y of over mouse, right? So grab it over here and break it. It has X and Y of over mouse, and with that, we can change the O of over camera, for example, or controller with the X of the mouse and change the pitch of over camera or over controller with the Y of overmse. So in here, first thing that you want to do, we want to add controller a input for looking left and right, and we can use just the s of it, right? Next thing, we want to be able to look up and down. And for doing that, we need to change the controller pitch, controller, pitch input, right? And we need to change the pitch by Y of our mouse. Just with that, if we head compile and run over again, no, you can see, I can look left and right. I can't look up and down, but left and right is working fine. The reason that we can't look up and down, if you go to class default and search for pitch, there is a use controller rotation pitch that by default, it is off. If you turn that on and no runo game, no, we can look up and down. But the problem with looking up and down, that it is inverted. So we need to change something. So whenever with our mode, we go forward, we look up, right? For doing that, there's a couple of ways we can just multiply this Y by minus one like this, multiply this by minus one, and it will work. We put it over here. Now, if you run over game with that, we can look up and down left and right, everything is good. But the best way to do it is not like this. We can just go to input map in context and in here, add a modifier to over most X and Y. Add a modifier and the type is the negate, but we want to just negate the Y, right? So expand this and tell it not to negate X or Z, just to negate the Y. Make sure you're safe. No, run over game, you can see we can look up down, left and right, and everything is looking perfect. Everything beautiful. Now we can look around. It's time to move around. 5. 04 Go forward backward: No we want to be able to go forward and backward. For doing that, we need go to FPS input folder, right click in here, create a input action, and I want to call it a go forward. Backward. I'll click on it to open it because for going forward and backward, it's just one value, so we can just change this to axis one D, a float value. You can just save it and now go to IMC FPS. We need to map it there. So in here, what do you want to map is called go forward and backward. No, when do we want to go forward, clicking here, head W. And when we want to go backward, clicking here to add another input and click in here heads. Whenever we hit S, we want to go backward. But by default, whenever we hit W or S, it will pass one. So we need to negate the S, so it will pass minus one. So go here to modifier and add a negate modifier there. That's it. Now with that, we can go forward and backward. And how we can do that, in here, we can say, I go forward. And backward, right. And with that done, we can add movement input based on the action value that we have. We can just connect this action value to here, but the direction is really important. To what direction? We need to go forward and backward. And this scale value is giving us a value between minus one and one. If we hit W, it will give us one. If we hit S, it will give us minus one. So the direction that we want to go is a forward vector for going forward, and forward vector, multiply by this scale value. Whenever we S, it will be minus one. So forward vector, multiply by minus one, it will give us backward vector, right? So we can get the control rotation, get the control rotation. And off of that, we can get the forward forward vector, right? And with that, we can go forward and backward. Let's just compile and run word game. Now, if you go forward, you can see it's working fine. We can go forward and backward and we can look left and right. That looks awesome. But next thing that we want to do, we want to be able to go left and right. Right now, D and A on our keyboard is not doing anything. Like we done it for Ford Victor, we have the same thing for right Victor, as well. I wanted to give you this as a challenge. Try to go left and right with D and A on your keyboard. We will do it next. 6. 05 Go left and right: For going left and right. Like we did it in last video, we need to create a input action. So right click in here, go to input and create input action. We are inside the inputs folder. I want to call it IA, go left, right. I'll click on it to open it. The top of it, I want it to be float as well because either we going left or going right. Okay? And now go to IMCFPS, create a new mapping. We want to map, D, go left and right. Choose IA go left and right. And whenever we hit D, we want to go right. And add another input whenever we hit A on our keyboard, so click in here, had A on your keyboard, we want to go left. But again, at both of these cases, it will pass one. Whenever we hit A, we want to negate it, so it will pass minus one. So click in here, add a modifier and choose the negate. That's it. Make sure you save, no go here. And like we did it for going forward and backward, we need the invent, go left, write the event of it, right? And again, we need to add movement to input, right. And with that, scale value, as you know, it should be action value. But the word direction, again, we can get this control rotation, and off of this, we can get the right vector and connect it to word direction. Just with that, we have compile save and Runo game. Now, you can see, I can go left and right and everything is working fine. And that's it. That's all we need to do for moving around or. 7. 06 Add gun: No next thing that we want to do. We want to give our player a gun. Let's see how we can do that. For the gun, the gun that we imported is just a skeletal mesh. So we can just click on our arms in here and click on a add a skeletal machine here, right? And the skeletal mesh, I want to call it gun. Right. And with this, I want to go here and in the skeletal mesh asset I want to choose over gun. But if you go to viewport, you can see the gun rotation is not good at all, right? So how we can put it in hand of or character or character skeletal mesh, if you click in here and click on this magnifier glass and find the skeleton and double click on it. There should be a socket in here that we can use. It's called Grip point, right? With that, if you go here and click on or gun and choose the parent socket to be grip point, it should be at the hand over character, but right now, it's up there, right? That's not good. The reason that it is up there, it's because it has a offset in its location. So for fixing that, we can just click in here and it will put it in hand character. No, that down, let's just compile and run over game. No, you can see, we can see the gun, look at everything, right? You can see. But the positioning of our hand is not okay, right now, we can't find that out, right? So we need to bring it down a little bit. So click on the arms and bring it down a little bit. Let me bring it down like this and no head compile and testo to see if it's okay. If this is okay for you, you can just use this. But again, you can move it to whatever location that you want. For me, right now, this is good. But with just changing this arm, you can bring it forward, backward, down up. You can do whatever you want. This position for no is good for. 8. 07 Sprinting: No next thing that we want to do. We want to be able to sprint, right? So let's see how we can do that. For doing that, we need an input. So let's just go to Content drawer in here, go to inputs, right click in here, create a new input action. And I want to call it IA sprint, right? Don't click on it to open it. The digital Boolean is more than enough. You can just close it. Go to IMCFPS. We want to map it over here. So click on New mapping to create a new map. And what we want to map is called a sprint, right? Let's just go down. When do we want to happen? Click in here, head left shift on your keyboard to put the left shift there, and that's it. With the left shift, we wanted to be able to sprint, right? Now in our event graph blueprint, what we want to do. We want to right, click Search for AA sprint, right? With this whenever we press left shift, we want to be able to sprint. And whenever we release the left shift, we want it to walk, right? So at default, we wanted to walk. But how we can do that. Inside the character movement component, there is lots of options that we can change. For example, Max walk speed that by default, it's 600. By default, we want to go to walk in. So I will decrease this to 250. So no, just with that, if you run over game and go forward, you can see we are going forward, not fast. Just 250 centimeter/second, right? No, we want to change the max walki speed whenever we hold shift. We can do that. This variable in here, Max walkie speed is inside the character movement component. So we can grab this and search for Max walkie speed, and we want to set the Max walking speed, right? Just with that whenever we press the left shift. We want to change the max walk speed to 600. And again, let's just select this Control C Control V to paste it over here. Whenever we release the left shift key, we wanted to bring it back to 250, right? Now with that down, let's just say compile, save and run. No, if you go forward, you can see it's walking, and if you hold left shift, the speed of walking is much more now. You can see we are walking and no we are running. Now, the next thing that you want to do we want to play the animations. Right now, it's playing the idle animation, and it doesn't matter if you are walking or running. Let's see how we can add animations. 9. 08 Animation blueprint: No, we can move and look around, but the problem is there is no animation. So let's see how we can do that. Click on the arms. You can see instead of just using one animation to be played, we can tell it to use animation blueprint. And with the animation blueprint, we can decide which animation to be played, right? So for doing that, I want to go to Content drawer, go to Blueprint folder, and in here, right click, go to Animation and create a animation Blueprint, right? For which one, we want to create animation blueprint for SK manikin arms skeleton. So select that head create and I want to call it ABP for Animation Blueprint FPS, right? They'll click on it to open it. So this is our animation Blueprint. And in our animation Blueprint, we have a preview that is showing us what it's connected to Output pose. Right now, it is in Apos, nothing is happening to it. We can go to Asset Browser and find the, for example, arms idle, right? Just drag and drop it and connect it like this. Now if you had compile, you can see it will go to IDL pose. And know with that, if you go to our BPFPs, click on the arms, we can decide that animation blueprint. That is called ABP FPS, right? Know with that done, if we run over game, it will be exactly like before, it's playing the idle animation for us. And if we move, nothing is happening, right? Now, the next step is to decide which animation to be played. And how we can do that, we want to check the speed of our character or velocity of our character. For example, if it is 250, play this walk animation, right? But if it is 600, play this sprint animation. And if the speed is zero, play the idle animation, right? For example, if I connect the walk animation there and head compiled. No, you can see it's playing the walk animation. But the problem with this is that it will play at once, and after that, you can see it will stay here. That's why we didn't enable the loop animation. So enable the loop animation after that head compiled, you can see it will play it in loop. And now you can see we have a walk in loop animation. Now if you run over game, it will always play the walk animation. Doesn't matter if you are walking or running, it play that animation, right? No, we don't want to do it like this. We want to use these three animations and blend between them. So whenever the velocity is zero, we play the idle animation. And whenever we start walking, we smoothly go from idle to walk. And whenever we hold left shift, smoothly, go from walk animation to sprint animation. If we connect the sprint animation and enable the loop animation I had compiled, you can see this is the animation for running. That's it. Now, let's see how we can do that next Video. 10. 09 Get character speed: No, for deciding which animation to be played, we need to know about the velocity of our character. And how we can do that, we can do it in event graph. In event graph, we can get the begin play event by searching event begin play, right? And we can use this Try Get Pan owner. If you don't have it and it is deleted, just search for Try Get Pawn owner. That's it, right? It's easy. And we want to cast this to FPS, right? BPFPs so we can get the velocity off of it, right? For it to make it easy, I want to right click in here, promote it to a variable, and I want to call it BPFPs. That's it, and put it over here. Now, in the update animation, what I want to do I want to get this BPFPS. And first thing to do, I want to check if it is valid. It's really important to check if it is valid. And after checking if it is valid, we can get the velocity off of it. So get velocity. Just search for get loci It is down here. You can get it like this. With that, I want to get the length of it. Search for length, the vector length X and Y because with this, we want to change the walking to idle and running. It is on the ground, so that's why I use X and Y. Now, I can right click on it, promote it to a variable and I can cool it speed, right? With that done, let's just connect it like this. And I want to use a print testing in here to show it, right? Just connect it like this. Now, with that, I want to go back to anim graph and connect one of these animations to here. It doesn't matter which one, it's just for testing. Go back to event graph. We want to show the speed, right? So Runo game. Right now, the speed, you can see it is zero. If we had told you, the speed will be close to 250. And if we hold left shift on over keyboard, it will go to a value close to 600, right? Now, you can see, we are getting the velocity or speed of our character inside our animation blueprint. And based on that, we want to decide which animation to be played. 11. 10 Blend spaces: Now in our animation blueprint, we know what is the speed of our character, right? Based on that, we want to decide which animation to be played. For doing that, there is a couple of ways. One way is to do it with state machines, one way to do it with Blender spaces. I think Blender spaces looks much better. So for doing that, I want to go to content drawer and I want to go to FPS folder. And in here, right click Go to New Folder and create a new folder, and I want to call it animations, right? Oh, click on it to open it in here. Right click Go to animation, and in here, go down until you reach the blender space. Click on it. It will tell you for which one you want to create a blender space. Want to do it for S Mankin arms, right. On to call it BS for blend the spaces. Walk run. Okay. I'll click on it to open it. In here, as you can see, there is a asset detail and we have a graph in here. So in here, we can add some animation to this, right? For example, if I get the idol and put it wherever, you can see it will play the idle animation. And there is a horizontal axis and vertical axis as well. We can name them and use them. For example, the horizontal axis, I want to go here and change its name from non to speed. Okay? And based on the speed of our character that is 0-600, we want to decide which animation to be played. That's it, right? No, for example, this animation that is for idle at the speed zero, we want it to happen, right? So put it on zero, and this none, you can just put it on zero, as well. So if the speed is zero, it will play the idle animation. And let's just use walk now. Click on this walk. When do we want this walk to happen when the speed is 250? And this non, we can put it on zero as well. Now, how we can test it. If you hold control, you can see, I can change the speed and know when we reach 250, you can see it's plain the walk animation. And it's blend between them. You can see how beautiful it looks. Now we can add the sprint as well in here, for example, and click on it. And now we want to say this animation that is for sprinting or running. I want it to happen at speed 600, and we can put this to zero as well. No, if you hold control and test that out, if the SPD is zero, it will play the idle animation. And if the SPD is 250, it will play the walk animation, and if the sped is 600, it will play the run animation, and you can see it looks awesome, right? That's it. We want to use this plenda space. So make sure you save everything and know in our animation blueprint we can go to anim graph, instead of using the, we can use over BS Wakron because we did create a blender space for this skeleton. That's why the blender space will be added in here. We can just drag and drop it and connect it to OwoodPose. It needs a variable of the speed, we can just get it from the variables and connect it to here. Now, if you hit compile at default, it will be at idle animation. Now, if you go and run over game, you can see it is idle animation. If you walk, you can see it is playing the walk animation. And if you hold Shift, it will go to sprint animation or run animation, and you can see it looks good. And now, again, it will go back walk, and after that, if we stay, it will go to idle animation, right? We can do lots of things with this. You can see when I'm testing in here, when I'm changing the value, it takes a little bit time to do it. There is two cross in here, and one of them is far behind the next cross. You can see this is for blending them, right? How we can change that we can change this moving time. For example, let's just say point tree, right? And now if you hold control, you can see it will take more time to reach us to reach the main green cross. You can see it. No, we can change this moving type to, for example, es in and ease out. And know it will looks much better. Now with that done. Let me change this to 1 second. It's a lot. It will take 1 second to reach the main green cross, but you can see the difference with it. Let me run over game and know if you walk, you can see it will take a little bit time, 1 second to reach the walk animation. And if we try to run, it will take 1 second to start running, and you can see how beautiful it is blending between them. But this value of 1 second is too much. Let's just put point there. You can decide what you want to do in there, but point, I think it's more than enough. You can see. We can go to run and we can go back to walk and we can go back to idle. And I think that looks awesome. Now that we have done that, we can go to ABP FBS and go to Event graph and delete this printer ring because we don't need it anymore. 12. 11 Crosshair UI: No, it's time to add some UI. Let's see how we can do that. For doing that, I want to go to Content drawer in FS folder. I want to right click, create a new folder for all of our UI stuff, and I want to call it digits. So right click in here, go down until you reach user interface and go down and create a Widget blueprint, the type that you want to create is called user widget, so click on it and I want to call the WBP. I want to create the crosshair I'll click on it to open it and know in here first thing that I want to do, I want to go down and add a Canvas panel because for crosshair Canvas panel, it's easier to work with, right? No, next thing that I want to do. I want to create hair, cross hair with just borders. I don't want to use any image. So go up and drag and drop one border inside in here. First thing that I want to do, I want to change the anchor of it to be at the middle. You can see the anchor right now is at middle. And if you change the position X and position Y to zero, you can see it will put it at middle. But it will align it to top left corner, and we can change that alignment. In this alignment, we can say to align itself by the anchor point at middle. And how we can do that, we can put 0.5 and 0.5 for X and Y for alignment, so it will put it at middle. What this alignment mean this one is X zero. This one is X 0.5, and this one is X one. And again, this one is Y zero. This one is Y 0.5 and this one is Y one, right? Just remember that because we want to use it a lot. Now, for the size of it, I want to put it on five to five. Like this, I want this to be crosser, but I want to change it to make it better. Go to apprehenss, go to brushes, and in here, let's just change the tint color to something red. So green should be zero, blue should be zero, and that's it. No, this is our pros but just a square is not good. I want to make it round. So again, click on it, go to draws in here and change it to rounded box. That's it. That's beautiful. Now, let's see how we can use it. For using it, I want to go to BPFPS and in here on the begin play, I want to create that Widget blueprint. You can see I'm at Bigmplay and in here, I want to create that widget, create Widget. Just search for Create Widget. What widget you want to create is called WBPCrossaer. And after that, I want to right click on it, promote it to a variable, and I want to call it W BP, cross hair, right. And after that, I want to add it to viewport, add to viewport, so we can see it right in our game. That's it. Now, with that, if you run over game, you can see the red dot is there. That looks awesome, and it's working fine. Beautiful. But I want to add more things to it. Let's see, we can do that next. 13. 12 Crosshair wings: Next thing, I want to make this cross hair a little bit better. For doing that, I want to go to WBP crosshair in here, and again, I want to use a border, right? With this border, by default, it will put it at top here. I want to click on it and change the anchor point to the middle again and change the position X and position Y to zero to be at middle. Now, what I want to do, I want to change the size. For example, size Y. I want it to be five and size X. Let's just stick with 20. I think that's good. No, I want it to be round, as well. So draws, I want to change it to rounded box. That looks much better, right? And I want to align it with the middle of the Y, like this. This point that we have in here, this point in here. So click on it and change the alignment for the Y 2.5. That's it. No, we can position it a little bit better. For example, ten unit to right. That's it. No, this is over crosser, but I want to duplicate this with selecting it, Control D, to duplicating it. And first thing first, I want to change the position position Y to zero because I want to put this wing, other wing that we copy and paste to the left side of it exactly like this, but mirror on that side. That's why I want to change the alignment in x direction to one, so it will go to that part, right? And for the position X, I want to change it to minus ten. So from this point to this point is ten, and from this point to this point is minus ten. That's it. Or cross hair is ready. I think that looks beautiful. No, let's just run over game. You can see or cross it. That looks beautiful. Now, what I want to change, I want to select both of these and go to tint color and change the alpha of it, 2.6, for example. I think this way, it looks much better. If you run over game, no, you can see. I think it looks beautiful. No, one thing that I want to change in here, you can see, if you look at the positioning of our crosser is that it's a little bit up. If we shoot, it doesn't look good because our weapon is looking a little bit down. So that's why I want to select all of these three borders, so hold control, select three of them, and change the offset to type by 50, right? So it go down a little bit. And now if you run over game, no, you can see it's more aligned. That's beautiful. No, our crosser is finished. 14. 13 Aiming: Know that we have a crosshair, what I want to do, I want to be able to aim, both with crosshair and with the scope of over gun. So for doing that, let me first save this. We don't need it. Save this, close it. We don't need this. For aiming, we need a input as well. So go to a fist folder, go to input right click in here, go to input and create input action, and I want to call it I aim, right? D click on it, open it. The digital boolean is more than enough. You can just close it. Go to Input Mapping context, create a new mapping. Let me hold Shift click in here and click again. It will bring it up in collapsed way because it's a mess. Click in here, we want to map the aim, right. And after that, click in here and hit rightmost button. With rightmost button, we want to be able to aim, right? Go to BPFPs now in here, find a part in here and right click search for IA Aim. And with that done, whenever we press rightmost button, this started will happen. And whenever we release rightmost button, this complete will happen. And what I want to do with those, I want to create a variable and I want to call it is aiming, right? And I want to set them over here. Whenever we press right most button, we want to say we are aiming. And whenever we release right most button, so contribute to paste this, we want to make these false. And next thing that I want to do whenever we are aiming with rightmost bottom, we want to use the scope, right? So for that, we don't need the cross hair anymore. So I will get the crosshair like this, and I will drag and drop and set the visibility on it. Search for set visibility. And if we are aiming, we want to set the visibility of the main crosshair to non to headen right? Control C control, we paste it over here. And whenever we release rightmost bottom, we make it visible. Now with that no if you had compile and run over game, you can see if I hit rightmost button, the widget will go away, and whenever we release right most button, the widget will be there, right? The crosshas going away. Now, how we want to use the scope. For doing that, there is a scope, a static mesh that you can use. Right now, if you look at this, you can see there is no scope there. How we can add the scope static mesh to Ogon, we can just click on Ogon because Ogon is a skeletal mesh. It has some bones. We can connect things to it, right? So in here, add a estaticmsh, search for static mesh, and add the estatic mesh. I want to call this one scope, right. And the static mesh that you want to use is called scope, but you can see it well put it over here. That's why we want to put it on a socket or on a bone. So clicking here, there is a scope socket there, a scope socket, right? If you put it there, no, you can see the scope will be there and we can use it, right? That looks really awesome. But how we want to change the position of Ogun or camera so it will go to the scope to look at the scope, how we can do that. For doing that, there is animation. Let me show it to you. If you go to Assets, go to arms, animation, right? We have arms. Aim up, right? That fit it will go there. You can see it. It will bring it in front of the camera. That looks really awesome. We can use that, right? But how we can use that we should use animation blueprint for it. And now it's time to show you how you can use this animation that is arms A up. So we can look at the scope with estate machines. Let's see how we can do that next. 15. 14 Start aiming: Know inside our animation blueprint, we want to use that arms up animation to bring the scope in front of the camera. For doing that, first, we need to know in our animation blueprint if you are aiming or not. So go to event graph, and in here, we get the velocity, we can get is aiming as well. So search for Get I aiming and we can just promote it to a variable, right? Just put it over here and know we have access to Is aiming inside our Anmissionblueprint. Now go to anim graph. We don't want to do things like this. I can just cut these, right? You can see if we will go to Apos again. No, I want to add a estate machine, right? Add estate machine, and I want to call it locomotion, right. And with that, I want to connect these two here. With this estate machine, we can decide at any time what animation to be played, right? By creating some estates. So add the estate in here, and I want to call it walk, run, idle. So all of them will be in here, right? And let's just go inside and control we to paste that blender space that we cut and connected like this to here. By default, when we run over game, the first estate that is connected to entry will be running always, right? So just with that, you can see everything should works like before. The walking should works, the running should works. Everything should works, right? Like before. We did not change anything. But with this state machine, we can decide some more estates. So for example, let's just add another este. I want to call it start aiming. Right? And with this start aiming inside it, we want to play the arms up. So go to Asset Browser in here and find the Aims up, not arms up. So grab these aims up and connect it to here like this. Now, the important thing, the loop animation for this one shouldn't be on at all, right? Just with that there is a rule. With this rule, we should decide when to go to a start aiming. So, for example, let's just go inside it. We can use is aiming in here. So if you are aiming, you should go to a start aiming, right? You can hover over it. It says, If you are aiming, you should go to a star aiming, right? No, let's just compile, run. Now with that. If I hold right most button, you can see it did play that animation, right? But right now, the positioning of our camera, the arms is not good, so we need to fix that, right? So for fixing that, we need to click on arms and do it with this. The values that I came up with is Z four -168.27, right? You can just play with these values. And for the Y, I want to put 1.4, and let's just test with that, make sure you save and compile. Now, if you hold right most button, no, you can see it's working fine. But it won't go back, right? It will happen just once. We will fix that. But you can see this is how it's supposed to be. O game, this is how it's supposed to be. Now, if you hold rightmost button, you can see, we can see through D or crosshair. Next thing that I see in here, if I hold rightmost button, you can see the red dot is not at the good position, right? One way to fix it is to go to a scope and change the positioning of it, for example, bring it to the right a little bit, like 0.1, right? A little bit. No, let's just run. And now you can see it is at middle exactly. That looks awesome and beautiful. But we are going at aiming, but we are not going back. Let's see how we can fix that. 16. 15 Aiming animations: No, we are playing the start aiming and it will start and put it in the right position. But when we release the right most bottom, it won't go back, and that is a problem. For fixing that, go to ABP FBS. And in here, after the start aiming finished, we want to create another state, and I want to call it aiming. So with it, it should have some aiming idle aiming walking that you can see over here. Arms aim idle. If I doubt click on it, you can see it. Arms aim idle, arms aim walking. You can see we have some animation for those, right? But when this aiming should happen, we can just tell this rule whenever this animation that we decide in start aiming get to be finished automatically go to Amin, right? So in here, we can just click on it and choose automatic rule based on sequence player, right? So check that. I will automatically go to Amin. And inside aiming for no, let's just use arms aim idle. Just put it there. This time, it should be on loop. Don't forget to put it on loop. No, let's just head compile. Go back. And for you to see it better, I want to run over game, make this small like this. And with that, let's just click in here and choose the instance so you can see which estate is playing. And with that done. Now, if I hold right most button, you can see it did go to Amin estate, right? First, it will play the start Amin, and after that, it will go to Amin state. Just look at it one more time. You can see it will automatically go there. But the next thing that you want to do, whenever we release right Most button, we want to go back to walk run idle, everything, right? So again, we can just connect from here to here. It will give us rule. And indeed, we can just check I aiming, right? We check I aiming was not true. So search for Not bullion. If we are not aiming, you can go from aim aiming to walk run and idle, right? Just with that, I want you to see everything. So let me make this smaller and run over game. No, you can see everything. If I hold rightmost button, you can see it will go to Amin until I'm holding the rightmost button, it will stay at the Amin and when I release it, you can see it will again go back to walk run idle. You can see that looks awesome. But one problem that we have in here is that first, when we are walking and aiming, it should play another animation. But right now, it's playing the aiming idol, right? And when we are aiming and hold shift, we are sprinting. So again, we need to play another animation. We shouldn't be able to aim when we are sprinting, right? We will fix all of those and next 17. 16 Aim walking: No we are aiming and we start aiming everything. But when we are walking, we are not playing the aim walk. And when we are running, we are not canceling the aiming. Let's see how we can fix that. First thing, first, whenever we are aiming and we are walking, we want play different animation because we have different animation arms Aim idle and arms aim walk. And how I want to use it, I want to use blended spaces. So go to FPS folder, go to animations and right click in here, go to animation and create a blend space for our c manikin skeleton. I want to call it BS aiming, right? That's it. D'll click on it to open it. No, based on the speed of or character, we want to decide which animation to be played, right? So for doing that, I want to use the horizontal value. So in horizontal value, I want to call it speed again, right? And as you know, because we have AM idle and aim walk and the walk is 250. So this value minimum XOs value, I want to put it on zero, and maximum value of the speed, I want to put it on 250, right? So you can see zero to 250. No, I want to grab these arms aimidl put that over here, click on it, and I want to say whenever the speed is zero, this animation, we want it to happen. Arms and idle, right? We can put zero for none in here as well. But when we are walking, so dragon drop these arms and walk, click in here. When do we want these arms and walk to happen whenever the speed is 250, right? And we can put this none to zero. Now, if the speed is zero, it will play the arms aim idle. But if the speed is 250, it will play arms AM walk and it will blend between them really good. Make sure you save. Go to ABP FBS in aiming state in here. Instead of just using this, I want to use BS aiming right dragon drop put it over here, and this need the speed as well. So connect the speed to it. That's it. Headcmple. Now, if you run over game, let's see what will happen. If I make this bigger, if we are at idle and speed is zero, you can see it is playing the idle aiming, right? But if we walk, you can see, No, it's playing the walk aiming, and that looks awesome. If you release rightmost bottom, you can see it's working fine. And if we go to Amin, you can see it is working fine, as well. That looks awesome, right? But the problem right now is that if I hold shift when we are aiming and walking, let's see what will happen. You can see. Again, it's aiming and playing the aim walking animation. We don't want that to happen. So how we can fix that. We want to check the speed. If the speed is more than 250, it should exit the aiming, right? So again, I want to drag and draw from this aimingtd to walk run idle. Create another rule from aiming to walk and run. And with that, I want to check the speed. If the speed is greater than, for example, 255 like this or 250, it means it should go from aiming to walk, run idle, right? Just with that, if you had compile, run. When we are aiming, go forward, you can see the animation is good. If we hold shift, you can see the problem. I try to go to running, but again, it will go back to aiming again. What is happening. Let me go to stack machine, put it over here, and run over again. Make it a small like this and choose or instance so you can see it better and know in here. You can see it's going to aiming When you are walking, again, it's aiming. But if I hold shift, you can see it will go to walk around idle and after that, it will go to start aiming again, right? B is aiming cause it to go to start aiming. So inside in here, we want to check two things. If the speed is less than 250 or 255, and the e aiming is true, it can go from walk run idle to start aiming. So we need to check the speed for a start aiming, right? So for that, I will get the speed and check if it is less than, for example, 255. And I want to check both of these, so I can check it with and Boolean. This Boolean, what it does, it will check both of these. And if both of these are true, it will go from walk on idle to start aiming, right? No, let's just compile, run over game, and in here, go to Locomotion, so you can see it in here as well. No, if I aim, you can see it will go to start aiming and aiming. After that. If we walk again, it will stay at aiming. But if you hold shift, you can see, no, it's going to walk run and idle. And if I release shift, it will go to start aiming and after that, to aiming and loop, right? Again, you can see how beautiful it looks. Now, next thing that I want to do, I want to go here and change this moving time 2.3, for example, so it looks much better. And this moving type I want to put it easing is out. That's it. I think this way it looks much better. No, let's just run over game again. No, in here, we are in walkun idle. We are in walking right now. We are in aim walking. And after that, we are in sprinting, right? You can see everything is working fine. That looks beautiful. 18. 17 Anim montages: No, the next thing that you want to do, we want to be able to fire or weapon, but it will take a little bit time and some videos to do that completely. So for doing that, first, we need an input. Whenever we hit leftmost button on or keyboard, we should be firing our weapon, right? Go to FPS folder, go to input, right click in here, go to input, go to input action and call it IAFre, right? You don't need to change anything in here. You can just close it, go to IMC FPS, to map it there. Again, you can hold Shift click in here and release shift and click in here, you can see it will open it normally. But if we add a new mapping, again, it is a mess in here right now. We want to map the IAFre, choose IAFre after that expand this click in here had leftmost button, and it will automatically put the leftmost button there. That's it. Make sure you save. Go to BPFPS, go to event graph. No, we want to be able to fire over a weapon. I want to go down in here, search for IA Fire, right? And with that, whenever we press leftmost button, this started to happen, and we want to fire our weapon, right? But before doing that, you want to check with a branch if you are aiming or not. So connect aiming to it. No, first thing that you want to do in here is to play animation, but how we can do it. We can do it in lots of ways, but I want to show you animation montages. Let's see how we can use them. Go to Content drawer, go to Assets, arms animations. And in here, we have some animation. For example, arms AM fire and arms fire. Okay? So select both of these, right click on one of them, go to create and create anintage off of these animations. Now, with that done, I want to drag and draw both of these in animations inside a fierce folder, move it there. No, let's just go to animations. You can see the animation montages. There. First, we want to do the arms fire, not the arms aim fire, arms fire, right? No, you can see this is animation montage that we can play it whenever we want. But animation montages needs a slot to be played there. So each animation montage can have a slot. By default, it is default slot, and that's more than enough for us. And we can decide where this slot should be inside our animation blueprint, right? So we can play this animation there. So go to Animation Blueprint, go to Anmgraph. And after this commotion, I want to search for default slot, right? This default slot will be between Ot Wood pose and our state machine, and with that, we can play our animation montage. There. So it will be added to all the animations that we have in here, right? Now, let's just compile, safe, go to our FPS. And in here, if you are not aiming, we can just play montage, right? Just play montage. And in here, first thing first, it needs a skeletal mesh to play animation on, so we can get our arms, put it here, right. Next, it needs montage to play. So clicking here, we want to use arms fire Montage, and that's it. Let's just head compile and run over game. And make this bigger. Now, if you are not aiming and hit leftmost bottom, you can see it. We can play the fire animation. You can see it. It's not too much, but it's working fine. You can see, cool. No, for the when we are aiming, again, we want to do the same so Control C, Control V to paste it in here in case of true, we are aiming. We want to play the AM fire montage, right? Let's just open that in here, AM fire montage. Again, this AM fire montage is using defaulted slot, right? So we can just use this defaulted slot for everything, right? That's more than enough. So no, in here, let's just test that out. If you run and go to aiming at lift most button, no, you can see that is working fine as well. So no, we are plain animation for firing over a weapon. And it looks, I think, awesome for both of them. It is working fine. 19. 18 Muzzle flash: No, we are firing a weapon and we are playing some animation for it. But no, I want to do more. For example, let's see, we want to see where we are heading, right? We want to have some visual effects. We want to have some sound. We want to have, for example, Amo manager because it shouldn't be infinite, right? So for doing that, I want to create a function so it will be reusable so we can use it wherever we want. So for doing that, I want to create a function, and I want to call it weapon fire, right? That's it. Now, inside this weapon fire, first thing that I want to do I want to play animation for Ogun itself, because Ogun itself have some animation. Let me show it to you. We go to FPS folder, go to Asset, go to gun and in the gun animation, you can see there is two animation in here. One is for gunfire and one for gun reload. Let's just double click on one of them. And you can see we have gun fire. Nothing is happening to it. Let me zoom. If you just zoom in here, you can see, there are some animation in here when we fire this one. It's just go back and just like that. We want to play this animation. So for doing that, in here, we can get our gun. We don't need animation blueprint for this kind of animations. We can just say play animation, right? Of course, you can just use animation blueprint for gun as well and add a slots there and have play animntage. But it's overkill. We can just do it like this. Play animation of gunfire. Let's just go down and choose gunfire for it, right? Now, with that, let's just see how we can use it. We want to use it on both of these. Even if we are aiming or not, we want to use this weapon fire. Function. So let's just connect this to here and use this function over here as well. So you can see it is reusable. We can do at once and use it for multiple places, right? Now with that done, nothing is changed. But if we run over game, you can see we are shooting. We can't see nothing different there, but it actually play animation. And you may say, we are not showing anything with this animation. Why we are using it? We are using it for some reason. If you go to gunfire animation, you can see in here, whenever we shoot, we want to add a sound. One way to do it, we can just go here and play a sound in here. But it's really easier to play a sound inside the animation sequence. We can tell it in which frame the sound should happen. In each frame, this bullet shell should go out, right? We can do all of that in just here, and it will be perfect. So in here, first thing that I want to I want to add a Naga system. So right click in here, add the Notify and go and put play Naga particle system. I want it to happen at the beginning over here, and the Naga system that you want to play, it's called NS weapon fire muzzle flash Rifle, right? Just put it there. Now, if you play it, let's see what will happen. You can see it's happening in here at 00 location, for example. We can change that by putting a socket named there. So for finding the socket, we can just click in here to go to a skeleton of over weapon. And in here, we need to play this muzzle flash Naugur system at tip of or gun. And there is a socket for it that is called muzzle. You can see it is a tip of Ogun. Just like this, we can just copy this controversy to copy it and put it in bone name in here. Now, with that, if we had Enter, it will put it there. And whenever we play this, you can see it will happen at tip over gun. Now with that done, let's just run over game and shoot. You can see, no, it's playing it, right? And we can go to Amin again. In that case, it's happening as well. That looks awesome, right? Next thing, I want to give you this as a challenge at an graphic for shell ejection, right? You try to do that. We will do it next. 20. 19 Firing sound and shell eject: Next thing that you want to do, we want to have shell ejection. For doing that, it's like before. In here, whenever this animation reach this point, for example, when the shell can eject, we can just right click in here, add a notified this time, play Naga particle effect as well, and click on it, and in here, choose the NS weapon fire shell eject. Choose that. Now for the bone name, again, we can go to a skeleton and you can see there is a shell eject in here that is at the right position. So we can use that. In here, we can just search for shell eject. Now with that done. You can see there is a shell ejection, but it's happening really fast, right? So, with that, let's just save go to our level and run over game and know if you shoot, you can see it, but in this AMS stae you can see it better. It's happening really fast, but it is there. That's more than enough. No, next thing that we want to do, we want to play some sound. So again, in gunfire, at the beginning, we want to add another notifier for playing a sound. So even here, we can right click and say play sound. But you can see, I want to put it at the beginning. Let me make this bigger. I want to put it at the beginning in here, but we already have something. So we can add another track. This is track one. We can just click in here. Add another track, a track to do that, right? At the beginning, we want to play a sound. So choose play sound. Put it at the beginning. Now, for the sound, clicking here, we want to play this assault rifle first. Just use that, right? Now, if we save, go to our game. You can see I can shoot, and now we have some sound as well. That looks really awesome. And we have Shell ejects W. No, our game is taking 21. 20 Line trace when we are aiming: Next thing that we want to do we want to see where our gun is looking at. If we fire over a weapon, where it should have an impact, right? So for doing that, we need a line trace, right? So I don't want to do it in here because it will mess up everything. The line trace needs lots of things. So that's why I want to create another function just for line trace. And in here, I can just create the function. I want to call it fire line trace, right? And with it, first and first, we have two estates for checking the where organ is looking at. Let me show it to you. If we are not aiming, it means we should shoot at where or cross hair is looking at, right? So if you are not aiming is different from when we are aiming. When we are aiming, we should shoot at where a scope is looking at, right? So first, let's just do it with a scope. So in here, first thing that you want to check, we want to check if you are aiming or not. So use a branch and check if you are aiming or not. With it, if it is true, it means we are aiming. So in this case, I want to use a line trace by channel, right? I need a start and end location. So let's just provide. For the start location, I can get the scope just like this. And inside this scope, there is a socket, as well. So let me show it to you. Click on A Scope and open up this scope, astatic Mish. I'll click on it to open it. And in here, you can see, there is a Socket there. Of course, it's too hard to zoom on it. I'm decreasing the camera speed with holding right most button with middle most. I can do that. Now this socket. If you don't have it, of course, you have it. You can just click in here and create another socket and you can position them, right? Position it. You can see by default it is there. We can just bring it up, put it at middle. For the size, I can just put 0.1 there for all of them, 0.1 for this one, and 0.1 for this one. This way is much easier to position it, right? Position it exactly at this red dot, right? Just like this. We can just delete this last scope. We want to create our own scope. This socket came with the acid. That's why it is there. Let's just put it there. And let me see if it's perfect. It's a little bit hard to position it. That's why they added their self, but I wanted to show you how you can add socket. And that's it. I think that looks good. This is where we dot is. Now with this socket, we can get its position. So we need the name of it, right? With that, we can go here from this scope, I can get this soccet location like this. And the socket location that you want to get is called socket, as well, right? We did name it socket in here, so that's it. Now, this is our start location. No, we want to get the end location, but for the end location, our socket needs to face at the right location, right? So for doing that, go back to a scope and we want to rotate it until the X direction is the forward vector, right? So let's just head E to rotate it like this. 90 degree first to see what will happen head W. No, you can see the X is facing the right direction. If we go to blueprint and in here, you look at it, you can see it's facing this way. The X should face this way. So when we get the forward vector of it, it's at the right direction. That's it about or socket. Or socket. No, it's perfect. Now, let's just go here, go to fire line trace function. We are getting the start location, but we need to get the end location as well. For the end location, I want to get the socket rotation first, and the socket that you want to get its rotation is called socket as well, right? And with it, we can get the forward vector off of it. And after getting the forward vector, because the forward vector is a length of one. It's not too much. It won't go a lot in front of us. So that's why I want to multiply it by really big value. All of X, Y, and Z should be multiplied by really big value, so I can just either put a big value in each one of them, but I want to right click in here, change this to a float, and I should put really big value there, right that's it. No, we need to add the start location to it, right, because we want this to start from the start location to forward, right? So, that's it. This is our end location. And for you to see it for draw to type, I want to change it for duration and no, let's just head compile. We have our function. Let's just use it. In here, I want to get over find line trace in here and connect it like this. Now, if we had compile and run over game, if we shoot like this, nothing happened because we did create or line trace just for when we are aiming. But when we aim, just look at it. Cool, can see there is a line from the scope to where we are looking at. You can see if I shoot over here, you can see, it's good, but it's a little bit up. If you want it to be pitch perfect, you can go to a scope and rotate it in wide direction a little bit, like minus five degree, right? So it will look down a little bit. Now, if you run over game, it's about the rotation of over gun and the scope and all of that, right? So let's shoot. No, you can see it's pitch perfect. Of course, the way that it was was okay, right? Let me shoot over here, for example. No, you can see everything looks awesome. So we did just rotate it a little bit down, so it will face the right dot, right? And that's it. Now, we have a fur line trace whenever we are aiming. We want to do the same whenever we are not aiming. Let's see what we can do that next 22. 21 Line trace for not aiming state: No, we want to create the line trace for when we are not aiming. Let's see how we can do that. For doing that, I want to go to fire line trace function in here. In case of faults, when we are not aiming, I want to use another line trace by channel, right, like before, I need a start and end point. What is the start and end point? The start point, I want it to be exactly at this middle of the screen where cross hair is. It's not exactly at middle. We bring it down a little bit. We will consider that as well, but this is the start point. And for the end location, we can just use the direction that this dot is aiming at, right? Let me show you how you can do that. First, we need to find the middle of the screen. How we can do that, we can get the viewport size, right? With this get viewport size, if you right click on it, split a strike pin, it will give us the X and Y of the size of our monitor or a screen or viewport, right? No, because we wanted the middle of it. We can divide X by two, and it will give us the middle of it, and we need to do the same for the Y as well. So divide it by two like and because in white direction, we did go a little with down, we can add to this a little bit, like, let's just say 35, we'll test with that. And with these values, we will find that red dot, right? So now, we want to convert this to a art position because this is a screen position. There is a node for that. It's called D project screen to art. And if I right click in here and split the strike pin needs a X and Y. So this is the Y, this is the X. Next, it needs the player controller. So get the player controller like this. That's it. Now we have the start location, and it will give us the word direction of it as well. Make some space. This word direction is exactly like forward vector of that middle of the screen, right? So because the direction is length of one, that's why we want to multiply it by really big value. So let's just change this to float and multiply it by really big value like this. And after that, we want to add the start position to it, as well, and that's it. This is our end location. And for you to see it, I want to change this draw debo type to duration. That's it. Now, if you run over game and in here shoot, you can see, again, it's a little bit up. So we need to add more to this. 50, for example, right? Now, if you run over game and shoot, now you can see it's perfect. Why we should use 50? If we go to Widget Blueprint, let me show it to you FPS, widget and go to Widget Blueprint. In here, if we select all of these, doesn't matter which one you can see the offset to top, we use 50. That's why we should add 50 to that, right? You can say, No, it's perfect perfect, right? No, we have line traces when we are not aiming 23. 22 Return results: Next thing that you want to do. We want to check with these line traces. If we did hit anything, return the result. Let's see how we can do that. First thing, let's start with this one. In here, first of all, there is a return value, and with that, we can check it with a branch. So if it is true, it means we did hit something, right? So in this case, we can return whatever value that you want. Add a return note we want to return some Ohad result, right? One way is to just click on output, name them, and all of that. But the best way and fastest way is to grab this, break the head result, and in here, expand this and get whatever that is necessary we need, right? So first thing that we need, we need the impact point. So let's just drag and drop, put it there, and it will put it as output for us and name it for us, right? That's beautiful. Next thing, we need the impact normal, as well. So dragon drop put it there as well. Next, we need the head actor, dragon drop. Beautiful. Next, it bone name, right? Drag and drop, put it there, and that's it. That's all we need to return so we can, for example, add some visual effects, right? So, no, we are returning some useful information from this function and we can use them, right? But what if didn't hit anything? What we should return, right? When we are not hitting anything, we don't have impact normal impact point, heat actor, had bone name. We don't have it because we didn't hit anything. So I will pass this tree empty, but the impact point, I will pass the trace end, the end location, right? So we have something to shoot at or impact point or end location, right? And no, with all of these control C Control V to paste it over here and connect them. You don't need to do it from scratch. So connect this to here, connect this to here, and it should work. That's it. Now, we are returning the useful information. And with this information, first, we will be really organized, and we can do lots of things with this. Now, let's just see how we can use these results. So we add some Nagra visual effects. 24. 23 Fire tracer VFX: First no graphic that I want to add is called fair tracer, and we want to do it with all of these value. We want to do some of visual effects. So in here, it's better to add a sequence node. So with this sequence node, we can one by one, play some visual effect, right? And for playing this Nagra visual fix, I want to create another function, so it will be easier to work with. First thing. Let's just create a function. I want to call it fire tracer, VFX, right? And where I want to use it, let me go to web and fire and then zero, right? Fire tracer Vax and connect it like this. Now with that now, let's just go inside it. I want to spawn system, span system, the inaugural system attached, why attached because we want to attach it at tip of or gun, right? So first first, we need to choose fire tracer. So search for trace weapon fire tracer, put it there. What we want to attach it to, we want to attach it to our gun. So connect the gun there. The attached point name, we wanted the tip of or gun. So let me find the gun skeleton. We have muzzle. So we can use that, right? So headf two on it, so you can rename it, Control C to copy the name and paste it over here. That's it. No, nothing will happen because there are some user pometers inside this Niagara system that we wanted to change them. So let's just click on this magnifier glass, open up this one, this visual effects, and know in here, let me first show it to you. If I had it, nothing is there because the user prometer that we want to sit is not set, right? So we need to update the impact position. So this name is really important. And now with that, let's just go back to here. And in here with this Naga effect, we want to sit where is the end of this fire tracer, right? So we should say Nagara set vector array. Why set vector array? Again, if I go here, you can see this is a Niagara data interface, array, flow tree. Flow tree Niagara is like a vector or blueprint. So remember that in here, it need a array, but because we are just hitting one place at each time, we can just make a array with just one input. And what is that input? It is impact point. So this function needs the impact point as its input. Click in here, and the type, as you know, it should be vector, and I want to call it impact point, right? And we can use that impact point in here, grab and search for impact point. I get it from the input in here. We could just drag and drop connected like this, but this way, it's much cleaner, right? Just put it over here. The name of overwrite name is really important. So it's really important to copy exact name in here. So we can right click on it, head rename and Croce to copy it. And in here, we need to paste it, right? But just with this, it won't work. If you go here, you can see the variable that we have in here, the vector array variable that we have in here is in user space. That's why we should add this user as well. So in here, we need to add that user user dot impact positions, right? So with that, we are adding the impact position with or impact point, right? That's it. No, we should go to weapon fire and pass the impact point to the impact point, right? So pass it just like this head compile. No, I want to go to fire line tracer and disable this draw debuc type to none because we don't need it anymore. In here as well, change the draw debuc type to none, no we can test it. If you run over game, let's just see. If you see it, that meets us we have a fire line trace, right? Doesn't matter which one we use, we have it, right? So cool. No, we add a visual effects for when we are firing or weapon. Next thing, we want to have impact, as well. Let's see how we can do that. Next. 25. 24 Fire Impact VFX: No, another visual effects that I want to add is for impacting the ground, right? So let's see how we can do that. Like it did for fire tracer VFX, we need to create function for this one as well. Impact or fire impact, VFX, right? This is our function. And inside this function, we want to use a spa system at location, right? That's more than enough. The system that you want to use it's called NS Impact concrete, right? Just use that. Now for the location rotation scale, you don't need to worry about it. I I just click on it and open it up in here. Let's just look at it. It did compile. You can see it how it looked like. If you go to user prometer, you can see it need impact normal and impact position, right? So we need to provide that with these values, right? Again, impact normal is a array, vector flow tree. And impact positions, again, a array, this time position. Position again, it's like a vector, right? So now, let's just go and set them. In here, we don't need to set location rotation and a scale. These are offset at this point because the location that we have in here is much more important, right? So first thing that you want to do in here, we say Naga set position array, right? Just like that. We call it position array, but it's exactly like setting a vector. If we make that because we are hitting one thing at a time, right, you can see it is just a vector. They just call it position at this point. So you will learn both of them. So we need the impact point for this position, right? So at the input, we can create an input, and I want to call it impact point, right? And we can use it over here. Search for impact. Point. No. The name of it is really important. So let's just go here the name for the position, right click on it, head rename, control C, copy it. And in here, let me zoom. We want to say user dot with this name, right? Impact position. Now, with that t, next thing that you want to set is the impact normals. So let's just do that now. We can grab this. This time, you should say Niagara set Vctor Ay, right? And it needs execution pin. This time, we want to update the normals. So let's just go here, right click on this one, rename it, controversy to copy it. And in here, we want to say user dot impact normals. That's it. For the passing the normals, again, it need array. So let's just make a array. And at the input, we need the impact normal as well. So create a input. I want to call it Impact normal, right? And we can just use it over here. So in here, search for Impact. Normal. That's it. I think everything is finished. I should work, but we should go to weapon fire and use that function. Fire, impact VFX, connect this, then one to it. I need impact point. So let's give it the impact point, and it need the impact normal. So let's give it the impact normal as well. And that's it. Now, let's just head compile and run. If you shoot, you can see it. It's plain or no graphics for heating something and it should happen for both of them. When we are aiming, you can see it but it is there. See? That looks awesome. That looks beautiful. 26. 25 Gun burst mode: Know that we can shoot over weapon, it's time to have a burst mode as well. So we can shoot after each other. We have a rate of fire, right? So if you hold leftmost bottom, we want to shoot again and again and again, right? So for doing that, I want to go back to event graph. And whenever we shoot over weapon, doesn't matter in which one, if we hold it for 0.1 second, for example, we want to be able to shoot over and over again. So in here, I want to use a timer. So in here, search for set timer, by event, it's easier to work with this one. First, this time, I wanted to be on loop. So I want it to happen every like 0.17 second, right? So every 17 second, this event will happen and we can create a custom event for it. So search for Custom event and this one because it's for when we are aiming, I will call this custom event because it is different than when we are not aiming. I want to call it fire when aiming, right? That's it. No, this event will happen every 0.17 seconds, right? And with that, we want to play these two. First, play animntage and after that, weapon, fire, right? Like always. Control C control we paste it over here and connect it like this. As you know, when the animation for foreign or weapon for aiming and not aiming is different. That's why I name this differently. Next, we want to do the same for when we are not aiming. We need more space. So let me grab this, bring it up. Now, in this one, again, I want to set a timer, as well. Set timer by event again. And again, in this one, I want to happen to every 0.17 second, and I want it to be in loop. So with that, this event will happen every 0.17 seconds, right? So create custom event for and I want to call this one firing when not aiming, right? Or whatever you want to call it, it should be just different with this one, right? And this will happen every 0.17 seconds, right? And each one of them, we want to play these two function as well. Play anemontage and after that, weapon fire. Now, let's just run over game to see if there is a problem. In here, if I hold left move, no we are firing. But if we release leftmost button, it won't stop firing. Let's see how we can fix that. So if we release leftmost button, what will happen this complete of the fire will happen. This will happen, and we want to cancel the timer. So let's see how we can do that. For us to be able to cancel the timer, we should save this timer inside a variable. So right clicking here, promote to a variable, and I want to call it firing. R, right? And I want to use the same variable for this timer as well. So controversy Control V to paste it over here. This is the same variable, right? I don't want to create a lot of variable in here. And whenever we release the leftmost button, what do you want to do? We want to get this firing timer and clear it, right? So it won't happen anymore. So we say clear and invalidate timer by handle whenever it is complete. Now with that done, let's just head compile and run over game. No if I shoot. Whenever I release it, you can see it won't be able to shoot. That's it. C, right? No, let's just test it when we are aiming. That is working perfectly fine. 27. 26 Print string tip: No, next thing that we want to do, we want to have a Ammo system. So we shouldn't be able to shoot in infinitely, right? So for doing that, I want to go to BPFPS and in here, I want to create a variable of type of integer, right? And the name of it, I want to call it ammo and next, I want to create another variable for storage. Ammo, right? Let's say the storage ammo, give it a default value. For example, 50, right? And the Ammo itself, let's just say we have ten of them, right? That's it. On a showT. The best way to show it is with a printer string on eventq. So let's just find the eventq. How I want to do it, it's a good practice to do the debugs like this. After that, we will create UI for it. So in here, I want to use a printer string, right. And with that, I want to use a format text, right. So with this format text, we can combine some texts together. O I can say, for example, open and close curly braces. And in there, I want to say ammo, right? And after that, I will add some text of, for example, another curly braces. I want to call this one storage, ammo or whatever you want to call it. If you head in there, you can see there will be two pin in here that if we connect the ammo to the ammo in here and storage ammo to this one. Of course, I didn't write this name correctly. A storage ammo to a storage ammo in here. What this node will do, it will replace these curly braces that is inside that ammo with this actual ammo variable, and it will replace the storage ammo curly braces with this storage ammo variable in here, right? The name of this and this doesn't need to be the same thing. No, with that done, we need to expand the print esting and give it a key. Doesn't matter what key you put in there, we want it to be persistence. So if we add the key, it will be persistence, right? Head compile and no runo game. No, you can see at top left corner, it says ten of 15 because we have ten ammo of 15 storage ammo, right? So let's say, for example, we decrease that ammo Just for example, here, when we head fire, we want to get our ammo right, and we want to decrease one from it. So we can use decrement int, right? What this node will do, it will decrease the ammo by one. That's it. And it will save it inside the ammo, as well. This is a fast way to do it. Now, if you run over game, you can see I can shoot, and it will be nine, eight, six, three, two, one. And you can see it can go to minus values. But we don't want to do the ammo manager like this. Delete this, you don't need it. We'll create a function for managing the ammo. Let's see how we can do that next 28. 27 Ammo manager: No, I want to create a function for decreasing ammo. So for doing that, let's just create a function and I want to call it decrease ammo, right? And inside it, each time that we call this function, we want to decrease the ammo just by one, like we did it before, right? So in here, first, we want to check if we have a ammo if the ammo was bigger than zero, we want to check it with a branch, so it won't go less than zero, right? It shouldn't be like that, right? So if it is more than zero, we want to get the ammo and decrease one from it, and how we can do it with minus minus decrement int, I will decrease it by one and it will save it inside itself. That's it. Compiles save. No, where do we want it to happen whenever the weapon fire. So in here, what do you want to do before doing anything, right, we want to use this decrease ammo function. And because we create a weapon fire, it's really easy to add this to everywhere, right? By just adding it in here because weapon fire is everywhere. Now, if you run over game, you can see it is ten and we can shoot. I go to zero after zero, it won't go minus, but again, we can shoot. Let's see how we can fix that now. If we go to a bent graph, at the beginning of this I fire, what we want to do we want to check if we have ammo after that, go and fire the weapon, right? So we need some space, make some space like this. I want to use a branch in here. So branch. And with this branch, we want to check if we have ammo. So get the ammo, and if the amount of ammo was bigger than zero, in that case, we can shoot. Now, let's just compile, run. Now, if you shoot you can see, we can't shoot anymore, but we have another problem. In here, if we shoot and don't release the leftmost button, it will be able to shoot again. You see? But if you release the leftmost button and try to shoot again, it won't work anymore. Why this is happening, it's because of these timers. On these timers, we need to check the ammo as well, right? So in both of these timers, we want to check exactly with this branch that we have in here, right? Let's just organize it a little bit like this and Croce to copy it because when you use it on both of these timers. If we have a ammo, you can continue with this firing the weapon. Again, for this one, we're going to put it over here, connect the execution pin just like that. Now, if we had compile and run over game, if we shoot all of our ammo, it won't be able to shoot. You can see it's not working anymore. Now it's time to be able to reload. See we can do that next 29. 28 Reload gun custom event: No, we want to be able to reload our gun, but I want to break it in some steps, so it will be easier for you to understand it. It's not that complicated, but I want it to be organized. So for reloading, I want to go down in here. Like here, right, click, create a custom event, add a Custom event, and I want to call it reload Gun, right? That's it. And with it, I just want to use a printer string, and I want to say in there. Reload, right? No, when do we want this reload to happen, right? First place that we want it to happen automatically on this timer custom event fire when aiming or not aiming in both of these cases, if the ammo was not bigger than zero, we want to use reload Gun. Okay? That's it in here, and here as well. Reload, Gun. And where else? Let's just see. Whenever we hit R on our keyboard, we want to reload as well. So we need an input as well. So let's just go to inputs folder, right click in here, go to input and create input action. I want to call it IAR load. That's it. We don't need to change anything inside it, we need to map it. So in here, IMC FPS, click add a new mapping and here we want to map the IA reload that is here. When do we want to happen? Click in here, at R on your keyboard. Whenever we hit R, we want it to happen, right? No, down here, what I want to do I want to right clicking here, search for IA reload. Okay? With that, whenever we hit reload the start whenever we press the reload or R on our keyboard, we want to reload the gun, right? That's it. Now, let's just had compile. First, if I hit R, you can see it says reload, and that is working fine. If we shoot our weapon and it decreases its ammo, just hold it. After it reached zero, it's say reload, and after that, we can't fire. One other place that we want to reload is at the beginning of this IA Fire whenever we check if the ammo was bigger than zero, right? In this case, we want to reload as well, right? So in here, in case of falls, if the ammo was not bigger than zero, we want to reload the gun. Why we need to add it over here? Let's say we shoot our weapon like this with leftmost button each time, right? And when it reaches zero, if you hit leftmost button, it says reload. If you hit leftmost button again, it says reload. Again, you can see, no, it's working fine. No, we know where to reload gun, and when to reload over gun, let's just implement the reloading system. 30. 29 Fill up the magazine: No, first thing that I want to do for reloading, I only create a function for increasing the ammo. The reason that I want to create a function for that even though we have a custom event because we need to check a lot of logic. We have a lot of logic. I don't want to mess this up. We will add some animation to it as well. So the animation will be here, but the logic will be in that function. So in here, I want to create a function and I want to call it reload, right? And in this reload, first of all, I want to check the ammo If the ammo is equal to zero, okay? It means we don't have any bullet inside the magazine, right? There is a difference, right? So use a branch in here to check the ammo. Next, we need to variable to define whenever we reload our weapon, what is the number of bullet that our magazine can take when it reloaded completely, right? So for that, I want to create a variable, and I want to call it reloaded Max Ammo reloaded Max Ammo. So while I'm checking if the ammo is equal zero. Let's say, for example, in a storage ammo, we have 50 bullet. And inside our magazine, we have three bullet. And we loaded Mg ammo. Let's say it is 12, right? Let's put 12 there. No, if we have three bullet in the magazine and the reloaded max Ammo is 12, it means we need just nine bullet from the storage ammo to be added to the magazine, right? We don't need to put away that three. But if the ammo was equal to zero, it means there is no bullet inside the magazine, so it will be easier. We can just decrease the storage ammo and increase the ammo right? That's it. So we have two estate. One, if there is already some bullet inside the magazine, and if there is no bullet in the magazine and magazine is empty, right? So if it is equal to zero, it means this true will happen and the magazine is empty. In that case, first of all, we want to check if the storage ammo was bigger than the reloaded Max ammo, that case, check it. We want to check it with a branch. Like this, if the storage ammo was more than reloaded max ammo, we can decrease the storage ammo first. So get the storage ammo ammo subtracted by the reloaded Max ammo and save it inside the storage ammo again, like this, right. And after we decrease it from storage ammo, we can add it ammo to our magazine, right? So we can get the ammo like this at to it the reloaded max ammo and save it inside the ammo again. Just like this, save it inside the Max ammo again. That's it. What we are doing, we check if there is no bullet inside the magazine and we have enough ammo in the storage to fill up the magazine, we decrease the amount that we want to put in the magazine from the storage ammo and we add it to the actual ammo. Now with that done, let's just see how we can test it. I want to go to Event graph. After this reload print testing, I want to use the reload function, right? Just like this. No, let's just say statute. For it to happen for us, first, the ammo should reach zero. So there is no bullet in the magazine. So let's. No, it is zero. If we hit leftmost button one more time, it will add 12 there, and it will decrease 12 from the storage ammo. And you can see it in here. We have 12 bullet in the magazine, and we decrease 12 bullet from the storage ammo. And again, if you shoot, and it reached zero, and if you hit leftmost button one more time, again, it decrease the storage ammo by 12 and increase the ammo by 12. That's 31. 30 Use Rest of the ammo in storage: No for the next este. In here, if the magazine is empty and the storage ammo was not bigger than reloaded Max ammo, this falls will happen, right? And if these falls happen, it means we don't have enough ammo in the storage ammo to reach 12. It's less than 12, right? Because the reloaded MX Ammo is 12, and the storage ammo doesn't have 12. So this false will happen. And in that case, we want to add the rest of the bullet to the ammo just like this, get the ammo add the risk to add the risk of the storage ammo to it, right, like these. And save it inside the ammo, save it there in case of falls like this. And after that, we want to set the storage ammo to zero. That's it. Let's see how we can test that. For testing that easy, I want to go to a storage ammo. I want to change this to eight, for example, right? So the reloaded max Ammo is 12, but storage ammo is just eight, so it can't fill up the magazine. So now with that, if you test our game, let's eight until we reach zero. No, if I hit ifmost button, it will decrease the storage ammo to zero, and it will add that eight bullet that we had in the storage ammo to the Ammo. No, if I shoot, when it reaches zero, nothing will happen. It can't reload anymore. No, this estate for when the magazine is empty is finished. No, we want to do the part that when the magazine have some bullet inside it and we hit R on our keyboard. Let's see how we can implement. 32. 31 Reload manualy: Now let's say there is some bullet already inside our magazine and we R. So how we can deal with that. In that case, the ammo won't be zero. So this false will happen. And if these false happen first, we need to know how much bullet we should decrease from a storage ammo and add it to the ammo, so the magazine will be full, right? So for doing that, I want to create a variable for calculating that. So in here, create a variable again, of type of integer and I want to call it amount to be added. Amount ammo to be added, right? That's better. Now, for calculating that, we need to get the reloaded Maxamo that in this case is 12, right, and subtracted by the ammo that we have already inside the magazine. And with that, this is the amount that you want to add to the magazine, so it will reach the reloaded Maxamo, right? Just like that. Now that we know how much ammo we should be adding to the magazine or ammo, I want to check if there is enough ammo in the storage ammo or not. So I can check that with the branch, right? And I want to check the storage ammo to see if it has more ammo than the amount ammo to be added. If the storage ammo has enough ammo to fill up the magazine, this true will happen. And with that, first, we need to decrease that amount of ammo from the storage ammo, so subtract the amount to be added from the storage ammo and save inside the storage ammo. So with this, we are decreasing the amount of ammo in the storage anno, right. And after that, we want to add that amount to the magazine. So we get the ammo and we add the amount ammo to be added to it, right, with a add node. And we save the ammo after that, right? So just like that, we can save the ammo. Cool. Now, let's just compile, save and test tattooed. Let's say, no we have ten in or magazine. The reloaded max Ammo is 12, and we have eight in or storage ammo. If we head R, what should happen, the storage ammo should decrease by two, and it will be six, and the ammo itself should get to 12, right? Head R, and now you can see, 12 of six. That is working fine, right? Again, you should we have seven. We need to add five to it, so it will be 12 again, reloaded Max ammo, right? And the storage ammo will use just one head R, and now you can see 121. So you can see it's working fine. The next step is when the storage ammo doesn't have enough ammo to fill up the magazine. So we can just add the rest of the ammo that is inside the storage ammo to the magazine. And set the storage ammo to zero after that because it doesn't have enough ammo. So for that, I want to get the ammo in here, add it with the storage ammo and after that, set the ammo with it, right, like this, connect the execution, pin to here. After that, we want to set the storage ammo back to zero, so it will be zero. Now, let's just see how we can text. Test that. If you run over game, let's just shoot everything, right? We have two on our magazine right now, and we have eight in storage ammo, and the reloaded Ammo is 12, so it won't fill up the magazine. If we hit R, the amount of ammo in the magazine should be ten, and the storage ammo should be zero. So let's just hit R. Now you can see, ten of zero. That's it. It's working fine, no. We have a ammo system for 33. 32 Reload animation: No next thing that we want to do. We want to play some animation when we are reloading, right? It's really important. So go to Content drawer. I want to show you the animation, so go to Asset, go to arms, arm animation, and let me find the reload. You can see it over here. This is our reload. We want this to happen, play this animation, right? So for doing that, again, I want to use an i montage. So right click on it, go to create and create nimntage, right? That's it. I want to drag and drop it, put it in animation folder inside the Opus, move it there, right. By default, everything should be fine. We have an reload montage, right? Go to BPFPsT reload function is good. This decrease Ammo is good. No, let's just close some of these. We don't need these ones. So go to event graph. No, in here, we don't need to say reload anymore. We have the function for reloading. You can just delete it for no, of course. First and first, in here, we want to check if we have any ammo in a storage ammo or not. So check it with the branch. The storage ammo, we should check if it is more than zero, right? If it is more than zero, we can play the animations, right? If it is true, we want to play a Montage. So search for play Montage, right? This one that has uncomplete on it. So whenever the nimntage get to be played completely, this uncomplete will happen, right? The montage that you want to play is called arms reload montage, and the skeletal mage that you want to play this animation on is called arms. So dragon drop it, put it there. No, you don't need to change anything. For it to not give us any bug, we need to create a variable. So whenever this is plain. This animotage is plain. Don't reload again. So reloads can't interrupt each other, right? So in here, I want to create a variable of type of Boolean, and I want to call it es reloading, right? So at the beginning in here, we want to set the ese reloading to true. So set the ease reloading to true when we want to play the animation. And before all of this, we want to check. If this reloading was not true, you can reload. So in here, check it with the branch like this. If we are not reloading, you can start reloading. And when the reloading finished, we can set this is reloading to falls again, right, the complete. And when this animation get to be played completely, we can use the reload function as well. So dragon drop reload function to here. Next, after we play this animation, we should play other animation as well. Let me show it to you. If you go to Asset, go to Gn, if you remember gone animation, we have a Gun reload animation as well. Just look at it. The magazine will go out, right? We want to play this animation as well. So in here, we can get over gun. With this animation, we want to play this animation. So this execution will happen exactly with this, right? So in here, we can play animation, right, and connect this execution pin to here. And the animation that you want to play is called gun reload. That's more than enough. No, let's just the Sato If you had compile, and if you hit run, no, let's see what will happen. If I hit R, you can see, it's working fine. And now we have 12. Now, if you shoot again and if you hit again, you can see the reload is working fine. But one problem that I can see in here, let's just reload first. You can see we are reloading, everything look good. But we have 12 bullet inside our magazine. But if you hit, again, it will play the animation for us. Nothing happened with the amount of bullet in the storage and the ammo, but it is playing the animation, so we need to fix that. We can fix it in here. So we want to check if the storage ammo was bigger than zero and with the end bullion, we want to check if the ammo was not equal, not equal to the reloaded max ammo, in that case, you can reload. Again, if the storage ammo has some ammo inside it and the ammo is not filled, the magazine is not filled. If both of these cases is true, you can reload. Now, if you have compile and run we have ten. If you reload, it is okay, right? And know if I had R, you can see it from plain animation, right? We shoot, and after that head R, you can see, No, it's reloading or weapon. That set or reload is finished 34. 33 Reload sound: No, we are reloading and we use the animation for it, but there is no sound. So for adding sound, where I want to do it, I want to do it in this animation sequence, gun reload. So click on this magnifier glass, open up the gun reload. In here, as you know, we can play some sound. So let me see this. First, the magazine gets out, right? That's it. In this case, in here, we want to play a sound. So in here, right click Add and Notify play sound, and the sound that we want to play, it has reload in it. Reload part one. That's it. After that another magazine will go inside, and then you want to go inside, again, I want to play another sound, add Nodify, play sound. And the sound that this time, again, it has reloading part two, name, right. After that, we have a tab, right? Now, for the next part, there is a tap. Let me show it to you. If you run over game, and let's just hit, you can see, there is a tab there. But in here, adding it, it's a little bit hard. We should put it somewhere and with that, decide if it should happen sooner or later. So go to Add Notify play sound. And for this sound, click in here, search for tap tap in the gun. Let's see if just with this, the audio is good or not. Now, if you hit, and I think that looks good. It is on frame 42, close to 42. Of course, you should play with this until it is perfect. Now, let's just play it in here as well. That looks awesome. That's beautiful. You can just close it. No over reloading has some sound. You see? Cool. 35. 34 Firing when sprinting: No, we want to fix some bugs that make you find it till now. So if I run over game and in here, let's just sprint, right? And if we hold fmost button, forget it. That doesn't look good, right? So what we want to do, we want to change the max, walk speed to 250 when we want to fire, right? So in here, in the event graph, when we want to fire, let me find it. I fire. Firsts, let me make some space in here. Before checking if you are aiming or not, I want to change the max walk speed. Get the character movement component and in here, set max walk speed, to 250. This is the walking speed, right, not the sprint speed, right? So put it there. No it will go to walk state. But when we release leftmost button, this complete will happen, and we want to go back to the state that we was. So we wanted to know if we were running or not. So for doing that, I want to create a variable, and I want to call it is running. That's it. Now, where do we want to set this? Go up where we are set the Max we right. If we put it on 600, we want to set the running to two could just call it Is sprinting, doesn't matter. Contin control we paste that over here, and this is for walking, right? So know with that we know when we are running. So in here, before clearing the fire timer, I want to check if we are running or not with a branch, right? So check if we are running. If you release leftmost button and we were running, we want to change the max walk speed to 600 again. So let's just get the character movement, and in here, set max walk speed to 600, right? If we were running, connect the execution pin two, and this to clear timer. But if we were walking, it should stay at walking, right? But for us to be sure, we can just put it on 250. If we were already walking and shooting and we release leftmost button, again, we wanted to stay at the walking speed, right? So we connect these two here, and that's it. Now, if you run over game, let's see what will happen. Let's just run and had left most button. You can see it will go to walking, but we have a problem. Let's just see. If we head try to shoot, it should reload. And you can see, when it's running, it have a shoot as well, a little bit shooting, right? That's because of the blender space that we have. So we need to change that, go to apes, go to animations, and we have beers walk and run. And I want to change the smoothness back to zero. Let's just test that no. If we run over game and try to run and get more button, you can see it's working fine, no. Cool. And that's about or problem. 36. 35 Fix running and gunning: Next problem that we have let me show it to you. Let's say we are moving and we are firing, right? And we hold shift. You can see what will happen. Let me walk, hold leftmost button, and held shift. You can see what is the problem. Whenever we are firing, we shouldn't allow player to sprint. So for doing that, first, we need to know when we are firing, right? When we are firing, when this fire happened and the Ammo is more than zero. So I want to create a variable, and I want to call it es firing. And in this case, we want to set it to true, right? And with that done, whenever we try to run, let me find it. We go up. Whenever we try to run, what do you want to do? We want to check this is firing. Get it and check it with the branch. And this time, I want the start and trigger to be checking this, right. It's really important. If you are not firing, we can go to Max walk speed of 600. No, let's just compile, save and run over game, shoot, move, and hold shift. After that, you can see we can't run. See, if I release leftmost button, again, we can't run. So what is the problem? The problem is that whenever we release leftmost button, we are not setting the Es firing to false. So in here, when we release the leftmost button, the IA fire, we need to set E firing to false. That's it. Now, let's just check that out. You can see we can't run. No, we can't run. So everything looking good, we have no bug. Of course, if you found any bug, just leave it in the question section or discord channel. I will create a video for. 37. 36 Ammo UI background: No, we want to create a UI for our AO. Let's see how we can do that. For doing that, I want to go to Content drawer, go to FPS folder, go to Widget. And in here, right, click Go to User Interface down here and create a Widget blueprint of type of user widget and I want to call it DUBP Amo UI, right, click on it to open it. In here, first thing that I want to add, I want to add a Canvas panel. Next, I want to add a border it over here. And click on it. I want to show the AO on bottom left corner. That's why I want to change the anchor point to bottom left corner as well and change the position X and position Y to zero. No, I want to change the alignment to Y to be one, this one, but the x zero is more than enough, right? So in here, alignment of Y, I want it to be one, and I want to give it some padding so it will get away from this border. So in position X, I want to put 50 and position Y, I want to use -50 so it will go up. For the size, I want to change the sizics to 300 by 100, right? That's it. Next, this one, go to appearances, go to brush, and change the draws image to rounded box. So it looks much better. Next, go to outline setting. Change the corner radio to ten for all of them. Like this, change the outline color to a white color, right? Just like this to. The wed of it, I want to put one in there, and the rounded type, I want to change it to fix radius. And next, I want to use brush transparency as well. No, I think that looks good, but I want to change the tint color of it, as well. The tint color, I want it to be exactly black so you can see the borders, and I want to change the Alpha 20.5, for example, heat ok. And this is the background of over AO UI, right? Just with that, let's just add it to our blueprint. In the begin play, we need to create it and add it to viewport. So in here, again, I will say create Widget, right? And what widget you want to create is called WBP MoUI. Next, I want to right la promoted to a variable, and I want to call it AO UI or it's better to call it WBP MOI. It will be easier to find it, right? After that, you want to add it to viewport to viewport. And just with that, if you run over game, you can see we have a background for showing the AO. Now, let's see how we can add more beautiful things to it. 38. 37 Horizental box widget: Next thing that I want to do. I want to show you what you want to create with this background. Let me bring up the paint. It's free, right? So in here, we have a background, right? In this background, what I want to do first. And in here, I want to show an image of a weapon in here like this. I can't do it better than this. After that, I want to add a line in here and add a line in here as well. And in here, I want to show the amount of ammo, for example, ten by eight, for example, right? And let me change the size like this. And after that, let me click in here to choose one of these. In here, I want to show how you can reload. So we add image in here and in here, we say reload, right? Like this reload, like this. So this is roughly what we want to show. An image, some line and the number of bullet inside the magazine and the storage. And after that, show an image in here to say, if you hit R, you can reload. That's it. That's what we want to do. This is our reference, right? For doing that, first of all, I want to add a horizontal box, right? So in here, add a horizontal box. So we can horizontally add item after each other. First thing that I want to add inside this horizontal box is just an image. So add an image and the image that I want to use, go to brush and in here. Search for M four. That's it. Now, you can see the size of it. It's too big. I want to tell it to fill up half of the background. So click on fill and change one to 0.5 for no. Of course, it's filled everything because there is nothing there right now. But when we add other stuff, you will see it's working. Next, I want to align it to the left and middle as well, middle in vertical, and left in horizontal. So left this side and middle this side. Next, I want to change the tint color to something like this, a blue color, right. Like this, I think that looks much better. Next, I want to add a line at middle in here, so add a border inside this horizontal. You can see it will be added over here. And again, we wanted to tell it how much of the screen it should feel. By default, when we put one in here and 0.5 for this one, it means the whole background will be 1.5, that one of them will be this image, and 0.5 of them will be this and four image, right? So, this one, I want to create just a line. So the size of this field, I want it to be 0.005, really a small number. No next thing that I want to do. I want to decrease the Alpha of this to 0.5. Right? You can see it. And I want to add some padding to top and bottom. So I think to top, let's just put ten for top and bottom to ten as well. And that's it for no, leave it like this. Next, I want to create a vertical for stacking things on top of each other. We create this, we create this line. But no, we need a vertical box so we can stack things at top of each other. So let's find a vertical box, vertical box, added horizontal box. And this one Again, I wanted to fill up, but this time, I wanted to fill up 0.6, right? All of these are just relative, right? Just with that, if you clicking here, you can see it. There is a line in here and there is vertical box in here. And note, the size of this image is not good. I want to change the size of this image to 152 by 41, and that's it. Now, we have a good image there. We have a vertical box that we can add a lot of things to it. But for now, I think that looks awesome. Let's just say compile and run, and now you can see. That's beautiful. Right now, we are not updating anything. We haven't finished it yet, but in next video, we try to finish it completely. 39. 38 Ammo UI for magazine and storage: No next thing that we want to do, we want to show the amount of right. So let's just go back in here. First of all, we have some numbers, and how I want to do it, first of all, we want to stack some things at top of each other. And the first thing that we want to stack at top is these numbers. And I want to use another horizontal box to, for example, this be a text, this be another text, and this will be another text. So they don't push them at all, right? After that, we add the line with the border, and after that, another horizontal box to put this image here and after that, a text in here, right? So let's see how we can do that. For doing that, first of all, I want to create a horizontal box, add a horizontal box to over vertical box, and you can see a top here. And I want to say feel 50% or 0.5, right? It's relative to other things that are inside in here because there is nothing inside there, 0.5 will fill up everything, right? After that, we need a border. So let me go up, grab a border because we need a line. And this one, again, we wanted to fill up everything, and the amount of filling, I want to be 0.01. That's it. Next, I want to add another horizontal box like this. And this one, again, we wanted to fill up a screen. This time, again, 0.5 as well, right? So now with that, if you click away, you can see it. That's it. First thing that I want to do, I want to click on this border and change its tint color Alpha to 0.5. Okay. So it looks much better. You can see it. That looks much better, right? Next, for our horizontal box, I want it to be exactly at middle like this. You can see it did get a small, but when we add stuff to it, it will get bigger. So what I want to add in there is just some text. So let me add one, add another one. We need three, right? Add another one. This first one, let's just name it amo. Right? The next one, we don't need to name it anything. It's just a slash, right? And the next one on call it storage ammo, right? That's it. Now the text of it for you to see it, for example, in here, let's just say eight, right? And for this one, let's just say from 50, right? For no, of course. And the middle one, let's just use is slash, right? Just like that. We are showing the amount of Ammo a pre, right? Now I want to click on all of them, select all of them, and change the color. So for example, the opacity or Alpha of all of them I want it to be 0.8, a little bit dim, all of them, I wanted to be aligned at middle as well. So if we change the screen size, it will be always at middle. That's it. That's beautiful. No four or horizontal box in here. First, we need to add an image. So add an image in here. The image that you want to add is called R on or keyboard R. We are showing it over here. Next, we want to say fill up the screen. Just point tree of it, right? Again, it is relative. When we add more stuff to it, we can change the field number relatively to this. If we add something else and this value of that is more than this, it will occupy more volume in our horizontal box, right? Next, the padding. So in here, padding to all direction. I want to put five like this. Again, I want it to be align at center for all of them. Now for the image size, I want to change it to 261 by 258. Just with that, I want to add another thing like a text I know you can see. And with this text, I want to click on it, again, tell it to fill up everything. This text, I want to fill up by 0.5, and I want it to be align at middle on both cases. And the Alpha of it, I want it to be 0.8 as well. And I want to say reload. On it, and that's it. Now, we have over UI, right? Now, if you run over game, you can see we have over UI, but we don't have this line. Let's just increase this value until we see that 0.2 and no run over game. No, you can see the line is there. No everything looks good. Now it's time to be able to update these numbers. Let's see how we can do that next video. 40. 39 Update ammo UI: Next thing that we want to do we want to update the amount of AO and storage AO inside where you are. Let's see if we can do that. For doing that, we need to click on this AO text and hold Control, select the storage AO as well, and make them variable by checking this. With making them variable, we have access to them inside the graph in here, right? For updating them, I want to create a function. So, for example, I want to name this one update AO, right? With this update ammo, I want to update the Ammo. So get the ammo and I want to set text on it. Sit text down here, right? And the need a text to be inside. But the AO is just integer. So click on update AO and create input in here, and I want to call this one amount or AO or whatever you want to call it. The type of it, I want it to be integer, and now I can just connect it to here. It will automatically change it to text, and know with this function, we can update it. We need to do the same for updating the storage ammo. Select everything, control C to copy it and create another function for update storage ammo, right? And with that, control V to paste everything in here, connect the execution pin. This time we don't want to change the Ammo. We want to change the storage Ammo. So drag and duro put it in here, and we can just connect this to here and name it, right? So click in here, name this to amount as well. That's it. Now, we have two function that with those, we can update the Amo in OUI. So no, for doing that, we should go to BPFBSF and first, in here at the begin play at the begin play execution path, we need to update both of them. So we can get the WBP MOI, and in here, use update AO right and connect the execution pin to it. We want to update the Ammo with the Ammo that we have in here, right? Next, we need to update the storage Ammo as well. So in here, search for Update storage Ammo, connect the execution pin, and for the amount, we need to pass the storage ammo, right? With these two, we can right click on them and collapse it to a function for updating update AOI, right? So with this function wherever we put it, we are updating the ammo. Now, let's see. If we compile, you can see the ammo is ten and the storage ammo is eight. Let's just run over game. We can see ten and eight. If we shoot, it's not updating. That's a problem where we should update it whenever we decrease the amount of ammo, where we can do it in weapon fire right in decrease ammo at the end of decrease ammo we can use this update MOI, just like this, connected like this, head compile, and no run, and let's see what will happen. You see it is updating. And if we head, let's see what will happen. It's not updating, no. So when it decrease, it is okay, but when we reload, it's not updating. So let's see how we can add that functionality as well. See where we are reloading. In here, we have reload gun at the end. When this reload happen, again, in this time, we want to update MOUI connected like this. And now let's just test Std If we run over game, can see when we shoot, it's updating. Cool. If I hit R, t's see what will happen. No, you can see. At every time it is updating. That looks awesome. That's beautiful. Let's test more No, everything is working fine. We don't need that printer string anymore, so we can go to Event. Let me find it. It's top here. We can just delete this because we are showing it with AUIO. That's it. Congratulations. 41. 40 Ammo Item: No, let's say, our bullet is empty. We don't have any in the magazine. We don't have any in a storage, so we need an item, so we can pick it up, right? So for doing that, I want to go to FPS folder and in here, go to Blueprint. Right click in here, create a blueprint class of type of actor, and I want to call it BP item, right? Because in future, I want this item to be other things as well. That's why I will call it item. But for now, I want to use it just as a bullet, right? So now in here, first thing that I want to add, I want to add a Niagara porticle system, and I want to drag and drop it, put it as default snroot and know the thing that I want to put there is called NS ammo, right? Just choose this. Now, you can see it. Whenever we collide with this one, we pick it up and amount of ammo of us will be increased, right? Next, I want to add a sphere collision. So search for sphere collision and put it there. Now, I want to bring this up just like this and go down in here until you reach the collision section in here, and it should be overlap all dynamic and generate overlap event. Next thing that I want to add in here, I want to add amount, right? Amount to be added, right? So click in here. I want to change it to integer. And let's say, for example, this, we want to add 25 Ammo to our storage. I want this amount to be instance editable and expose on span. So compile save. Now, let's just put some of them in or level. I want to click on or player Sart head F to go there. No, I want to put them, one of these BP item over here so we can collide with it. Now if you run, you can see, we can go forward and collide with it, right? Cool. But right now, it's not doing anything. Let's just see how we can pick it up. Let's just go to BP FPS and in here, click on the capsule component. If you go down, we can create on component BN overlap. W this, let me bring it down here so we have some space. In here, we want to check. If you are overlapping with something, we want to check if it is item, get the other actual that we overlap with, cast it to BP. Item, right? And because we know that this PP item right now, it can be just a ammo. We can get it amount, amount, right, get it, and add it to storage ammo, add them together like this, connected like this. And save it inside the storage ammo after that, save it like this and connect the execution pin to it, right? And after doing that, we need to update the MoUI right? Just like that update the MOUI. Now let's see what will happen. If you run over game, you can see if I overlap with it, what will happen, I will add 25 to us. But the next thing that we want to do whenever we overlap with it, we want to destroy it, so we can't pick it up over and over again. So at the end, we want to get the other actor in here and destroy it. Say, destroy actor, right, and connect it like this. Now, with that done, let's just add some more. For example, PPIM is in here. Hold out, create a copy of it. You can see sometimes it's not showing it, it's just a bug. Don't worry about it. The amount of this one, we can just change it in detail if you click on it. Right now, this one is 25. We can put eight there, right, and this one is 25, right? No, let's run. If you pick up this one, it will add eight to us, you can see, and it will be destroyed. And again, if we grab this one, it will add 25 to us, right? See? No, we have more bullet to shoot. 42. 41 Kraken blueprint: No next thing that you want to add, we want to add some AI, some NM and we want to use tracking. For doing that, there is a zip file in description of this video that is called ai dot zip. Download it. Put it on your desktop. Double click on it to open it. Next, go to Real engine in here, click on Content drawer. Go to Content folder, right, click on it, show it in Explorer, and know we have the content folder of our project. No, with that done, drag and drop the AI folder inside this content folder. Make sure it is exactly named AI. After that, inside, it should be cracking, right? That's it. Don't change anything just yet. If you want to change anything, you can go to Areal Engine and do that, right? No, with that done, if you go inside it, you can see there is a folder for cracking and some assets there like a mesh for over cracking, right? So, no, let's just create over cracking. Inside this cracking folder, I want to right click, create a new folder, and I want to call it BluePrint, right? I'll click on it to open it right, click in here, create a blueprint class because our cracking can move. That's why I want to create a character class for or cracking, right? And I want to call it BP cracking, right? I'll click on it to open it. First thing that I want to do in here, I want to click on the mesh and choose the mesh. So click in here and choose the cracken, right? You can see, it's really big. No, the capsule collision, right now, it's too small, but we Cracken is too big. So let's just click on the capsule component and change the capsule Halfte and capsule radius. I want to change it to 352 for both of them, like this. No, I want to click on or mesh of the Kraken, and I want to reposition it until it is at middle in here. I want to change it to -350, right? It will be at middle. That's good. Now, with that, let's just check one of its animation. So for example, use animation asset and choose one of the cracking animation. For example, idle. You can see, or Kraken is facing toward the positive Y direction, and we want it to face toward the positive X direction, the forward vector, this arrow that we can't see it in here, right? Let me head F to zoom on it. You can see the arrow. This is our forward vector. So Kraken should face that way, and we can rotate it -90 around the Z axis, so it will face the positive X direction, right? This way, again, it's like it's facing the positive tes because if you click in here, you can see this is the word position, and this is the local positioning, local rotation, right? So this is the thing that you want align the positive x axis, right. And with that, what I want to do, let's just compile, save and go to a level and let's just put one over here, right? Just like this. It will be on the ground. No, that's okay. You can see that's beautiful. Now, let's just run over game and no you can see we have or cracking, right? Looks beautiful. It's just playing the ideal animation. 43. 42 AI controller: No, we want to create a controller, AI controller for over cracking. So it can move it. It can find the player. I can hit the player, damage the player and all of that. So for doing that, go to Content drawer. I want to create our controller inside our blueprints because it's just a blueprint. So right clicking here, create a blueprint class, go to all classes and search for AI controller, right? And the one that I want to use is called DTrKrod AI Controller. Selected, head select, and I want to call it AIC for AI controller. Crack him. Right? That's it. No, with that, we want to go to where cracken itself and go to class defaults, go down until you reach the pawn section. If I can find it, it's a little bit hard. It's down here. You can see in Pan section, we have a AI controller class, and we want to provide it with our own controller that we create, right? Just with that, no we can't tell it where to go, where to stay, when to head and all of that. But right that we are here, let's just go to character movement. I want to change some stuff in here. For example, the max walk speed for cracking, I want to change it to 250. It looks more natural this way. On to go down, when you reach the rotation rate, I want to decrease that by 100 as well, and that's it. Now, we have a controller that can control the cracking, but how we want to control it? Let's just click in here. In here, you can see it is like any blueprint, right? But Ari engine give us a tool that is called behavior tree that with that, we can do lots of things in an easy way, fast way, right? So let's just go to Content drawer in here. Right, click, go to Artificial Intelligence or AI and create a behavior tree. I want to call it BT. Kraken. This is our behavior. And if you don't click on it in here, we can decide what or cracking should do at any time. And I will explain everything. Don't worry about it. Just for notice that with this behavior tree, we can manage the behavior of our crack. And this behavior artery needs a blackboard. Right now, you can see it is grade out. The Blackboard is where we save our data. We save where our player is, we save the locations and whatever we need. So we need a blackboard, as well. So right click in here, go to Artificial Intelligence and create a blackboard. This time, I want to call it BB crack, right? You can do click on it to open it. And no we need to connect this BT behavior artery cracking with this blackboard. So we save our data inside the Blackboard, and with the behavior are, we can access them. So for setting the Blackboard in here, in the behavior artery, we should click in here in behavior artery and choose the asset. Click in here, choose the BB cracking and know we have access to our Blackboard just in here. You can see in here, we can access to both of them or you can just open it like this. Both of them are the same. Oh, you can see or blackboard is connected to our behavior tree. And we can save it. No insight or AI controller. We need to tell this AI controller to use this behavior tree to manage the behavior of our cracking and how we can do that. We can say run behavior tree. And it will tell us which behavior tree, choose the BT cracking, right? And that's it. Our AI controller will control over cracking by this behavior tree in here. Next do, we will talk about this behavior tree. 44. 43 Kraken Move to: Now let me explain how these things works. First, we create a AI controller, and with the AI controller, we run a behavior artery, and in the behavior artery, we can decide what we cracking can do. It's exactly like any input. For example, we have moose and keyboard, right? So in moose and keyboard, that it is just a controller when we told you where cracking should go forward. When we hit S, it should go backward, right? But in the behavior artery, we call them tasks. For example, task to move forward. Task to move backward. Of course, we don't want to do it like that, but we do them with tasks, right? You know that the AIC cracking is controlling or cracking, right? And with our behavior artery, we are deciding what AI controller should pass to the cracker, right? So in here, if it dragon drop from here, you can see there are some things in here that the most used one is a sequence node. This sequence node, if you hover over it, it will tell you what it too. Whatever task that we add in here, it will be executed from left to right. So the positioning of things in here is really important. It's not like blueprint that you can connect anything to where you want, right? So in here, it will execute the tasks from left to right. And if one of the tasks failed, the sequence itself will fail. But if the all tasks connected to the sequence get to be played successfully without any problem, the sequence, we call it, the sequence was successful, right? For example, one of the tasks that we want to use is called move to, right? This move to will cause over cracking to move to a location. So we need a location for over move to, and how we can set that location, we can set it inside the blackboard. You can see in here we have a Blackboard category, and in here, we can decide to where it should go. For example, if I go to Blackboard and in here, add the key of type of vector, and I want to call it location to go to, right? With this, if I head save and go back to behavior three and click on or move to, we can decide the Blackboard key that this move to should use to move to a location. Now with that done or move to node or tasks has a location to go to. You can see it says move to location to go to, right? So we need to update this location inside or BP Kraken. So go to BP Kraken, and in here, let's just say at begin Play, we want to update or Blackboard key that is called location to go to, so in here, we can get to Blackboard. So search for Blackboard. We say get the blackboard. I will get the blackboard because it is connected to here by the AI controller that we create. And in here, we want to set a vector. Search for vector, set value as a vector, right? No, the next thing that this set value as vector needs is a kename. So we should go to our behavior three after that the Blackboard and copy this name headf two control C to copy, and we can just use it for the kename. But the keyname you can see, I can't paste it in here. So what I want to do I want to use a string to name node in here, right? So I can put or text the location to go to, right? And the vector value, the position that we want it to go, let's just leave it as zero, zero, zero. Doesn't matter, right? So now, if you go to over level, this is or cracking, and for you to see where is the 000 location, I will click on one of these items and put it on 00 location. So you can see, this is the 00 location that you can see it over here. So, or cracking should start there and stop here. Now, if you run over game, you can see where cracking is not moving. Why it's not moving to that 000 location, it's because our AI needs a Navmsh so it can find its face. Go here and add a Nav mesh. Okay, Nav Msh bounce volume. Just put it there. I want to change the size in each direction to, for example, 100 and in direction, 100 as well. And in the Z direction, let's just use 50, right? That's more than enough. Let's just run over game. Now you can see where cracking is moving. The movement is not that much. We don't have animation for moving, but you can see it is moving and it's working fine. And whenever it reached the 000 location, it will be a stopping now you can see it will stop at 000 location. 45. 44 Check if player is in range: Know that we know how to move over racking. What we want to do now, we want to check if the player is in line of sight, go to the player and attack it and we will do it in several videos. So for doing that, first of all, we need to know if the player is in range so the cracking can see it, something like that, right? So for doing that, I want to create a sphere collision. So click on the capsule, click on AD and search for a sphere. Collision with that. I want to make it really big. Like the Sphere radius 6,000, right? Just like this. You can see how big it is. And know with that if I had compile save, go to or level, I want to put it outside of where player starts. So let's just put it over here maybe. And next thing that I want to do I want to get a Navmsh and make it really bigger, like 500 by 500. That's it. Just big enough so it can find us, right? Know with that done, whenever we get inside this sphere, we want the cracking to come after the player, right? So for doing that, I want to click on or a sphere, go down in here and create a begin overlap. And with that, I want to check the actor that begin overlap with this sphere collision with the casting, cast two BP FPS, right? And if it is the player, the success will happen, and I want to show it with just a print tesorne right? And I want to say player is in range. That's it. Now, if the player get out of the range, again click on the sphere, and in here, just create on component overlap. In this case, again, I want to do the same. Control C Control V pi all of this, connect the execution pin other actor to object. No, this time, I want to say player is not in range. So in here is not in range and the color of it, I want to make it red so you can see it better. That's it. Head okay. Now with that, let's just head compile, save and run over game. No, you can see, it's not saying anything, but if you go forward inside that, you can see it says player is in range, and if we get out of it, it's moving because it want to go to 00 location. And you can see it says player is not in range. Again, if we get to it, player is in range, and if we get out of it, let's see what will happen. Player is not in range. Again, if we get inside it, you can see how it's worked. Now with that, we want to create a system. So whenever we are inside that sphere collision, it will go after the player. Let's see how we can do that. Next. 46. 45 Kraken chase player: No, we want crack and to follow the player, if the player is in range. So for that, we don't need this printesring. Next, we don't need to set the location to go to anymore, so we can delete this as well. Now, with that done, I want to go to Blackboard in here, and we don't need this location to go to delete it. We don't need this one as well. We want to save the player, right? And inside our behavior tree, we want to say, go to player, right? So let's just go to Blackboard in here. The key that I want to create is type of object, and I want to call it player, right? And the key type expanded the base class. I want to change it to BPFPS, right? Make sure it is BP FPS. So no this player can save a FPS player inside it. And in our behavior tree in this move to, we wanted to say, go after the player. That's it. We put the player there, right? But no, if I just run over game just like this or cracking won't move at all. You can see it's not moving at all. Even if you are inside the collision, right? It's not moving. Why it's not moving? Because we didn't set this player at all. And where do we want to set it? On this, we get overlap. So if the player is inside the sphere collision, Kraken can go after it. So for doing that, what I want to do I want to get our blackboard, so get black board. And we want to set object value. So search for object, right, set value as object. That's it. I need the execution pin. The object that you want to pass is as BPFS and the key name, we want to use a string to name, right? And the name is player. That's it, put it there. And with that done, if you head compile, save a run over right now, you can see our cracker is not moving. If we go toward it and we go inside the atmosphere collision, it should go after us. Now, you can see it is coming after us. Let's wait. If we go closer, we will help that. And if we get close to us, let's see what will happen. Let's wait. Let's wait. Let's wait. And now you can see it is staying there. That's it. It's playing the idle animation. And if we move again, it will move with us as well. You can see to reach us, right? No, it is getting too close to us. We can change that. Go to behavior T in here and click on this move to. We can change the acceptable radiance from five because five is too small to 1,300, right? Know it that then if we had compile and runo game, right? No, it's not chasing us. And if we go inside the sphere collision, it will chase us and it will wait close to us, but not that close that we are beneath it, right? So, no, let's wait, let's wait. And now you can see, it will wait there. That's awesome, right? No cracking can go after 47. 46 Kraken get damage: No next thing that you want to do. We want to be able to shoot at our cracking, decrease its health and have some health war, right? So let's run our game and go. You can see I can shoot it, but let it go to us. It's whenever we are shooting at it, it's like nothing is happening, right? It's not impacting it. So let's see what is the problem. If we go to our BP crack, go to Mish, we need to change the collision of it. So first and first, I want to change the collision preset to the custom because I want to do some stuff in here. I wanted to block everything, but overlap the pun and generate overlap event as well. No wishes he compile and run over game. Now, let's just get close to it to see if we hit it if it is impacting it or not. No, you can see when we hit it, you can actually see the effect. Can see there is some effect hitting it, impact visual effects, right? So let me shoot. In here, you can see, No, it's working. We can hit it. But when we hit it, there is nothing happening, right? We need to damage or cracking, and how we can do that, we need to open up our FPS blueprint, PFPS and in here, wherever we are firing. I IA fire, right? We need to go to weapon fire. After we had the for line trace, let's just make some space. We want to get the hit actor and apply damage to it, right? That's it. Easy. Apply damage to the actor that you are hitting. If the actor is cracking, this will happen. If it is ground, this won't happen. A engine will ignore it, right? Now, for the base damage, I want to use a random float in range, right? Let's say each time we want to add five to eight damage. So every time it will be different, right? Now, let's see if it works or not. Go to BP cracking and in here, find the empty space and search for event any damage, right? And I want to check with the printer string, print a string to see what is the damage, right? Every time that we have it. Now, if you run over game, and let's just shoot at it, you can see five, seven, seven, and no, you can see, it's working fine. We are damaging or cracking. Cool, right? 48. 47 Kraken health system: No, we want to create a health system for over cracking, right? So we don't need this printer string. What I want to do in here, I want to create a variable, and I want to call it health, right? And the type of it, I want it to be float. Next, I want to create another variable, and I want to call it Max Health, right? That's it. For example, let's say, health is 45 or 50 and max health 100 or whatever you want to put in there. It should work with all of them, right? Now with that done, every time that the crack can get the damage, we want to check if the health is bigger than zero with a branch, right? So search for branch like this. If it is more than zero, we can decrease the health, right. So in here, true will happen, and in that case, we want to get our health again and subtract it by this damaged number. And after that, we want to save it inside the health again in case of true, right? That's it. No next thing that we want to do. We want to check if the health is less than zero or zero, right? So in here, again, I want to get the health and check. If the health is less or equal, then zero, it means or cracking is dead. So we should check it with a branch like this. In that case, if true happen, we can use a printer string for no like this and say, cracking is dead. And in case of faults, what I want to do I want to use a printsring and show the health there. That's it. No, let's just compile and run and know if you shoot at or cracken, you can see the health is 42. Shoot at it. You can see it is decreasing, decreasing. And when it get zero, it says cracking is dead. So our system is working fine. But the next problem that we have whenever we shoot at our crack and it should follow us. Doesn't matter if we are inside that sphere collision or not. So in here, when the health is more than zero and we damage it, these falls will happen and we show the health after that, what you want to do we want to update the player in or Blackboard, update this player inside or Blackboard, right? We done it before in here, right? Just like this Control C, Control V to paste it over here, right? And for the player for the object value, we can get the player character, right? And we can cast it to cast to BP FPS. I need execution pin. So let's just give it that like this and connect it to the object value. Now with that done, if we head compile and Runo game, you can see it's not moving toward us, but if we shoot at it, no, you can see it's following us. If we wait, it will reach us. No, you can see it's coming to us. No, or cracking is checking if it's head or not. That's beautiful. 49. 48 Kraken Health UI: No, we want to create a health bar UI for over cracking. So let's see how we can do that. Go to Content drawer, go to Content folder, go to AI crack and, and in here on the right click, create a new folder and I want to call it Widgets. Double click on it to open it. Right click in here, go to user interface, and in here, create a Widget blueprint. And I want to create a type of user widget, and I want to call it WP, crack and Health. Right. I'll click on it to open it. Now, in here, first thing that I want to do, I want to add a canvas panel. I want to use a progress bar just like this, and I want to anchor it at the middle like this, top middle, of course, the position X and position Y, I want it to be zero. The size of it, I want it to be 800 in X direction and 15 in Y direction. And for the position Y, I want to put 50 there, so it will go down a little bit. And positionX I want to add 16 as well, right? Why I'm doing this because I want to put an image in middle in here, and create this health baar on the left side as well. So let me use Control D to duplicate this one. And this time, again, the anchor point top middle, right? And the size of it is good. The alignment of it, I want it to be X one, and the position Y, I want it to be 50, just like this, like we have it over here. And position X, I want it to be -60. This one is 60, this is -60. Now, you can see it's like it's mirror, right? Now, with that done, let's just put the percent on 0.5 and percent of this one to 0.5 as well. Next thing that I want to do. This one I wanted to go to left to right, and this one I wanted to go from right to left, just like this. Now, if I grab both of these and change the person to whatever value, both of them are changing like this away from each other, right? Next thing that I want to do, I want to go down to transform and change the shear. You can see I can shear it like this to 50, for example, right? And the next one -50, just like this. I think that looks much better. You can see it. No, I want to add an image between them, so it looks more beautiful. At this image, I want to anchor it at top center, just like this. Choose the image. It's called Kraken. No, let's just change the position X and position Y to zero, so it will be at middle. I want the alignment to the X to be at middle. So 0.5 is middle. No, next thing that I want to do. I want to change the size to content. You can see it. No, I want to change the size to 150 by 150. Just like this. No, you can see a little bit of this health far is getting away. So what I want to do I want to click on it, the position X, I want it to be 50, a little bit inside. And for this one, click on it, change the position X to -50, right? Or we can just put -55. It is at the edge, it's better. So 55 for this one and -55 for this. No, I think that looks awesome. What I want to do next, I want to select both of these and change the color field type to green. So it looks more beautiful and it's showing the health, right? Now, with that, with selecting both of these, I want to make them as variable, just like this. After that, I want to go to graph. I have both of these progress bar. You could just name it, but it's not important. We can create a function for updating them. So I will call it update Health. Right? And with that, I want to get our progress bar, one of the progress bar like this and set a percent on. It set percent, right? That's set like this. And the in percent, we can just drag and drop it, put it over here. It is a value 0-1. So in our Kraken, when we update it, we should know that it is a value 0-1. We want to set the progress bar and progress bar 17 that we have over here to that person, both of them at the same time. Now, let's see how we can use it. For using it, go to BP Kraken at event begin play. We want to create this widget. So search for Create Widget, right? And the widget that we want to create is called WBPKraknHLth, with that, we want to promote it to a variable first. So I will call this health UI. Right. And after that, you want to add it to viewport, add to viewport, right, and that's it. Now next thing that you want to do, we want to update the health. And how we can do that, we can get the health UI and use the update health on it. And you know that the update health is value 0-1. So we can get our health and divide it by Max health. Just like this, divided by Max health, and it will give us a value 0-1. And that's what we need, right? Next, we want to use this function whenever the health of over cracking change, for example, in here, right? I wherever we get any damage, right? At the end of it, I want to paste that, and in both of these cases, I want to update the health, just like this. Now if you run over game, you can see we can see the health far. If you shoot at it, you can see, it's decreasing on both of them. So that looks awesome. It's working fine. 50. 49 Kraken Health bar Visibility: No next thing that you want to do. We don't want to show this crack and health bar whenever it's not chasing us, right? Whenever we are not close to it, right? So for doing that, first of all, at the beginning in here, we want to get our health UI. At the beginning, we want to set the visibility of our UI to be not visible, right? If we get close to it, it should be visible in that case. That said, No, I want to copy and paste this where I want to use it whenever we begin overlap with its sphere collision, right? So in here at the end, if we overlap with that sphere collision, we want to make it visible like this. And again, control to paste it over here. If we end overlap with that sphere collision, we want to make it hidden as well. Next thing, whenever the cracking get to be dead, what you want to do, we want to set it hidden as well. So control V to paste it over here and make the health bar hidden. But if the crack and health decrease by a bullet in here and the health is not zero, in that case, we want to make it visible again in here. So make it visible, connect it like this, and connect it like this to here. Now, let's see what will happen. If you head compile and run over you can see, there is no health bar. If you shoot at it, no, you can see the health bar, it's chasing us and if we shoot at it until it's dead, you can see the health war will go away. No health bar is showing whenever we shoot at it or get inside its radius. Again, let me run. Don't shoot at it. If we get close to it, now you can see, it's showing the health bar because we get close to it. No next thing that I want to do in here in this unbegin overlap whenever we go inside that sphere collision, we are making the health bar visible. But before doing that, I want to check if the health is more than zero, if the health of Kraken is more than zero. So get the health and check. If it is more than zero, check it with the branch, right? Just like this. If it is more than zero, you can make the health bar visible in that case. That's it. No over health bar UI is working fine. 51. 50 Kraken animation blueprint: No, we want to add some animations to over cracking. Right now, it's sliding, so we want to add animation. For doing that, I will go to Content drawer, go to crack and folder, go to Blueprint. And in here, right click because I'm recording it getting a little bit slow, go to animation, go to Animation Blueprint, and we want to create it for cracking skeleton, head create. I want to call it ABP cracking, right? Doll click on it to open it. And know in here, based on the speed of over cracking, we need to play we animation. So go to Asset Browser. You can see we have some animation, for example, dl, right? So for doing that, I want to create a state machine. So search for a state machine and I want to call it Locomotion or whatever you want to call it. I'll click on it to open it. And know in here the first estate that I want to create Adest I want to call it idle and the next estate that I want to create in here, Adeste I want to call it walk because we have just two estates. And no for the animations, go to idle. We want to put the idol there and connect it and make sure the loop animation is set. Now, go back and do it for the walk as well. Again, crack and walk, put it over here, connect it. Make sure the loop animation is checked, as well. Compile. Know about the rules. We wanted to go from idle to walk whenever the speed is more than zero, and we want to go from walk to idle whenever the speed is zero, right? So we need to get the velocity or speed of over cracking. So go to event graph. In here, we want to get over cracking, right? So I will create a begin play in here, event blueprint begin play, and we want to cast these pawn owners. So cast it to cracking, BP cracking, right, like this. And after that, we want to promote it to a variable. I want to call it BP cracking, right? No, down here, we want to get our BP cracker and we want to check if it is valid. So search for is valid. With that, if it is valid, we want to get its velocity. So dragon drop, search for get velocity. It is down in here, get velocity. We want to get the length of the velocity. Vector length X and Y is more than enough. No, we want to promote these to a variable and we can call it the speed. Or velocity or whatever you want to call it in case of valid, right? That's it. No, we have it. Let's just go to Locomotion. For this rule from going to idle to walk, we want to check. If the speed is more than zero, like this, if it is more than zero, you can go from idle to walk. But if the speed is equal to zero, we can go from walk to idle. Get the speed. And this time, I want to check if it is nearly equal to zero, right? If it is nearly equal to zero, with tolerance of five, for example, and connected there. That's it. Now with all of this done, we need to go to over cracking and put the animation blueprint there. So click on O mesh, and instead of just using one animation asset, change it to animation blueprint and change it to ABP cracking, right? That's it. Now with that done, if you run over game, if we go close in here and if we crack and move, you can see the feet of our crack is moving as well. And when it reaches, it will go back to idle. Just shoot it. You can see, we can shoot it as well. And now you can see the feats is working fine as well. That looks awesome. 52. 51 Kraken death animation: No next thing that you want to do we want to be able to play the dead animation. Right, no, we're cracking. Health can get the zero, but it won't play any animation if the health get the zero, right? So for doing that, let's just find the right animation, go to cracking folder, go to Asset, go to animations. And now you can see we have cracking death. If we don't click on it, you can see the animation. You can see when it get dead, it will play this animation. Now, for playing this animation, I want to do it with animntage so right click on it and create a animontage just like that. I want to create a new folder inside or cracking, new folder, and I want to call it animations, right. And with that, I want to put the animntage that we create inside that folder. Move it there. And with that done, let's just click on the nimontage. In here, you can see, like before, it's using the default slot and we want to use that, right? Now for putting this slot, in our ABP cracking, we can go to our anim graph and in here, search for a slot, default slot, we can just put it there, and that's it. Now, we can use it. Go to BP cracking in here. When the cracking is dead, we want to instead of saying cracking is dead, we want to play its animation. So in here, we can get over mesh, right. And with that, we want to play montage, right, play montage. And with that done, let's just connect the through to here. The montage that you want to play is called cracking Def montage, right. And connect these two here, and that's it. Now, let's see if it's working or not. If you run our game and shoot at our racken you can see, it's playing the deaf animation. Let's see what will happen. You can see it play the animation. But again, after that, it get alive and after that, chasing us, right? So that is a problem. So what you want to do in that case, first of all, we want to say to stay at the last frame of the deaf animation. Go to crack and folder, go to animations and open up the animontage one more time. And disable this enable auto blend out. If we uncheck that, it will stay at the last frame. If you run over game no, let's see what will happen. Make it die. You can see it's playing that animation, and it will stay at that frame. But as you can see, it's moving again. So that is a problem. You can see it's moving again. So we shouldn't let our behavior artery to move over cracken when it's dead. But let's just do it inside another video. 53. 52 move to decorator: No, when we cracking is dead, it's moving as well. So for fixing that, we should go to where behavior arteries clicking here. This move too, we wanted to prevent it from happening whenever we cracking is dead. So in here, we need to know if the cracking is dead or not. So we need to go to Blackboard and add another keotyp Boolean. And I want to call it is cracking. Dead, right? So we have the necessary variable, but we need to go to our BP cracking and set it whenever our cracking get to be dead and play the animation, right? In that case, we want to get our Blackboard, get the Blackboard and set a Boolean value. So search for bull, set value as Boolean, right? Let me organize a little bit like this. And in here, we want to set it as true. Because cracking is dead. Now for the name, I want to use a string to name in here, right? And the name, we should go here and copy it from here, head of two, control C to copy, and in here, control to paste, right? Now with that done, we know that it will be updated in Blackboard, right? No, our behavior artery, we can tell the move to note or move to task not to happen if or cacken is dead. And how we can do that we can right click on it and add a decorator to it. I want to create a blackboard decorator, right? That's it. I want to name it in here to move if Kraken was not dead. Okay? We name it correctly, but no, we should click on it and tell it how it should happen. So on the value change, we should be checking this, right? And what we want to abort on value change is the self. So we wanted this move to task to abort. When the value changed, a boat went to abort and went to continue in this in here, we want to check is the cracking dead? And we check it. If it wasn't set, if it falls, this is not set. It's like saying false. If it was false, you can continue. But if it wasn't false, it means our cracking is dead. This cracking will be true. So it will abort itself. Just like that. Now if you head safe, go to a level and run. Let's just shoot at it. Shoot it again, and now you can see it get to be dead and it won't be able to move at all. You can see it's not moving at all. We can shoot at it. Nothing will happen. That's it. No, we're cracking won't move if we kill it. 54. 53 Kraken Attack task: Know that we can kill our cracking, the crack and should be able to attack us, as well. Let's see how we can do that. For doing that, let me close some of this stuff that we don't need. We don't need this one for now. We don't need this ABP cracking anymore. Make sure you go to file, go to save everything. No, you can just close these ones, right, and close the cracking holf because it's working fine. Now in here, go to behavior tree. I want to use some other tasks. For example, I want to use a weight task. For example, let's say I want to weight 1 second by deviation, 0.5. What it means, it means randomly it will get a float value between 0.5 and 1.5, and it will wait for that time. Next, after waiting that time, we want to be able to attack. But in here, you can see there is no attack in here, right? So we need to create our own task. For creating a new task, you can just click in here and create the new task. I want to call it BTT behavior T task. Attack, right? That's it. Make sure you save it and it will open it automatically. Now, in here, we need some event. Click in here, and we want to first receive execute AI. So with this, whenever this sequencer, try to run the attack, search for BTT attack. What will happen? This event will happen inside this BTT attack. And in here for no, I want to use a printer string, right? And I want to call it attack, right? And after that, you know that this sequencer needs to know if these tasks get to be played successfully or not. So we need to finish the execution, finish finish execute, and make it successful. That's it. That's all we need to do. Now, let's just go to over behavior artery, and in here, or BTT attack should happen. But after this, because I don't want it to happen all over again really fast, I want to add another weight for, for example, five second by deviation of two. It's like wait like a random value 3-7. Choose a random value 3-7 and wait for that, right? Now with that done, if you head, save, and for you to see it better, I want to bring them closer. You know that the sequencer execute task from left to right. If one of them failed, the sequence will fail as well, and it will start over. Now, if you run over game in here, and make it a small. Let me make it a small like this. Go to behavior You can see it's checking the move to, but right now, because the player is empty, it won't do anything. It will fail, right? But if we shoot at it, let's see what will happen. No, the player is not empty. Player in Blackboard is not empty. So that's why the move to will happen and you can see it's happening until it reached the position that it should reach close enough to shoot at us, right? No, you can see it will wait. After that, go to attack. And after that, it will wait. After that, go to move to again, wait after that attack. You can see the attack at top left corner as well. When it get to attack, it will print a string for us. Can see it. That's cool. No, with this PTT attack, we wanted to actually play attack animation and after that, decrease the health of our player. Let's see how we can do. 55. 54 Kraken attack animations: Now let's see how we can make the cracking, attack the player. For doing that, I want to go to BP Cracken. In here, I want to create a event, a custom event. So search for Custom event, and I want to call this one attack. That's it. That's more than enough. For no, I want to use a printer ring, right, and I want to call it attack, right? And now go to BTT attack the behavior tree task. And in here, first, we need to get the control pun cast it to BP cracking, right. And after that, we want to run the attack event, right, and connect it just like this. Now, if you run over game and let's just shoot at it and go forward, again, like before, it should say attack, right? Just like before. But this time, we can play the animation, right? You can see it's saying attack every 5 seconds, for example. You can see it. That's it. Now where attack is working fine, let's just implement it. We don't want to use a print test ring. So in here, what do you want to do we want to play a montage, right? So search for play Montage and in the montage that we want to play, right now, we don't have anything. So create that, right? Go to crack and folder, go to Acid. We have animations folder, and in here, we have some type of attacks. Select these four types of attack right click on one of them, go to create and create nimntage for all of them. Now, I want to grab all of them and right and drop it and move it inside the animations folder, right? We want to use these type of attacks. So now, let's just choose one of them in here. It's called one of them, it's called a Smash attack montage, right? We want to give it the skeletal mesh of over cracking. No, with that, let's just compile, run, and no's just go forward to see if it's attacking us or not. Go forward. And no, let's just wait. You can see it's attacking us now. We'll see if it attack us again or not. You can see it's attacking us now, and that's perfect. But for making it safe, I want to create a variable, and I want to call it es cracking attacking, right? And the type of it, I want it to be float. So if the cracking wanted to attack the player, this attack will happen and we want to set the cracking cracking attacking to true, right? And when it gets to be complete, again, we want to set the cracking attacking. Set it over here to falls, right? That's it. No, at the beginning of all of this, we want to get is cracking, attacking, and we want to check it with the branch. If it wasn't attacking, we can play the attack, right? That's it. It's a fail safe. It shouldn't be any problem, but it fail safe. No, the problem with this is that it's just plain one animation, right? So what I want to do, I want to use a random array item. And with that, I want to promote these to a variable, and I want to call it Kraken attacks, right? So we put all of the rack attacks inside this array, and randomly, we get one of the montages to be played. How many one we have, we have four of them. So create four and choose. We have cracking, death, no cracking, smash damage. After that, cracking, sweep attack, two hit combo, right? Again, we have sweep attack. That's it. Next one is called Sweep Smash attack three heat combo. We put three other no, if you run over game, each time that cracking want to attack us, it will play another animation. It will randomly select between them. Sometimes one of them can happen multiple time. You can see, no, we have smash, we have sweep, you can see it, right? Everything looks awesome. It will be different. Sometimes it can be repetitive because they are mostly like each other. But you can see we are randomly selecting one of the animations to be played. No, cracking is attacking our player, but it's not damaging our player. Let's see what we can do. 56. 55 Kraken damage player: Now let's see how we can actually damage the player when the cracker attacking, right? We know when the cracking is attacking, right? So we want to use that to damage the character whenever the mesh of the cracking is overlapping with our player, right? So for doing that, I want to click on or mesh of the racken. Go down. And until you find the component, begin overlap, right? Now with that done, first, we want to check if the cracking is attacking. So check it with the branch, get this cracking, and check it with the branch, right, like this. If it is cracking, you can apply damage to other actors. So apply damage, right, if the cracking is attacking. And the amount, again, I want to use a random floating range like five to eight each time, right? That's it. No, I want to go to BPFPs, right? Go to Content folder, go to FPS folder. In Blueprint, open up the BPFPs. And in here, go to event graph, find a empty space down here, right click Search for event A damage, right? And I want to show it with a printer ring, right? Show the damage. That's it. No, I want to go to over BP Cracken. And in here, wherever we have a prints ring, we want to delete it. So we know that the damage from the cracking is just showing, right? Now, let's just head compile, run, get close to or cracking. Shoot at it a little bit, so it will come to us as well. You can see if it attack us, go to attack a state, it will attack us like six, seven, and you can see it, right? Now with that done, or cracking is damaging the character. No, the next thing that you want to do we want to have a health system for our player, some health UI. Let's see how we can do that. Next 57. 56 Player health and shield system: No, for the health system of our BPFBS, let's just go there. And in here, I want to create some variables. I want to have health and shield as well. So in here, create a variable, and I want to call it health. The type of it, I want to be float. Again, create another one. This one, I want to call it Max Health, right? Next one, I want to call it shield. And another one, I want to call it max shield. Let's say the health, I want it to be 50 again. Okay? The MxL, I want it to be 100. The shield, let's say it is 25, and the max shield is 100 as well. You can change these values, the max shield and max health values, and it will works. Don't worry about it. Now, with all of these, what we want to do, I don't want to just show it with the printer string. First thing to do, I want to check the damage that we are receiving in our player blueprint. And if the damage that it is causing us is more than the shield that we have, we want to decrease the health. But if it's not more than the shield, we want to decrease it from the shield, right? So now, in here, we want to check the shield. Get it. If the damage was bigger or equal to the shield damage, right? This true will happen. It means, for example, the shield is, for example, five, and the damage is six. So we need to decrease the shield by five, make it zero, and decrease the health by one, right? So first of all, I want to get this damage and subtract it from the shield, subtracted from the shield to see how many of damage should be absorbed with the shield. And after that, what it is remaining, we want to decrease it from over health. So get the health, decrease this amount that exist and save it inside the health again. Like this in case of True, right? And after that, you want to set the shield to be zero, just like that because we decrease that in here, right? Now, with that done, what do you want to do? I want to head compile. I wanted to show it to you. So in here, let me find the eventiqU here, I want to use a printer string. And again, like before, I want to use a format text, right? And I want to say health C on. Let me zoom in here so you can see it better. I'm holding control with middle most, I can zoom more, right? So you can see it better. Health is this much. I want to call it edge, right. And after that, hold shift head inter. So you go to the next line in here, you want to say shield is, for example, S, and that's it. Head inter. No, we can set the health in here and set the shield in here as well, right? No, with that done, we can just connect it to here. No, with that done, we need to expand this and give it a key. Doesn't matter what you put in there. No, for testing that, I want to decrease the shield to be like two, right? No. Let's just compile and run. You can see the shield is two. And the health is 50. First time that crack and attack us, the shield is a lot less. So it will decrease the shield and health, both of them together. Just look at it. The shield is zero, and the health is decreasing, as well as you can see it. That looks awesome, right? No next thing that we want to do we want to do the estate whenever the shield is more than the damage that we are getting inside our player. In that case, it's easier. We can just get our shield and subtract it by the value of damage, right, like this. And we can save it inside the shield as well after that and connect it to here. Now, for testing data we'll increase the shield to 25 and no let's runo game. Shoot at it, so it will get close to us as well. We have lots of shield, and it should be attacking us and decreasing the shield. Just look at it. 18125, and you can see the shield is decreasing successfully. Just look at it. Again, you can see the health is decreasing now. So everything is looking good. Now it's time to create a UI for it, right? No, we don't have UI for health and shi. 58. 57 Player health UI: No, let's just create or Health UI. For doing that, I want to go to Content drawer, go to Content folder, go to AI crack in, and in here, go to Widget. Right click in here, go to user interface and create a Widget blueprint of type of user Widget. I want to call it WBP Health, right? That's it. I'll click on it to open it. Like always, first thing that I want to do in here, I want to add the Canvas panel. After that, I want to create the background of our Health UI, so I will use a board like we did that for the MoUI, right? We want to create that kind of background. First of all, the anchoring of it is good because I want to leave it at top left corner. Next, the positioning of it needs to be 50 by 50. So it will have some space in here and here, right? Size 6100 is good, but size Y, I want it to be 300, right? That's it. Now, I want to get rid of all of this padding. So put all of them to zero like this. Next, I want to change the tint color to a black color and change the off of it to 0.5, right? That looks awesome. No, I want to go here, change it from the image to rounded box. Don't worry about this. The rounded type, I want it to be fixed radius. Now you can see it. I want to use thrush transparency as well. And after that, the heat, I want to put it on one. Now for the corner radio, I want to put all of them to ten, like we did it before. That's it. If you click in here, click away, you can see it better. Now, for the color of the outline, I want to put it on white. Just like that. No, if I click away, you can see it. We have a good background. I want to have the health bar over here and have the shield over here, right? So for doing that, I want a horizontal bar. To stack them at side of each other. Next, I want two vertical boxes. Why vertical? Because I want to have progress bar like this in here and image benefit to say it is health and another progress bar in here image benefit for showing that it is shield. So for doing that, I want to have vertical boxes, two of them, add two in here, and you can just select both of them withholding control and tell it to fill everything 50, 50, right? That's it. No, with that, the first one I want it to be for health. So let's just add a progress par to it. Just like this, you can see a top there. No, click on the progress board. I want it to fill everything, right, top to bottom. And if you change the person, you can see it is from left to right. I want it to be from bottom. Top, just like that. You can see. That's for our health. Next, I want to add an image. So add an image to this vertical box, and you can see the image down here. So click on the image, search for Plus and put it there. You can see it. I want this to feel as well. But the progress part, I want to feel 0.9 like this and the Image wanted to feel like 0.13, right? Now, for the field color of this, I want to click in here and change it to something green like this. I think that looks good. And now, you can see if I click away, you can see it is outside of our background. So that's why I want to click on or progress board and add some padding to all direction like five. Just put five there. We expand, you can see all of them. No it's five. That I think looks awesome. No, we want to do the same for the vertical box. So select everything, right, click, copy, and go to this vertical box, right, click paste, right? That's it. Just what we want to change in the image. We want to change it to shield texture, just like that. And the color of the progress bar, I want to change it to something bluey, like something like this, right? And no for the images. For example, both of these images. Just hold control, select both of them. First thing first, I want it to be at middle like this for both horizontal and vertical. Next, I want to add some padding from left like five can see from right, five as well, and from bottom five as well. Now, you can see it looks much better. Now for the coloring of it. I want to save this color like this. We can just save this color by dragging and dropping it over here and save this color, clicking here by grabbing it and put it over here. Now we are saving the colors, and we can put it for this one. For example, the tint color of for this one, I want it to be the screen, Head okay. You can see that looks awesome. And this one, the tint color of it, I want it to be this one. So that looks awesome. Now, let's just head compile, save. Let's just go to our BPFPs and implement it, right? So in here at this begin play execution path, I want to create over widget, create widget, right? And the widget that you want to create it's called WBPHLF and we want to promote it to a variable. I want to call it WBP health as well. And we want to add it to Viewport. Add to viewport. That's all we need to do. Let's just head compile and run over game. Now, you can see the health bar there. No, it's time to actually update the health bar. Right now, the health bar is not updating, but it does look good, right? Let's see how we can update it in next video. 59. 58 Update health UI: No, for updating the health UI. Let's see how we can do that. For doing that, we need to go to WBPHLP. And in here for this progress bar, we need to name it Health bar, call it something meaningful. And this progress bar is called Shield bar, right. And make sure you hold Control, select both of them and make them variable by checking is variable. After that, we will have access to them inside the graph. And inside the graph, you want to create functions for them. So create a function for updating the Health, right. And with this, we want to get the health bar like this and set a percent on it, set percent, right, and connect the execution pin, and for the input, we can just connect it like this. And we can just copy and paste this, create a function for updating the shield, update shield, right? And paste it over here, connect the execution pin this time. We want to update the shield part. So drag and drop put it there, and for the in person, just connect it like this. Now, we have two functions, one for health and one for shield. Let's see how we can use them. Go to BPFPS in here at the beginning, let's just get the WBP health, and with that, we want to update the health update health and connect the execution pin. For the in percent, we know that it is a value 0-1. So we should get our health like this. Divide it by Max Health, it will give us a value 0-1, right, divide by max Health. This will update the health. Next, what you want to do Control C control, paste it over here and update the shield this time, right? So for doing that, connect it over here. Again, like we did it over here, we want to get the shield like this and get the max shield like this. And divide them by each other, right, like this and connect it to in percent. Now, let's just look at it. The health is 50, so half of it should be full and the shield is 25. Like 25% of our health should be there. And you can see it's updating. Now what I want to do first so let's just go and lead this printer string. We don't need it. We have a UI to show it, right? Now I want to select all of these, right click on one of them, and collapse a two function for updating, update Health, right? Now with this function, wherever we are decreasing or increasing the health, we want to update the health UI, right? So for example, in here, we want to use update health. And in both of these cases, the update health, we want it to happen. Let's see if it's working fine or not. If we shoot at the cracking, so it will go to us and we run toward it. Let's see what will happen. It should attack us. Look at it. When it attack us, it will decrease the shield first. You can see it is decreasing the shield. And after the shield is finished, it will decrease the health. Just look at it. You can see it's working fine. Whenever it hit us, the shield and health is decreasing. So everything is working fine with the updating the health. 60. 59 Item type: Know our health and shield is decreasing, but we need an item for bring it up for increasing it. So for doing that, I want to go to Content drawer, go to Content folder, FPS folder, blueprint and open up the BP item. Now what I want to do. I want to make it customizable, so we can put that in our level and we should decide what it should be. There should be health or shield or ammo, right? So for doing I want to create an enumeration for that. So right click in here, go to Blueprint and create a enumeration. And I want to call it E item type, right? Just like that. Double click on it, open it. I want to add enumerator in here, so one, two, three. The first one I want it to be Amo, right? The next one, I want it to be shield, and the next one I want it to be health. That's it. Make sure you save. Go to BPM. I want to create a variable. And I want to call it item type. And the type of it, again, I want it to be item type, that enumeration that you create together. So type of it, I want it to be E item type, right? And I want it to be instance editable and expose on a spawn. And by default, let's say it is health, for example, right? Head compile, no. If we go and one of them, find one of them that is in our level, for example, this one, right? Let me put it in front of our player. This one, you can see, I can say, what is the item type. For example, B shield or Ammo or whatever, we can decide that over here. And based on what we decide in here, the representation of it, this no graphic, I wanted to change as well. So for doing that, I can go to construction script in here. I want to get the item type that we choose and I want to use switch on it, right? So switch on it. If it is amo, what we want to do we want to get our no graphic component over here and set Niagara system acid and connect the ammo to it. In this case, we want to set it to NS Amo copy and paste it again. This time, we want to do it for the shield. So we just change this to NS shield, right? NS shield. Next, Control C Control V to paste it over here, and this one, we want to do it for health, right? So change this to NS health. That's it. No, I need the target as well. So connect the target here. Now, if you compile, go to our level. You can see if we change them to health, it will be health. And if we change them to ammo, it will be ammo. Again, if I duplicate this and change the to, for example, shield, it will show us the shield. Now you can see we have items, right? Cool. Now let's see how we can pick them up. We will do it next to. 61. 60 Item pickup: No, for picking the shield half and ammo and all of that, let's see how we can do that. Go to BPFS. If you remember, we done it for the ammo, right? I want to disconnect this from here. We want to do it for AO. So let's bring all of this where we update the MOUI and add the storage ammo, right? Now with this BP item, we can get the item type first, get the item type, and with that, we want to switch on it to see which one is it, right? If it is ammo, what we want to do, we want to increase the Ammo storage. Just like that, the ammo should works fine, right? Let me put all of these, for example, up here, so we will be organized, and after that, we destroy the actor, right? Next, we want to do it for shield. If it is shield, again, we want to get the amount amount of shield that you want to add, just like that. Let's just put it over here. We want to add it to shield the shield and add this to it, add this to it, right after that, save it inside the shield like this and connect the execution pin off shield to it, and after that, we want to update the health. And with that done, after that, we can just destroy the actor. Next thing, we want to do it for the health as well, exactly the same. We get our health like this. And we add it to the amount that the item provide. So search for amount, get amount, and add it to the health like this and save it inside the health again like this and connect it to the health. And after that, update the health as well, and connect it to here. To destroy it afterwards, right? No, let's just say that too. If you run over game, you can see if you go onto ammo item, you can see the ammo is increasing. If we go above the health, you can see the health is increasing and for the shield, you can see the shield is increasing as well. But the next thing that we want to do in here, it's really important to not go more than a certain value, right? So, for example, let me make some space. If the health get more than Mac self, si check it. The health get more than Max's health, right? We want to check it with a branch like this. And after that, if it is more than Mac health, we want to set the health with the Mc self. So we don't want it to be increased more than Mac self, right? In case of true. After that, we can update the health. In case of false, we can just update the health UI. The exact same thing that we done in here, we can just copy it and do it for the shield as well. So make some space. Control V to paste all of that in here, or a space like this. Connect the execution pins, we will replace everything that is necessary. This time we are checking the shield, so connect the shield in here. If the shield was bigger than Max shield, just like that, we want to change the shield like this to Max shield. And in case of falls, it means this shield is less than Max shield, and update health should happen. That's it. If we head compile for testing that, what I want to do I want to grab one of these, grab one of these items, and I want to hold out drag. And this time, I want to put like 150 really big value. And for this health, I want to hold out again, drag. And again, in here, let's just say 150 as well. Now with that done. We shouldn't allow it to get more than 100 because the max health is like that. Now, if you go here, look at the health, health is increasing. But if you take this one, you can see health is at 100. No. Again, if you take this, this will fill up health and shield. Now, if the cracking attack us, what will happen? It will be decreased. You can see it will be decreased from 100, not more than that. Let's just wait until it hit us. Again, you can see when it attack us, it will decrease the health again, you can see, no, it is decreasing the health. The health and shield, it didn't increase more than 100, more than Max health. No everything is working, fine. We have some item. 62. 61 Game over UI: No next thing that you want to do, we want to create a UI for or player get to be dead. So let's see how we can do that. For doing that, I want to go to Cont DrR, go to Apis, go to Widget, and in here, right click, go to User Interface and create a Widget blueprint of type of user Widget. I want to call it WBPGame over, right? Don't click on it to open it or head inter to open it. Now in here, what I want to do, there is a thing in here that is called background blur. Search for it. Just put it there, and know with that, we can change the strength of blurriness of background, right? That's it. No, I want to add a text there as well. So find the text, put it there. I want it to be at middle. So click in here and click in here to put it at middle. No, I want to go to font, make it bigger like this. And I want to say game over, right? That's it. No, let's just he compiles, save. And no with that down, let's just go to BPFS where we are decreasing the health over here, we want to check the health after updating the health UI. Check the health. Is the health is less or equal to zero. We want to check it with the branch. It means our player is dead, right? So let's just connected there. If these less than zero, what do you want to do? We want to create or widget, create Widget. And the widget that you want to create is game over game over WBP, right? And after that, you want to add it to viewport. Next thing that you want to do, we want to sit input mode to UI only. So the player can't change anything after that. It needs a player controller, so we can get the player controller, just like that. After that, in get to be focused, we want to focus on this widget that we create and flush the input as well. After that, I want to create a timer like this timer set timer by event, right? Let's say after 3 seconds, we want to restart over game, right? So we need a custom event for it, custom event. I don't want to call it reload level. Right. And with that done, what we want to do we want to open level, right, by name, and the level that we want to open is called New Map, right? That's it. That's all we need to do. Let's just head compile. I want to decrease the help for no, like ten and decrease the shield as well to eight, for example. So it will kill us much faster so you can see the effect. Let's just take this one and no let's just go to it, shoot at it. So it will find us much faster, right? Go forward. Let's just look at it. When it's hurting us, you can see the health is decreasing. No, let's just wait, and that's it. It will say game over. And after 3 seconds, it should open up the level. Again, congratulations on finishing this course. If you found any bode or you want me to create or add more video to this course, you can just leave it in question section or in this course channel, thank you. Thank you. Thank you very much for watching. 63. 62 Fottstep sound: No, the last thing that you want to add is walk in sound. So let's see how we can do that. For doing that, we need to do it inside the animation. We have walk animation. Let's just open that. In walk animation, you can see, in this case, and here we want to play the walk sound. But for doing that, I want to go to Content drawer, first of all, go to Assets, go to Ft Step sound. You can see there is lots of them in here. We want to use all of them. No, I want to go to FPS in here, right, click create a new folder, and I want to call it sound, right? In here, right click, go to audio and create a metasund source. I want to call it s foot step, right? Foot to step. And inside it, we need a wave player. So search for wave player, right, because you want to play a wave, right? And connect it like this. No, choose over wavefacetF example, this one, right? Now, if you play, I hope you can hear it, but there is a walking sound, right? Every time that it get to be played it's finished, we want to finish executing the metasund so all the resources will be free. No. Again, you can see we can play it, and after the play finish, it will go to unfinished. Now, we have lots of sound, but we are just playing one of them. How we can randomly select one of them and play it over here. We can just drag and drop the promoted to a graph variable, and I want to call it sounds, right? And I wanted to make these sounds array so we can have multiple of them. No, I want to fund the sounds in footsteps, dock it over here. Like this. Now with that, again, select everything, draw dry and drop, put it over here, and know it's putting it all inside this area automatically for us, right? Now with this sound, we want to randomly random get one of them each time and play it as wave act, right? So we need to connect these two next and connect it like this, right? And for the seed, we can just put a value there, so it will randomize it more. And that's it. This is our sound. We want to add it to or what? For example, let's say one of them in here because our player doesn't have any food. We need to just put it after that, see if it sound good or not and after that, change the position. So play a sound and in here, the sound that you want to play is called MS footstep, right? And that's it. Now again, for example, here, we want to play another one. So go to add Notify play sound. And this time again, we want to play MS footstep, right? Now, let's just play it. That's it. You can just play with this until you reach the result that you want. That's cool. No, we done it for this one. We want to do it for Sprint as well. So in a sprint in here, for example, right click, play a sound. And the sound that you want to play is called S footstep, right? And at the end, let's just add another play sound. Okay? And we want to play MS, foot a slip, as well. That's it. Now, let's just de out. If you run over game, let's see what you have you can see. Now, we have a foot a slip, and I think it's working good, right? 64. 63 Input not working after reset: I need to add a fixing here. The problem is that when we get to be destroyed, let's just say. When we're cracking, destroy us, let's see what will happen. Let's wait. And the game over after 3 seconds, it will be restarted, right? But no, we can't move at all. That's a problem. Let's see how we can fix that. For fixing that, I want to go to Blueprint, open up the BPFS and at the begin play in here, at the end, we can set the input to game only, right? And it needs a player controller. So get player controller. And no with that done, let's just run over game. If we go and at this, let's wait until it destroy us. Now, you can see it did kill us after 3 seconds. What will happen, we can move now. So this was the first boy that we found and fixed.