Build a 2. 5 D Game in Unreal Engine 5 | Hyper Dev | Skillshare
Search

Playback Speed


1.0x


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

Build a 2. 5 D Game in Unreal Engine 5

teacher avatar Hyper Dev

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.

      Overview Video

      5:40

    • 2.

      001 Get Unreal Engine And Start The Project

      2:43

    • 3.

      002 Setting Up The Developer Level

      5:12

    • 4.

      003 Installing Paper Zd And Make Developer Level Load On Startup

      4:32

    • 5.

      004 Adding A Player Character To The World

      8:23

    • 6.

      005 Importing Art into Unreal Engine for the player character

      4:43

    • 7.

      006 How To Set Up A Simple Idle Animation And Manage Sprites And Flipbooks

      9:57

    • 8.

      007 How To Plan Out Your Game

      5:08

    • 9.

      008 In Depth Explaination Of How To Add Controller Inputs

      18:03

    • 10.

      009 Left And Right Movement With Keyboard And Controller

      8:15

    • 11.

      010 Add Constraint, Fix Stick Drift And Set Player Position

      2:36

    • 12.

      011 Setting Up Paperzd For Animation Managment

      10:38

    • 13.

      012 Play The Idle Animation Through Paperzd

      5:29

    • 14.

      013 Play The Run Animation Through Paperzd

      6:35

    • 15.

      014 Changine Sprite Direction Based Off Movement Direction

      4:51

    • 16.

      015 Adding Running Audio Files

      9:18

    • 17.

      016 Adding Spatial Running Sound When The Sprite Foot Lands

      10:38

    • 18.

      017 Using Comments To Organise Blueprint Nodes

      0:18

    • 19.

      018 Control Setup And Code For Adding A Jump

      5:11

    • 20.

      019 Adding A Jump Start Animation

      4:36

    • 21.

      020 Jump Animation Transitions Logic

      7:02

    • 22.

      21 Jump Start Sound

      5:48

    • 23.

      22 Jump Landing Sound

      4:51

    • 24.

      23 Adding Platforms For Platforming

      4:38

    • 25.

      24 How to Customize player movement and jump

      6:55

    • 26.

      25 Adding Platformer 3D Platform Assets From Quixel

      4:50

    • 27.

      26 How to add assets from unreal engine store for your environemnts

      1:29

    • 28.

      27 Adding Assets Part 2

      4:24

    • 29.

      28 Watch me do some basic level design and how I think about basic levels

      21:51

    • 30.

      29 Share Feedback Teachingand Learning Quality

      1:19

    • 31.

      30 Course Progress knowledge check

      4:17

    • 32.

      31 Resetting The Developer Level To Clear

      3:28

    • 33.

      32 Creating A Simple Health System Part 0

      2:28

    • 34.

      32 Creating A Simple Health System Part 1

      3:04

    • 35.

      33 Creating A Simple Health System Part 2

      10:09

    • 36.

      34 Creating A Simple Health System Part 3 Adding A Damage Object

      13:18

    • 37.

      35 Checking if the player is alive or dead on taking damage

      3:57

    • 38.

      36 Making a death screen user interface

      15:59

    • 39.

      37 Adding The DeathScreen on Death

      5:12

    • 40.

      38 Adding Functionality to the Death Screen

      5:59

    • 41.

      39 Adding Player Attack Inputs

      3:56

    • 42.

      40 Creating A Combat Dummy Part 1

      20:26

    • 43.

      41 Making A Player Attack Part 1

      14:45

    • 44.

      42 Making A Player Attack Part 2 Code Changes

      11:00

    • 45.

      43 Player Sword Attack Animation Part 1

      7:22

    • 46.

      44 Player Sword Attack Animation Part 2

      5:29

    • 47.

      45 Air Sword Attack Animation

      5:44

    • 48.

      46 Using Custom animation notifies for sword hitbox

      8:35

    • 49.

      47 Adding More Attack Animations For The Combo System

      15:49

    • 50.

      48 Getting Started With Input Buffering

      9:44

    • 51.

      49 Setting Up The Basic Combo With Hard Input Lockout

      12:37

    • 52.

      50 A Brief overview before more integration of the combo system

      3:28

    • 53.

      51 Adding Attack Link to first Sword Attack

      15:14

    • 54.

      52 Adding Attack Link to the second Sword Attack

      8:59

    • 55.

      53 Finalizing Combo Links and Resets For The Grounded Combo

      19:55

    • 56.

      54 Checking if player is aerial for sword attack routes

      8:36

    • 57.

      55 Setting Up Animation Blueprints For Air Combo

      8:20

    • 58.

      56 Setting Up Air Combo Logic

      9:39

    • 59.

      57 Polishing The Air Combo Logic

      18:25

    • 60.

      58 Detecting the player in range

      8:50

    • 61.

      59 Make AI Move towards the player

      7:04

    • 62.

      60 Adjusting AI Movement Towards the player

      11:59

    • 63.

      61 Adjusting Sensing Component and some theory crafting around timing

      6:04

    • 64.

      62 Adding A Visible Sprite To The Melee Enemy

      6:48

    • 65.

      63 Adding in Walking Animations in PaperZD

      9:14

    • 66.

      64 Adding Melee Enemy Attack Sprite

      4:50

    • 67.

      65 Melee Enemy AI Overview And Code Comments

      7:59

    • 68.

      66 Adding Damage Hitbox For Melee Enemy Attack

      11:32

    • 69.

      67 Linking Attack Animation with Code For Melee Enemy

      13:59

    • 70.

      68 Adding Attack State Reset Function

      10:01

    • 71.

      69 Stop player from being able to run through AI

      1:53

    • 72.

      70 Nerfing the Melee Enemy AI

      3:34

    • 73.

      71 Death Animation for AI and some logic theorycrafting

      6:04

    • 74.

      72 Making AI Health Bar Visible And Some Adjustments before moving forward

      3:59

    • 75.

      73 Melee Enemy Hitstun and Death all in one

      11:29

    • 76.

      74 Setting Up The Ranged Enemy

      2:59

    • 77.

      75 Simple Idle Animation for the ranged enemy

      6:22

    • 78.

      76 Spawn a projectile that goes to player location on launch

      13:27

    • 79.

      77 Setting Up Animation Blueprint For Ranged Enemy

      12:23

    • 80.

      78 Linking Throw Animation with Projectile Spawn

      7:12

    • 81.

      79 Adjusting Sprite Direction to player location

      4:42

    • 82.

      80 Adding Sprite To The Magic Ball

      3:09

    • 83.

      81 Changine Direction Of The Magic Ball

      9:03

    • 84.

      82 Setting Up Hit And Death Animation Combo

      6:37

    • 85.

      83 Ranged Enemy Enters Hitstun on Taking Any Damage

      10:05

    • 86.

      84 Setting Attack Delay After Taking A hit

      11:41

    • 87.

      85 How to Prevent your enemies from getting stuck on each other

      1:47

    • 88.

      86 Creating An Attack Range For the Ranged enemy

      3:46

    • 89.

      87 A look at the level

      4:57

    • 90.

      88 Making Player Sprite React To Light

      3:17

    • 91.

      89 General Touches For The Level

      10:07

    • 92.

      90 Make A Boss Enemy As Your Final Practise

      4:28

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

7

Students

--

Projects

About This Class

Made for absolute beginners getting into Game Development Unreal Engine. Learn how to create a 2.5D platformer in Unreal Engine.

Platformers are one of the best ways to get into game design. Learn how to get a platformer up and running in a fully playable state. You will go from a blank project through all the steps a good game developer takes to make a fully playable game.

The pacing is set just right so you never get confused or go into a topic without the right amount of knowledge.

Through the course you aren’t just going to make a copy paste of what I make. Instead, I’m going to teach you how to think like a game designer so you will be able to create the games that you want to.

My hope for you is that after this course you will go out and finish the game idea that you have had on your mind and launch it. As an avid gamer myself, I can’t wait to go on the journey you will create.

For anyone coming from UNITY ENGINE, this is the right course for you. It teaches everything you need to get up to speed using blueprints to create the games you want to make. Built by a company run by Game Developers.

Good luck.

Meet Your Teacher

Teacher Profile Image

Hyper Dev

Teacher

Join me for some learning on how to make production ready games. Tutorials that give you the full scope of what you need to do to get a game totally ready for release.

They are made for people going from being a hobbyist to a professional game developer who wants to earn a living by selling games.

See full profile

Level: Beginner

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. Overview Video: I love 0.5 d games. There's something about having the two D art style while being able to interact in a three D will. So this is a quick overview of the 2.5 d game development cost. We cover a lot of what you're going to learn so that you can go from, you know, seeing things from the small scale to the larger scale of game development as a whole. So the first thing you're going to learn fundamentally is going to be my simple four step process for designing and creating things for your game. Basically, it is designed, create the art, and then adding the audio. That's going to be the core of everything else that adds up and how to create and implement a two D character with movement and then some combat. So with this character, it's able to perform a three hit combo, including air combos, as well. And when you build the character out, you're going to learn how to set up the controls for PC so that you can control the character using mouse and keyboard. And on top of that, you're also going to learn how to create these character controls using a controller as well. So you'll have those two options. And all of these features are going to be built on top of unreal engine and using the blueprints system so that all you need is a basic understanding of logic, and you will be able to create the character. Now, the cool thing about blueprints, right, is that you're going to be able to quickly make changes to your code. And in case of anything, you can easily see the code alive in real time. So now, anytime I perform an attack animation, I can see which line of food is being called. This is a simple example of a three hit attack. So I can tell when the fast attack is being called alone, or when the player has pressed all three attacks, and it's fighting, rather it's firing off the entire combo, and you will learn this in the tutorial as well. Now, before talking about some of the other features in the tutorial, one thing that I love about learning is clarity. I wasn't happy about a lot of the other tutorials that I myself purchased when I was learning game development. But don't worry this time, there's going to be a lot of clarity for this one. So one thing you're going to see a lot is a lot of zooming in. So what that means is a lot of the time, I'm going to zoom in exactly on where my mouse is, and I'm going to show you specifics about what it is that I'm doing so that you can gain a pretty cool and clear understanding of everything I'm changing. Every variable, every time I turn a dial, there will be some zoom in to give you the exact clarity that you need to know exactly what I'm doing. I also like to keep my explanations very clear and contained. But now moving on, also going to learn about enemies and enemy AI. Oh, look, there's a ranged enemy. One of the things you're going to learn is how to get enemies and create them that will do damage to the player, including ranged enemy that attacks from far and a much more close range enemy that does damage to the player by walking up to it and attacking. But it's not just about being attacked by enemies. You're also going to learn how to give enemies heads start so that when they take damage, they can die. So our player has the ability to fight back, which is cool. So enemies are coal and all, right? But another thing that you're going to have to do is level design. So I'm going to teach you step by step on how you're going to be doing proper level design and making levels that makes sense for players to use, as well as the basics of how to bring in assets into unreal engine and how to utilize them and make different changes to lighting and environment. Okay. And when you're done learning all that, you're going to end up in a final project where you're going to create a boss character that you're going to use for your own games. And once you create that character, you would have fully learned everything you need to know about 2.5 d game development. So that covers pretty much everything you're going to be learning in the tutorial. I wish you good luck and make sure to take your time, learn everything step by step, and hey, your dream game isn't going to make itself. I wish you good luck and you'll find me in the next video. Let's move forward. 2. 001 Get Unreal Engine And Start The Project: Alright, so to get started, we need to make sure to get the basic stuff out of the way. You're going to need NRL Engine 5.4. Simply get the Epic Games launcher. Make sure you download UnreLEngine. You can go to library. And from inside the library, you know, basically, you have the option to pick different engine versions, you know, get the late. Okay? You don't need anything else. Just get the lats. The latest as of recording is 5.4. I've organized the blueprints to make sure that they will work with any version of Unreal up to 2025 at the bare minimum, they very rarely change blueprint code, since it is just C plus plus collected up. Once you have that done, launch the engine, and once you launch it, you're going to come and click over here on Games. So it's going to ask you to, you know, set up your game project. Now, set it up as a blank project. We do not want to start with any template files. Let's start from a blank slate. And then on the right side, Make sure that the target platform is desktop and then set it up for blueprint. If you click CiplusPlus we'll have to do a lot of C plus plus writing, but it is much faster to start off from here with Blueprint code. It's much easier to get started with it. As far as quality presets, these aren't very relevant. You can leave them as is. You can leave out starter content, and you can leave retracing off for now. We won't really need tracing for this project, and it's very graphically intensive. With all of that setup, simply come down here and select your project name. I'm just going to call it updated videos for 2.5 d platform because here all of these videos are being updated from the original ones in the course, and then you can decide on the project name. I am going to call it 2.5 d Oh, I can't put space bars. No, I'm going to call it a hero's journey. Yes, that's going to be what I call the project. With that setup, we can now get into unreal engine. 3. 002 Setting Up The Developer Level: And once Unreal Engine has booted up, this is what you are going to be greeted with. So the first thing is, let's close that content browser window and have a look around at how Unreal Engine lays things out. So you'll notice in the top right corner that's our project. Then we have a big screen in the middle that is our editor window. This is our viewport, our look into the world that we are going to create. If we click inside it. So right now, I have clicked inside of it. You can look around using your mouse after holding the right mouse button. So you can see my mouse there. I'm holding the right mouse button, and I can look around. And then using WAS D, I am going to be able to move around from inside the world. So now that we have our mouse button, we can use W A to move to the left, to move to the back, and D to move to the right. So with those two, we can basically fly around the world. Okay. But this is a big world, and we do not need a large open world. And depending on your PC, your PC might even be stressed out. So let's remove this open world so that we have something a bit more plain for us to use when we get into this project. Now, to do that, all we have to do is we're going to need to create a new level. Now, to create the new level, what you're going to do, is you're going to come over here to the top left corner to the top left corner, we're going to click on File and after clicking on file, we're just going to create a new level. Now that's going to open up a couple of options for us. We can create an open wild level. We can create a basic level. Click on Basic. We just need to set up a basic level. Ah, perfect. Now that we have this basic level, I'm going to move back. Notice that all it is is this single rectangular object here. It is a skybox. We can look around. There is a nice sun, and there are clouds ready for us to use and start our game from. This is the good starting point we need. But now that we have created our level, we are going to need to save it within our content. So what do I mean by content? If you come in and you press Control and space bar at the same time, it's going to open up a content browser. Okay? Now, inside of that content browser on the bottom left, notice that it's showing us content. So click on that. That's all of the files that you will use within your game. And then we want to create a new folder. And let's call that folder levels. Okay? So now we have our levels folder here. Now, we just want to save our current level, right, this plane level into that folder. Notice anytime you click away, you need to press Control and space bar once again to open it up. Now, to save that level, we'll go back up to where we can select File, and notice there is the option to save current level as. So let's save current level as. Okay, it opens up the window. We'll go into levels, and let's simply call this I like to use numbers when I'm naming levels. Now, the level we are creating is going to be the developer level. So I will call it zero, zero, zero, a space. Oh, yes, a dash and developer level because this is the level we are going to use to basically create all of the things that will go into the game. Now, we have our developer level ready, but there's one last thing we need to do. We need to set it up so that when we start Unreal Engine, we get into this exact level, and we also need to set up paper Z D which we are going to use because it will help us deal with two d sprites easier. Let's do that in the next lesson. 4. 003 Installing Paper Zd And Make Developer Level Load On Startup: Now right after we have set up our initial level, we are now going to add in a plug in, so close real engine and go back to the Epic Games launcher. Go to the marketplace and once you are at the marketplace, we shall simply search. The search terms that I use is Z and D. Right? And you should immediately get paper Z, actually, which should be paper Z D, paper, Z, and D. So those are the search terms I'm using. You can see paper Z D has come up, and this will pop up. And it's saying, Hey, paper Z D, and all you have to do is click on Install to Engine, and it's going to ask which engine you want to install too. Of course, install to your latest engine that you selected. It's a reasonably small download, only 71 megabytes and then it's done. And now after some time, the download should be done. It's fully installed to Engine. It might not show so here, but we can go to library, and we are able to check, let's see, installed plugins. It's showing you Quicksabidge and paper Z D. That's perfect. Simply close that out, and then we can launch Unreal Engine. Now, once you're back in UnreL Engine, it's actually notifying you that, Hey, there's a new plug in available. So I'll just go to manage plugins. I'll type in Z D here. So UnreL will search, and there we are. We have the paper Z D plugin. And it's going to say, Hey, just restart for the editor to make the changes and just restart UnreLEngine again. Perfect. Now, the engine has restarted and this plugin is now working. But notice that once we jump back into Unreal Engine, it's now showing us this open level, which is not what we want. We want our actual developer level to be the first thing we see when we boot into Unreal Engine. To solve that, go to file, go to Edit and then go to project settings. Then what you want to look for, let's quickly it's frozen. I'm going to give it 1 second. Okay, it has unfrozen. So what you want to look for is I'm going to type the start term starter. Okay. So that's the term I used to search. But essentially, it's going to show you the options of, hey, Editor startup map, and right now it's set to OpenWorld. So you can simply click on that, and there we have our developer level, so I'll set that to developer level. Okay. And now that I'm done with that, I am actually going to close this and I'm going to restart Unreal Engine once again. All right. So now I have loaded back into Unreal Engine, and here we are we are now in the developer level. So now it is properly set up. You have the plugins. You have your nice I'm pressing. I'm going to press Control and Space bar, and notice you have our nice content with one empty level, not entirely empty, but it's a good starting point level, and we are now ready to start adding in some gameplay elements. We'll start by adding in one gameplay element, which is going to be the player character. Then we'll go through a bit of planning and game development philosophy. Although that's going to be a very short video, it won't be too long and then we'll get back into this developer level and start crafting the components of our 2.5 d platformer game. Let's do that in the next video. Let's go. 5. 004 Adding A Player Character To The World: All right. Now that we are inside of Unreal Engine, we have our baseline level setup. We are going to add in the very first object. And just to make sure that it's something that is truly important, we will start by adding in a player character. So to add in a player character, we're going to keep it really simple, okay? All you have to do is you're going to need to press Control and space bar to bring up that menu, okay? Now, once that menu is opened up, we want to under content. We want to come here and we are going to create a new folder. Just to keep things organized, we've created a new folder. Now, to keep things organized, I am going to press F two after selecting and I'm going to call this characters. Okay. So we have one folder for levels, another folder for characters. I'm going to double click into the character folder and I'm going to create another folder. Now, this folder, we are going to call it player. That's essentially it because it is the hero's journey and we are going to have a player character that we will use in the world. I'll double click inside of player, and then I am going to actually right click and I want to search for blueprint class. It's going to give us some options. Now, among the options, you'll notice there is character, there is pan, there is actor. Simply go and select a character. Okay. Now with that, it has created for us a little file here, a blueprint. I'll select it F two again, and then I'm going to call this hero. Right? Now, we know that hero is going to be our player character. Next, we are going to put this hero into the world. I'm just going to click and drag it into the world. And, boom, there it is. This simple object that is actually totally invisible is our current hero. Now, since we are using a blueprint, any change to one blueprint changes everything. Now let me click on the Hero again. Right now, all it is is a basic capsule that's invisible. Let's add an object to it. I'm double clicking on hero. Notice it's loading up a totally different window. I personally prefer for it to not be on a different window. I click on that, I drag it out, and I drag it here. Now I can go from the developer level over here back to the hero blueprint, okay? Now within the Hero blueprint, there are some things we can look at. On the right is some details. We have the details here, and it also has a couple of different elements that we are going to be using. That basically alters things about the character. And then on the left side, we have components. Components are all about the different parts of the character. Now the baseline character component comes with a capsule. A capsule is this object over here, okay? It's a collider. We'll get more into that later. And then it has an arrow component that basically shows the direction. Okay. And after the arrow component, there's a basic character mesh, and then there's a character movement component. The character movement component is something we will use to dial in the movement of the character from left to right and jumping. But right now we are going to add one other component because currently the player is completely invisible and we do not want them to be completely invisible. If I click anywhere else and I come here, notice that the player is just a mesh, and if I hit play on the game, there is nothing there. I'm moving around the world with WAS D and I'm holding right click on my mouse and there's nothing there. Let me press a scape to come out of that window. This is completely invisible. Let's start off by adding in a simple component so we can see where the player is. I'm going to add a simple cube. Now that I have added a simple cube, I'm not going to touch anything apart from just the cube. I'm going to select the cube. Okay. And then on the right side under details, notice there is scale, which is X axis, Y axis, and the Z axis. Y axis, rather, the X axis is width the Y axis is depth, and then the Z axis, as you may have guessed, is the height. I am going to reduce its size on the X axis until it is just about inside of the collider. I'm going to reduce its size on the y axis. Now, I'm using Worst D whenever I write click on Worst D there so I can see that. That's generally about. I don't think I need to do anything else here. I'm going to now hit on compile. And then back to the developer level. At least now when I look around, I can see the player character. So this is our player character right now. We can see it. The next thing we're going to do is we want to make sure that once we hit play, instead of being on the floaty development camera, we are attached to the player character. And to do that is very basic. All you have to do is click on the player character here. And then go to your details panel. And then within the details panel, we want to look under search. Actually, let me show you exactly why it is without searching. You want to scroll down, and what you want to look for is the option to possess or Auto possess. Now, looking down, let's see why is auto possess. You're going to scroll. Now, let's just search for it. Autopossess. Here you'll notice these are the search terms autopossess, and it's giving us a couple of different options. It says autopossess AI placed in WIL. Let's just say disabled. I should never be possessed by the AI. It is a pawn. Instead, we shall simply say autoposess player. Player zero, that's good enough. Okay? Now, if we come in now and we press play. Notice, I'm clicking, I'm moving around. Let me try and show what I'm pressing on the keyboard again. I'm pressing worst day and nothing is happening because we have taken control of the player character, but we have not yet implemented the controls for the player character. But this is a simple enough start. At least now we have a player character object. In the next video, we are going to add a camera to it and then we'll add some art to it. 6. 005 Importing Art into Unreal Engine for the player character: All right. Now we have our basic player character that is right in front of us. It is being possessed into immediately the game starts. So when we click Play, we are connected to that. We are ready to take control of it. Now, we're just going to add in a camera to the player character. We have a nice two D like view of the character. So we shall go back into the blueprint and we will add another component. Now, this component will simply get a spring arm, right? Let me see spring spring arm. Now, the spring arm component, you can notice it's right over there, right? Now, clicking on the spring arm component, it's basically like a liver arm, kind of like a cinematic camera arm. We will now add another component and we shall simply look for camera. There we are. So there we are. We have the camera, we have the spring arm. So let's compile that. And then when we go back into the game, notice once you select the player component, now on the bottom right side, there is a little camera showing you. What the camera is seeing, right? The camera you've attached to the player. Let me move backwards a bit. You can see that's where the camera is. And the way that it's currently set up, it is set up so that movement, the camera is looking at the character from the left side, which means in order for the player to move left and right, will be moving left and right on the Y axis. That is this green axis, and depth would be being handled by the X axis. Okay. Now, starting from here, we simply press play. Vala, we are now connected directly to the player character, and this is the camera that the player character rather, this is the camera that is attached to the player character. That's cool. Now before we move forward into a more in depth planning process, let's also add in some art to the player character. All right. Now, in order to add art to the player character, there is a folder that has been provided to you and zip it, come in, get all of the sprites and copy those, and then go into the folder of hey, a hero's journey, that should be the folder based off how you named it. Go into content, go into characters. We organized it this way. Go into player and art, and then you're going to paste all of the art in here. And once that's done, move over into Unreal Engine. Now, inside of Unreal Engine, you'll notice after we pasted in that art, a little pop up is showing 124 changes to source content files have been detected. Would you like to import them? And it's very simple, simply say import. So Unreal Engine is going to bring in all of those files that we have imported. Now that we have those files here, we shall simply go into the art I notice we have all these different sprites that we will be using for our player character. These are some very nice sprites, some basic sprites that we'll be using. Now, in order to move forward here, the first thing is you want to control A, you have selected all the sprites, and then you're going to right click and after right clicking, you're going to go to Sprite Actions, and you want to basically apply paper two D texture settings. Nice. So now, you'll notice that your sprites have correct settings for the backgrounds and transparency. This means that the sprites are now usable. Now that you've imported the sprites and applied some sprite settings, next, we are going to apply a basic sprite to our player object. 7. 006 How To Set Up A Simple Idle Animation And Manage Sprites And Flipbooks: All right. Now that we have our sprites inside of unreal engine, it's now time to actually put them to use. So in order to do that, let's go back to the hero blueprint. And now from here, we are going to add another component and we are simply going to look for a sprite component, and we have paper grounded sprite and paper sprite component. Now we'll simply click on paper sprite component, and that's all we need to do. Now that we've selected the sprite, we have a couple of options. On the detail side of the sprite, notice that we have the ability to select from a bunch of sprites that we have created. Let's start by creating a Sprite. If I press Control and Space Bar, that's basically universal for if you want to pull out. Control and Space Bar, it will bring up our file selection. And then I come down here. Let's say I simply came over here to the Air tak, and I came out and I went to Sprite Actions and I clicked on Create Sprite. Now that single PNG will become a sprite. If I click away, and I go back to source sprites here. I can scroll down and it will show the adventure air attack. Now, initially, we had set up a cube, but now it's covering up our sprites. So I'm simply going to press delete because we no longer need that cube. So I'll click on the paper sprite once again. Ah, there's a problem with positioning. Right now, select I was selecting the spring when I selected the sprite. So let me drag that out and put it back on the capsule collider. Actually, let me delete that really quickly. I am not fixing this in post. I'll leave that mistake in there. I'll go back, simply add a paper sprite. Okay, so I'm going to add a paper sprite. There it is. Now it's in the right position. And then because its position should be at the center, and then I change the source sprite to the air attack, and there it is. Our air attack is now here. And if I go into the developer level, notice our air attack is here, but we need to change the camera direction because if we press play right now, we don't see anything because the sprite is being looked at from an angle. So we will come back here. We will select the spring arm. With the spring arm selected, we'll come out here and we are going to change the rotation. Now we want it to be rotated 90 degrees. No, that's on the X axis. We want it 90 degrees on let's see the Y axis. No, that's your. We want it 90 degrees. Perfect. We want it negative 90 degrees on the Z axis. That's negative 90. You can see what I've selected there. So this time now, when we come back here and we hit play, notice you are seeing the sprite right there. That is good. Now, there are a couple of things we're going to do. Number one, we are going to adjust the scaling so that the sprite is at the bottom, and it is the appropriate size. So I am selecting the paper sprite. I am adjusting its position to be lower than where it initially started. And then I'm going to increase its scale. I'm going to click on this log so that it has a locked uniform scale, and then I'm going to increase its scale. Then I'll raise it up just a bit. Perfect, and click on that. And now when we click Play, we see that sword attack as our sprite. This is not what we're actually going to use, but it's just good to know how the systems work together. Now, with all of that, we'll come back to the hero and we're going to bring up all of our sprites again. Now, we're going to type in what we want to look for is the idle sprite. So we shall click from Idle zero to Idle three. Okay, from IDO zero to IDO three, and then we shall click again and this time Sprite actions, we are going to create Sprite. So now we have these sprites. These are the actual sprites. Notice the names will have sprite next to them. These aren't images, these are sprites. Then I'll simply click from the zero to three, and then I'm going to right click again. But this time, instead of creating a sprite, we are going to create a flipbook. A flipbook is a set of sprites that are banded together. Now notice, if you look at the flipbook Let me click away for a bit. Let me open that up again. You should be able to see it clearly your side. When I'm hovering over it, it's showing the sprite animation. That is fantastic. Now instead of having a sprite, we want an idle animation flipbook. Now to implement that into real engine, we shall simply come back to the source sprite. Okay. And you'll notice right now, it's not showing us sprites. Rather, it's not showing us the flipbook. It's only showing us the sprites, and that's what we are going to change. So now we'll come back. We will remove the paper sprites because we've understood how to put sprites into the game. Okay, we'll simply delete that. And this time, what we want is a paper flipbook and then add that in. So this is our flipbook. And now I'll select the flipbook and then it's going to look for source flipbook. I'll open it up, and I'll click adventurer Idol Flip Book. Now let's look at how it looks in game. Now when you press Play, you can see we have our little adventurer there moving up and down based off the flipbook. We're going to go through the same basic process. We'll come in, want to move the flipbook write down. Let's see, about negative 70 units seems to be the right amount. And then we're going to lock in the scale and scale it up to about I think four times seems to be right, and then scale it right back. You want it to be just touching the bottom of our because this is the actual important thing. This collision right here, that capsule is what is most important. Let me increase that to five Perfect. So at five and at about 20 units on the Xaxis, it seems to be working perfectly. So now when we press Play Notice, our character is there. But the id animation is reasonably fast, right? So simply I will look for adventurer id, the flipbook. And then what I'm going to do is after once you double click the flipbook from here, now the adventurer id is here and on the right side and the details, we can drop the frame rate. I'm simply going to click on that and I'll drop the frame rate to let let me drop it to nine. Okay, that's a much better idea animation. I think that is much more realistic. So with that, I'll press Control S to save. Now, I think this is a good flipbook animation. Now we have our world and we have our basic character. Next, we're going to go into how to actually now start adding in some code because now have a simple character. It is ready. We've learned how to use sprites, how to put sprites into the game, attach them to a player character. But if I show what's on my keyboard, right now, we still aren't able to move around and interact. So we're going to learn how to do all of that after a little session on how to plan and execute game design. Let's get into that next. 8. 007 How To Plan Out Your Game: All right. So we now need to go through a basic concept that is going to be very useful to you moving forward. This works in all areas of life, but in game development, it is uniquely useful, okay? So let me start by just saying that planning is overpowered. Okay. Planning is okay. It's that simple. And by planning, all I mean is you're going to learn how to write stuff down and follow it. That means when you decide on how the game works or the characters or any system, just write it down and try to bring that to life. Let me now share with you a bit deeper how I am going to show you how to do that to make sure you have success because majority of what causes indie game projects to fail, game projects to fail, general failure in general is a lack of proper and clear planning and follow through. Okay? Now, let me explain that in a bit more detail. All right. So the way to think about it for game development is a simple system that I like to call D a A. Okay? That's what I call it. I call it D, a A. That's essentially the system that we are going to be using for this game development, and it should end up making quite a bit of sense to you. Now, Design. Design is going to mean, let's say we decide that our player character should be able to attack with a sword and jump around. That's fundamentally it, and later on we'll give him a bow and arrow for long range engagement. That's basic design, level design. You just draw stuff out. Once you're done with that basic thing, we're going to code. Code means for this example, blueprints, learning how to use blueprints. So we know where we want him to jump. What blueprints do we need to organize in order for him to be able to jump, okay? So we know, Hey, I need to organize that blueprint node, this blueprint node, that one, and then the jump is going to be available, okay? Once we're done with the coding bit, we're going to art. Art is all about the sprites, the Sprite animation. Later on, if you ever do a three D design project, it's going to include modeling and animation, but it is condensed into art. Then last but definitely not least is audio. Audio is all about getting the right sound for the game. Now with this simple example that I want you to keep in mind, let's get started with working on the player character, designing it a bit so that we understand what we want it to do, and then we'll move on to code. And after code, we are going to move on to art and then audio. Okay. Let's immediately do that. Now, let's keep it really, really simple. Okay? So let me copy this over. So we are designing a player character, right? So what do we want it to do, right? So for starters, we want it to move left and right. Okay. Next, we want it to have an attack with a sword. After that, we also needed to have a basic health bar, right? It needs to be able to take damage. Let's call it health bar and damage. And then actually right after the attack with the sword and health bar, we also wanted to have a bow and arrow. To shoot at Range. Now, that's the end of the planning phase. It's a very simple plan. It is a basic plan, and we're going to go through each 11. Oh, wait, move left and right, and jump. Okay, perfect. It can also jump. So with that in mind, let's immediately move on to the next video where we are going to learn a bit about movement, setting up controls, and let's get things started from there. 9. 008 In Depth Explaination Of How To Add Controller Inputs: All right. Let's quickly get started with the first thing is moving left and right and then jumping. Let's get started. Let's get back into Unreal Engine. Okay. Now that we are back into Unreal Engine with our player character, we want to have the ability to move left and right, and we're going to start with the controls. Now, just to visually show you, I have my keyboard, so you are going to be able to know when I press AWS and D. We'll mostly focus on A and D to start. And then on top of that, when you want to have this work on Controller, I will also show you how to make it so that the movement is based off your controller positioning and your buttons. Now, to start with, what we want to do is we're going to hit Control and Space Bar once again, and outside of characters, let's go back to the general content folder, and right around here, we're going to create a new folder and call it Controls. The reason why we are calling it controls is because it's going to have everything that we are using to determine the buttons the player can press. Okay? So let's go into that. So inside of controls, let's start with one simple control, which is moving left and right. So you're going to left click. And after left clicking, you want to go to inputs. Which is here, and the thing you want is you want an input action. We will start with just one. And we are going to call it move right. So this input action or this button is going to cause the player to move towards the right direction. And then we are going to go into inputs again. But this time, what we look for is an input mapping context. We'll click on that. And we are simply going to call it player map. So we have Move wight, which is a single input action, and we have player map. The player map is basically, as you can kind of see from the icons, it's going to be the collection of input actions that you can press. Now, in order to make sure that move wright is working correctly, we first go and double click on Move Right, and it's going to open up this window. So you can start with a simple action description, and we can simply describe it as moves the player. Right. You can keep it as that. And then should it trigger when paused? No, it should not trigger when paused. And then reserve all mappings. You can essentially make it so that this cannot be overridden, or now we'll leave it. And then value type, this is important. Now, we can change the value type. Right now we set to a digital boolean. You can see that right there. Booleans essentially are ones and zeros. So if we set it to a boolean, it is either on or off. We can also set it as Axis one D or Aces two D. But essentially, setting it to Aces one D is going to make sure it is a value 0-1. For simplicity's sake and for demonstration, we'll start off by having it just be a digital boo layer. Now that this is done, we'll simply close this. And then Control Space bar again, we'll open up the player map. Now notice on the left side, there are some mappings. We will simply add one by clicking on the plus, and when we scroll down, notice it's showing us the move right. Click on that move right, and then from here, we can simply click on that little arrow to scroll down. Now it is showing us that there are no actions attached to it. However, what we can do is we can simply click on that and then we should be D. So I've clicked on D on the keyboard. Okay? That's what you can do because essentially what Unreal engine is capable of doing is listening to your keyboard. So if I click on it again and click hit Spacebar, it will change the input to spacebar. If I click on it again and press W W, that's essentially the concept. We can leave it at D for now. And then we will simply click on the class, which will add another binding. This time I want click on the keyboard. I'm simply going to open up my controller, and I am going to press on select this value, and I'm pressing the right gamepad button on my controller. I've pressed that and it has saved that right over here, which is going to be good. That's all we need to do from here, okay? So we have now set it up so that there is a move right input action. And in the player map details, if you press D, it will execute move right. If you press the right button on your keyboard, rather, sorry, on your controller, it will move the player character to the right or rather it will execute the move right action. With all of that done, we can now go in to the player Blueprint and add those controls in. So go to the hero Blueprint. And now we have started making adjustments to the actual player blueprint. Now, the first thing we're going to do is we want to make sure a control space bar. We want to make sure that the player map is the input context that is being used in Unreal Engine. Now we are going to do that on a node known as the begin play node. That is this node. Begin play means that this is the code that is fired when unreal engine just starts, or when this object is spawned into the world. So let's do that. Now, the first thing we're going to do is from a simple right click, we want to get controller. That is what we want. Notice paw, get controller, that is good. Then from the return value, what we want is we want to cast two player controller. Essentially what that does is we are telling Unreal Engine to please access all the controls of this player, and then casting is connecting it so that every function will run through that casted object. That's a generalized way of looking at things. Then we will connect the begin play to the cast to player controller. Once that's done, we now have our controller loaded in, are we are casted to it so we can access functions from it. Now, as the player controller, you want to drag that out and type out enhanced and there we are, go to the second option, that is get enhanced local player subsystem. This is going to be what allows us to select the different inputs that we are going to use. And once that is done, we'll drag it out one last time, and we want to add mapping context. You can just type add Map after right clicking and that will add the mapping context. So we'll connect that node over here. And then go down and there we are player map. Remember that player map input context, that is the one that we select. Now that we have that selected, let's quickly have a look at how this code is running. Event begin play means it is going to begin the game by doing this. Basically, it's running off the blueprint of the player character. But since the player character is in the world when the game starts, it will start by doing that. It's self explanatory on event begin play. Then it is getting the controller, okay, and then casting that as a player controller. So we have access to those functions. We get the local player subsystem for inputs, okay. And then we say, Hey, use the player map as the mapping context. Now, with all this done and set up, we are now able to use the input that we set up. Now let me drag all these other nodes down here so we can have a clear view of this. The next thing we're going to do just for simplicity and to make sure this is working, we're going to right click and we're going to look for that input. Now, that input we called it move right. So typing, move and notice there is that action event already set up over here. Since it's a Boolean, it is like, Hey, when it's triggered on enhanced input action, move right. Let's simply drag this out and we want to start with just print. Print out that string. And the text, we're going to say, Hey, player is moving right. And that is it. Voila fine. Now, with just that, we are going to be able to test out and see if this is reading our inputs. So what you want to do at this point is click on Compile and then go into the developer level. Now, when you press play, on the left side, anytime you press, let's start with the keyboard. So I'm going to press D on the keyboard. That's good. So we know that this is actually working correctly. Let me zoom in so that the text is clear notice. The minute I press D on the keyboard and I'm in Aldon, I need to press play. Let's press play. Here we are. So now that the game is running, when I press D on the keyboard, it is printing out those actions printing out that text on screen. It's saying, Hey, play is moving right. That's good. But now, let's test this out with the controller. I've added in the controller. I have pressed play o right over here, I have pressed play. Come back in here and let's see if the text comes up. So when I hit right on the controller, yes, it is registering that the player is moving. When I hit D on the keyboard, it is registering. So that's the basic fundamental of letting your inputs be read on rather inside of unreal engine. Now that that's done, let's actually add in the movement. But right before we add in the movement, I wanted to show this to you as well. One of the good things about blueprints. So now, notice, I am going to hit play. We are now in this world. I'm clicking on the hero, and you are able to see what the blueprints are doing. I'm dragging that out just so that it's going to be a bit more to the right of the screen. This is a useful way to debug and see how the blueprints are actually working. Now in the background, I've clicked on the game. Now, I am currently in the game. Let me come out of the game. Now as debug Object, I'm going to select Hero. Now with that selected, I'm going to press Play. Now we are playing in game. Notice the moment I press the right button on my keyboard, it shows that moving right is being pressed. Let me show my controller and some of my worst day so that it is much clearer. I am clicking on play again. So notice when I press on my controller, you are able to visually see the blueprints showing what's working. So you can see that that's been fired off and it's working. When I press D, it fires off and it works. When I press any other button, nothing is going on. When I press anything else on the keyboard, nothing is going on. So you can easily set your blueprint on maybe a second screen. On the other side of your monitor, when you want to do some basic double checking, it's good to be able to see your code visualized. Now let's add the movement to our player character. To add the movement input, essentially, you're going to be using the ARD movement input node. Right here, after the print string, simply drag it out, and then you will use ARD movement and from there scroll down, and notice there is that add movement input. Click quickly add that. Then as far as wild direction, we need to make a choice about which direction we are moving in. Now, we know for a fact that for our player character right now, if we look at these directions, the Y is controlling depth, the X is controlling left and right movement, and Z is vertical movement. Since we know that in order to move right, that means we want to move positively in the X direction. We will simply decide we're going to make the decision that for wild direction, we'll simply say one in the X direction. Now with just that, hit compile and then go back to the developer level and play. And now every time I'm currently hitting D on the keyboard and it's moving in the right direction, that's good. I'm currently pressing it on my game controller, and it's doing the same thing. Now, let me visualize it for you. You should be seeing the exact same thing on your screen if you've been following properly. In case of anything, always go back and refer. So on my controller, I press right. The character moves right. On my keyboard, I press D. The character moves D and Whoop D off the world. Okay, I've pressed escape to get out of there. But yeah, that's okay. So we have done a basic movement input. In the next video, let's clean it up for moving left and right and add a few more keys to the movement to enhance it. Let's 10. 009 Left And Right Movement With Keyboard And Controller: All right. So now that we have the player character able to move to the right and you have an understanding of how inputs work, we are going to add left right movement to the character and let me take you through how to do that properly. Now, initially, we started out by adding a move right input and then just adding that to the player map. Now we're going to make one change before moving forward. Let's quickly rename this from moving right to simply let's simply call it movement. Because we want to have one input action that will both move the player character left and also to the right. So I've simply called it movement. Okay. That's going to be our starting point. Once you're done changing that name, now we're going to open it up, and that's basically just double clicking it. And notice right now it is simply set up as a digital Blayer, right? Now, let's change that to an axis three D vector. That is essentially what we want it to be Axis three D allows us to assign it a value on the X, Y, and Z axis to determine its movement. With that done, the next thing we're going to do is going into the player map. Now, currently, the player map is showing as movement. D, let me open and make sure my keys are visible. It is currently set to D pad right, which is that to move it to the right direction, and also D on the keyboard. But what we want is we want to be able to use the analog sticks for starters. We want to be able to use left and right on the buttons, and then we want to be able to use A and D as well. Now, in order to make that work with the current vector three D that we've set it up as, we're going to need to make a minor change. So we'll start by leaving D here. Next, we're actually going to add a number of other buttons. Let me drag this. I can easily drag this up so that let me not cover up any of these buttons. I'm simply going to excellent select that and drag it up. I've clicked on that. I'm going to call it A because we will need A and we will need D. Then there's directional pad right, and then I'm going to press left on actually. Let me press left first and then write on the D pad, and then there's going to be another input, which is going to be the thumbstick X axis. The thumbstick X axis basically comes about because I clicked when I clicked on nRLEngineT Listen, I pressed my X axis a bit to the left and right. If I click on that and press up, it's going to listen to the Y axis. But we don't need that. We need the X axis, so I have now set that up correctly. Now, with it set up in its exact current form, let me quickly show you what you'd be getting from your character movement. Now, going back into the character blueprint, you will notice that there's been a change. Now, our blueprint is showing action value here. Let's quickly delete that print string. It is not needed and connect the trigger directly to the movement input. Okay. Now with that connected directly, we will also connect the action value. Notice the action value. It's showing X zero, Y zero, and z zero. We can connect that directly to wild direction right over there. Now, with just this single basic change, we'll quickly save and compile. And then let me drag this out so that we'll be able to see it visibly. Opening it up, I am hitting play to simulate. Okay. So now, notice that when I'm using the analog sticks, okay? I'm currently using the controller's analog sticks. Let me set that up again. The controller analog stick is now able to move the player character in a negative value on X and a positive value on X, and you can see that the blueprint is reacting. However, if I press left on the D pad, it moves forward. If I press right on the D pad, it moves to the right. If I press D on the D pad, rather, if I press D on the keyboard, it moves right. If I press A on the keyboard, it still moves to the right. Now, that's something we're going to correct right now. So let me quickly double click on the hero so that the game drags me back to here, Control and space bar in order to open this up, and I'm double clicking on the player map again. Now we're making a pretty simple change. Under A, A means under worst D that should essentially move you to the left. We are going to find modifiers, and then under modifiers, you're going to add scaler. You can type it out. So scalar and open it up and then we want to set it up to negative one. And then we are done with setting up A and then gamepad left will do the same thing. Come here, add a scalar modifier to change the scale that it uses so that negative on the X axis is moving to the left. Set that up as negative one. And with that, we are done. We'll quickly press Control S to serve. And now our movement should be working correctly. I am going to let me make sure my keyboard is showing and my controller hit play left, rather right on the on the controller, I hope you can hear that clicking. Left is doing the correct thing, and then on the keyboard, A is doing the correct thing. D is doing the correct thing, that's good. Then I guess my stick has a little bit of drift, but that's okay. That's just a bit of stick drift. You'll see that left, right, and we are done. Now that we are done with left right movement fundamentally, let's quickly go back to how we are planning things out. So very quickly, remember, design code art. Now we are done with the basic design. We know what we want. We want some basic left right movement. It's simple. We are done with the basic code. Right now, it works and it works correctly, the movement. Now let's add in some art in the next video so that the run animation is working correctly. Let's do that moving forward. And once we're done with that, we'll add in the audio. Let's go. 11. 010 Add Constraint, Fix Stick Drift And Set Player Position: Okay, so let's do some minor fixes before moving forward. Now that we are beginning to use movement, select the player character. And after selecting the player character right under details, let's transform it and make sure the Z axis leave that, but make sure it's at zero, zero on the X and Y, so that we know that it's wild location when the game starts zero, zero, it's basically the center of the entire world. Next, we are going to quickly fix the controller stick drift. Be currently when you first play, when you move around, there's always a little bit of stick drift. Now fixing the stick drift is simple simply going to the player map go out here, go to the modifiers and at the modifiers, add the modifier and add the modifier known as dead zone. After you have the dead zone, I already did it here, leave the values as is. With that, there's going to be no more stack drift, like we're seeing in the previous video. Now with that done, there's going to be one last thing we need to tighten up before we move forward. You're going to go to the player blueprint. You are going to select the capsule component. And the first thing we're going to look for is we want to add a constraint and what we want to do is we want to it to the Z and X plane. What we want to do is want to its position on the Y. And what that means is that the player character can no longer move along the Y axis. That's going to be very important. Let me actually click on the hero itself and lock its position along the Y axis. That means that it's going to be properly two D. It can no longer move up or down along the y axis, only along the X, let's just make sure that we haven't messed anything up. That's perfect and this is good. Now in the next video, let's quickly add in the left right movement for the player character as far as the animations. Let's 12. 011 Setting Up Paperzd For Animation Managment: All right. Next, we are going to add in a running animation. Now, to add in that running animation, the first thing we're going to do is we're going back to the main folder. We are going back into characters, the player, and then under the player will go back into the art folder. Now, under the art, we're going to do a quick search. One of the good things about well organized sprites is we're able to type that out. Now notice that we have our run animation, rather our running sprites, going 0-5, simply select all of them. And then Sprite actions and create Sprite. Done. Now I'm typing Run in again, keeping it organized, and I'm going to select 0-5 and then right click and create flipbook. So now we have this flipbook of Adventure Run. Let's double click it and see. So now it has the five animations moving concurrently, that's good. Now I'm going to quickly make the decision to drop its frames per second 15-5. Okay, now it's looking. It's not there yet. About seven. About ten. Okay, I think ten frames per second, that's a reasonable run animation. Now that we have this basic run animation, how are we going to apply it to our player character? Because right now the player character is still. And what we want is when the player character is moving, we want to switch to that sprite. Okay? Now, in order to do that, we're going to move on, and this is where using paper Z D to create those animation pathways simplifies our life. So we are going to go back into the player right now, let me close, remove that text. Right now, our main side of the player. Here we have art, and this is a good folder to have. We're going to make another folder, and we're going to call this animation. Now that the animation folder is established, we can go into the animation folder and we're going to start creating some paper Z D items. So go directly to paper Z D, and the first thing you're going to add in is something known as an animation sauce. You should see it there. Now what we are going to do is we're going to call it hero animation sauce. So I'm going to call it hero. Paper Z de animation sauce. We're just going to leave it at that. Now, when we quickly double click on that animation sauce, notice that we have this grand space, but we don't have any new animations here. So what we're going to do is we're going to come over to the top left corner and we're going to add a new animation sequence. Okay. And we are going to simply call this. I'm going to rename it. I'm going to call this idle. Now that we have our idol ready, I've clicked on that on the right side, it's showing animation sequence. I'm going to scroll down and notice you immediately have adventurer Id and adventurer Run available. Click on Idle, and it will show the idle animation. The next thing we'll do is we'll add in a new animation sequence and call it Run, go through the same process, select the Run animation. So now we have rather, we idle animation and we have the run animation. Make sure that it's not set as a multi directional sequence. We will handle the directionality of this later. Double click on Run. That's the run. You can see where its position is. It looks like it's basically a bit forward from the center. We have idle. Idle is 100% dead set on the center. Run and idle. Everything seems to be checking out. They are lined up correctly. This is good. So now we have Control Space bar. We have our paper Z D animation sauce. Notice it has made another folder with animation or sequences. We don't need to touch that. And our animation, basically, our hero paper Z D animation sauce has an idle animation, and it has a run animation. That's perfect. This is where everything starts. Now that we have the animation source, it's basically a collection of all the animations that Paper Z D is going to be using. Now that we have that, next, we are going to create an animation blueprint, Control Space bar once again. Now, this time, go to paper Z D, and what you want is paper Z D, name BP. So notice once you click on that, a new window opens up, that asks you, so, Hey, what's going to be the parent animation sauce and just simply select the hero paper Z di animation sauce. So this is the container that all the animations will be pulled from. So now that it's here, I'm simply going to rename it. I'm going to rename it hero paper Zi Anime BP. Now, I'm going to quickly double click on that animation blueprint. And here now we are in an animation graph that is going to be the thing that is in charge and in control of all of our animations. There is for star as an event graph, and then there is an animation graph over here. And we're going to go through how to use both of these effectively. Now this right here, the animation graph is where we are going to set up all of our different animations. But before we do that, let's do some basic setup in the event graph. So in the event graph, there is a node called event on int or on initiate, and this is the first node that we need to interact with. So we need to tell it what to do on initiate. So what we want it to truly do is immediately it initiates, it's going to set up the player as a variable and make sure that the animation graph is connected to it. Now, to get that working, the first thing is, we're going to need to get the actor that owns this object, okay? So we're going to get the owning actor, that is the first thing we're going to do. So whatever object we attach this to, which is going to be our hero and we're going to do that next. This is going to be the owning actor. Next thing we're going to do is we're going to cast to the player. Okay, actually, no, we don't want to cast to player. We want the blueprint. We call the blueprint hero, so we want to cast to the hero blueprint that is going to be our hero character. Once we are done casting to the hero character, we are simply going to promote this as a variable, let's call this, let's call it let's call it the hero. We'll simply promote to variable. Here we are, and it's saying set and it's called as hero. Now, with this setup, you'll notice on the left side, there's now a variable called as hero. That is good and that's all we need from right over here. Now, we'll move on to the animation graph. Now, this animation graph works in a pretty simple way. This right here is the output animation, and we need to connect a node to the result. Right now, it might not make the most sense, but don't worry. As you get to grips with it, as you use it, it's going to make total sense. And in case anything is confusing, just send me a message and I'll reach out to you. But I am going to explain everything step by step so that it makes sense. Let's continue in the next lesson. Now, before moving forward, just to cover up, make sure your event graph, we get the owning actor, cast to hero and set it promote as hero as a variable. Make sure that you have your animation source with the idle animation and the run animation, the idle animation and the run animation. With those two set up and organize, that's all you're going to need to move forward. 13. 012 Play The Idle Animation Through Paperzd: All right. Now that we have our basic animation blueprint setup, we're going back to the hero blueprint. Now we have our flipbook setup, quickly compile. We are going to add a new component and we are going to type Z D what we want is a new paper Z D animation component. With that component, we are going to look to the right, and there are going to be a couple of options. We'll leave the variable name, one paper Zed di and notice it's asking for an animation instance class, and here we are. It is hero paper Zi Animation blueprint that we created in the last video. And now it's also asking for a render component, okay? So the one we will select, we want to select the paper flipbook. Because the flip book is going to be the component that we are going to be this one right here, it's the one that we are rendering all over to the imagery to. Now, just to make sure that everything is working as intended, the first thing we are going to do is we're going to come in here and we are going to go to the source of the flipbook. Currently, it is set to adventure idol. We're just going to come over here and we are going to clear so now that flip book is not being rendered to by anything. We are going to use paper Z D to manage all of our animations. So if we go right back into the level, now notice there is nothing being shown. Okay? There's absolutely nothing and moving left and right, and there's nothing, that's okay. Now with all of this setup, we are ready to start adding in the different animations. So we are going to go back into the paper Z D animation blueprint, and then we are going into the animation graph, and this is where we start working on the animations. So we are going to press right click and type State. And we are going to add new state machine. The state machine, we're simply going to call it, give it the name hero. You can name it whatever you want. These are just the names I am using since this is a hero's journey. I'm going to connect from hero to output animation. Now that we have our initial state machine, and what a state machine is is essentially in the name. It is the logic that decides on the state the player is in. So let's go double click on the state machine to get in. And you'll notice initially all it has is out. That's okay. We'll simply drag it off. And we'll add another animation stat. Let's call this first animation state idle because essentially, once you load into the game, the first thing you see is going to be, you know, the character standing there idle. Now that we have the idle animation set, I'm double clicking on the inside of that, and then I'm going to right click and I'm going to request it to play idle. Okay. So it will try to play that idle animation. That is the result. Let's quickly compile that and then we'll go back up to here back to the animation graph. So the simple way to think about it is the state machine is pushing out output animations. Inside of the hero state right now, from when it starts, which is out, all it's showing is the idol. And inside of idol, all it's doing is like, Hey, just play the idle animation. That's going to be the output. That means that right now, once we go back into the level and we hit play, all we should see is the idle animation. And so go in once you hit play, Boom, we have the idle animation. Now, remember, the way that the idle animation is attached, our paper flipbook doesn't have any animations connected. It's so none. It is the paper Z D animation, going to the hero Paper Zed Blueprint, that is controlling that. So right now, let's go back to the animation Blueprint. This right here is what is controlling our animation. Now that this is working correctly and it should be working correctly, next, let's make sure that if the player is moving at a velocity on the horizontal direction, it's playing the running animation. 14. 013 Play The Run Animation Through Paperzd: Alright. Now that we have set it up so that Pepa z is handling our idle animation, now our next job is to simply play the running animation. So to do that, let's get back into the animation blueprint. So just to be clear, from the animation graph, double click on hero. Now we're outside here. Now, it's pretty simple to make another animation state. We'll simply drag it out. We'll create a new animation state. And this state, we are going to call it run. That's all we'll do. We'll call it run. Now notice that there is something here that's saying, Hey, idle to run. Because now inside the animation graph, we are going to be transitioning from one animation to another. So what would it take to go from idle to run we'll add in that code and then come to the outer layer of run and drag it with the right click a left click, sorry, right back to idle. So everything here will be going from running to idle. Everything here will go from idle to run. Let's get in to what that's going to mean at a code level. So let's quickly go into the Idle animation. All that does is it plays the idle animation and that's the output. Good. Now, go back to the hero, go into the run animation. There is currently no run. So the next thing we are going to do is with a simple right click, we shall play run. That's what I've typed out for Unreal Engine to find. And since that is inside of our animation source that we set up, you can simply link the run to the output animation. Now that is done. Now, if you were to compile here, okay, just quickly compile. Even if you go back and you're moving, it won't play the run animation. So inside of the blueprint will simply go into idle to run. And it's looking for a positive value to state that it should go into that transition, a positive boolean. Now, I'm just going to share with you the logic to keep it simple, okay? The first thing we're going to do is we're going to get our hero variable and drag it out. So we will get as hero, okay? We'll get that. After that, we're going to drag this out again, and we want to get its velocity. Let's make sure to scroll down. You want the simple get velocity. Okay? Now that we have gotten its velocity, we want to split it up to a structural pin. Now, keep in mind moving left and right is strictly on X. So we want to drag out the X value, and what we want to look for is not equal. In other words, if it is not equal to zero, it can go into the next transition. Now, just to explain the logic again, we are getting the player character checking its velocity. The moment its velocity is not exactly zero, I can enter into that transition. And what is that transition? That is the run animation right here that we have set up to play the run animation. Now with everything set up like that, let's quickly compile and test it out. So the player is standing still. Now, when you move, it goes into the run animation. But you'll notice, although we are in the run animation, we are not getting out of it. So we need to go back to the blueprint. We've added in the code going from idle to run. Let's come here and copy all of it. I'm pressing Control C to copy all of that. Then let's come out of that, go into the run to idle. It literally states the run to idle. We are done with idle to run. Let's work on run to idle. And to keep it simple, I will simply paste everything from before except for one simple small change. Instead of saying, Hey, if the velocity is not zero, what we want to check is we want equal, okay? So if the velocity is exactly equal to zero, it will go from the run animation. Back to the idle animation. With it set up that way, let's go through the logic again. It starts with going straight to the idle animation and playing the idle animation. If the velocity on X is greater than zero, it is going to play the run animation. If velocity hits zero, it goes back and plays the idle animation. With that done inside of paper, this animation blueprint, let's go back and check it out for real in game. Let me pull out my controller for this. Test of truth. I've hit Play. Perfect. When I move, it plays the run animation. When I stop, the animation stops. This is excellent. The animations are aligned correctly. This is good news. Let's quickly jump off the bridge. Okay. That is perfect. That is good. Next, let me quickly double click on the player so that I get taken back up here. Now, although the animation is working correctly, you notice that the player character is not facing the right direction. Now that's going to be a simple change. Let's do it in the next video. 15. 014 Changine Sprite Direction Based Off Movement Direction: All right. In the current state of the game, if you move left, with the control if you move left, the player still plays the animation to the right. If you move to the right, the player, I mean, that one's generally correct. Let's fix that. In order to fix that, all we have to do is go into the hero blueprint and you go in over here. Now, the place we want to put the code that's going to fix that is closer to the right side. The first thing we're going to do is we want to get velocity. Quickly scroll not volume, we want velocity. We shall get the velocity. There we are. Now that we've gotten the velocity, we can put that right over there. We want to split the structure pin, that's getting the value. Now, since we are moving in the X, what we want is the X velocity. We shall simply get the value and we want to do a simple check. And what we want is we're going to do a double check. Is it greater than zero, or is it negative? Simply start with a basic check of is it greater than zero. Then we'll drag out this node, and we're going to set it up on a simple branch. Now, a branch is basically a node used to double check Booleans. If it comes out as positive, in other words, if the velocity X is greater than zero, then it's going to be true. If it is less than zero, is going to be false. Now, now that we are done with that, what we want is we're going to go back here. We're going to get the paper flip book since that is what is going to be containing our animations, we'll drag it and we'll drop it right over there. Once we are done with that, we can drag this out, and then we want to set rotation. And we want to set wild rotation. Now that we have it set to set wild rotation, we're going to copy and paste that, drop it here, and connect the flip book here as well, because we're going to be setting wild rotation twice. So we will say, Hey, if it's true, it will follow the first wild rotation. If it's false, it will follow the second wild rotation. Now, remember when you're flipping something, you're flipping along the Z axis. Let me quickly demonstrate that. So let me quickly set this paper flip book to show the running sprite. So what we want to do is we want to rotate it along the Z axis. Okay. So as an example, this is zero degrees or close enough to zero. This is 180 degrees. So what we want is when the X velocity is positive, it's going to stay at zero degrees. When the X velocity is negative, in other words, it's moving to the left, okay? We want it to be 180 degrees. Let me set that back to zero. And set this back to clear so that there is nothing interrupting papers a day. Go back into the event graph. Now, we are going to say, Hey, if the X velocity is greater than zero, set wild rotation is going to be zero. If its X velocity is less than zero, which means it's in negative, we want to set its wild rotation to negative 180 degrees. Now, that's a very simple change. I hope I have explained it properly. We'll go back into the developer level, hit play, and now notice when I move to the left, the sprite follows and it doesn't change back right away. When I move to the right, the sprite follows that rotation and stops. That's fantastic. That's exactly what we wanted. And now we are going to move on to adding some sounds and stepping sounds to our player character. 16. 015 Adding Running Audio Files: We currently have our character. It can move left and right, and we have that ready. Now, let's go back to the basic principles we're using. Now, we're done with design. We are done with code on that particular element. We are now done with art for that particular thing. Now we need to move on to the audio of the run animation. Let's do that right now, adding some audio to the running. So this is where we get into some basic recommendations. Number one, I highly recommend that you as an Indie developer, learn how to add in your own sound. So we're going to add in a running sound. There are many ways to get footstep sounds. Some of them are going on and buying some assets, but as an Indi Dev, just as an additional aside, I think being able to make your own audio is going to be very important. So let's get into what that would look like, okay? Now, right now, I have opened up a free application called Audacity. Now let's look into audacity. So audacity basically lets you edit and change different sound clips, okay? Now, notice that this sound clip that I dragged in is called me walking outside. This is basically just some footstep sounds, which I recorded by going out, putting my phone pretty much like near where I was stepping, and it's going to sound like I was moving forward, but in reality, I was in one place. Now, just listening to how it sounds. Okay. We have all those different audio bits of me making a step. Now, I won't go into everything that you can do in audacity because as I said, there are many ways to get sounds. But one thing that's really useful is let's play that back. Okay, I want to fundamentally break it down so that I can just capture. Let me try and I just want to capture a single footstep. So let me drag this here and play. Let me try and put my mouse back on screen, I should simplify me explaining what I'm doing. I am just dragging over an area and then pressing play. It will play only that sound segment. Okay, so that is one footstep. Nice. But what I want is I want to get the sound at the very first point where the foot is making sound. Okay, so that's around here to here. This is what I want. This is the real footstep sound. So I'm simply going to copy that. Let me zoom back out. I'm going to click on Tracks, add a new track. Let me consider it a mono track. Then down here, I'll click on back here to bring the playhead back, and I'll paste. Oh, yes, I recorded this in stereo. So when I add a track, I have to add in a track as stereo. Okay, now, left click and paste. So let me come over here, mute this, come down here, and then that's now me walking. I'll bring it back. Let me play that sound. That's a proper single footstep. Nice. Now that I have isolated a single footstep, I am going to go over to file and I am going to export audio. Now it's saying, Hey, do I want to put it on audio.com? That's cool. No, I want to export it to my computer. And now that I am done exporting that, I'm going to go through the hard work of exporting out about five different footstep sounds. Now, I find personally that around five footstep sounds is the ideal number, and I'm not going to take you through the entire process because that would be a bit boring. And I'm going to include these sounds with the project, but I just wanted to put this in here. Now, let's move on to the next step. Once the footstep sounds are exported. And when exporting, export them as WAV files. That's always better with Unreal Engine. And now by the magic of time travel, I have organized those five footstep sounds. Now, I have gone and created a folder called Audio. You will find this. It's going to be downloadable for you. I've created another folder under audio, and I'm going to call this footsteps, right. So within the footsteps folder, I'm going to paste let's see control V. There we are. I'm going to paste footstep one, two, three, four and five. Okay. Now that we have this, once you get this, simply copy these over and you're going to paste them inside of a folder for our project in Unreal Engine. So finding our project folder, go into it, go into content. Now notice there's levels, controls, characters. That's cool. Since all of this audio is for a single character, I like to go into the characters, there is player, it's animation, there's art. I'll simply create a new folder and I'm going to call it audio. I prefer to have audio in a separate folder for each character that simplifies me finding things. I know some developers like to have one big folder for all the audio, but I don't like that it's too disorganized. So I'll go into audio. I'm going to make another folder and I'm going to call this folder footsteps. Okay. Then inside of the footsteps folder is where I am going to paste. I paste with Control viaon Windows, but you can paste however it is if you're on MAC that may be a bit different. Now that we have put this inside of our content folder for our game, let's go into Unreal Engine and see how to implement them. Okay, so now we are back in real engine. And notice that right over here, it first starts by saying, Hey, three asset editors were opened before it was last closed. Here, let's reopen those, and then five changes to source content have been detected. In other words, it has identified that there are five new files here. So it's saying, would you like to import them? Yes, I would like to import them. So let's quickly have those imported and it's done. So we'll go into the developer level, have hit Control Space bar to raise this up. And now you'll notice under player, of course, it has identified correctly that folder for audio for footsteps, and there we go. We have footstep one, two, three, four and five. Let's quickly listen to each audio sample. Okay. Good. Good. Good. Okay, so we have five different distinct audio audio sounds available for us. The reason why I recommend having at least five because you can use one. But if you play just one, then it's not going to sound good. So the next step is going to be just adding those sounds to our character because the character right now is not making any sound when it works. Let's fix that in the next video when we add in those sounds. 17. 016 Adding Spatial Running Sound When The Sprite Foot Lands: Now, all we have to do is to add in an audio component to start. The audio component is called a sound queue. A sound queue is just a smart way to collect together multiple sounds. Now, that sound cue, let's simply call it player. What steps. So that's going to be the name of the sound queue. Now, if you double click that sound queue, it opens up the sound queue in Annual engine, and that's our output. If you hit play, you shouldn't hear anything now because no sounds have been connected to the output. Now what we will do, I'll simply gather all of these. I'm using shift and clicking, and I'll drag all of them in all at once. Now, let's quickly do a minor test to see if this is working correctly. We'll add in the first put step, okay? And then once we're done with that, let's play the sound cue. Okay, so that one's working correctly. Let me break it. Let's test out the third. Okay, that's working correctly. Let's test out the fifth. If this works, all of them are working correctly. Perfect. Now that these are all working correctly, we only need to randomize them. Now to randomize them, simply right click and search random. Which should lead you to carve a sound node called random. So with that random node, I'm going to push the output up, bring this random node over here and let me add a couple of inputs. They need to be five. That's good. So I am connecting all of our different footstep sounds to the random node so that it can randomize them for variety of footsteps. Connect that to the output. Now, let's listen to what that would sound like. Perfect. Now we have our sound queue properly set up. Now with the sound queue properly set up, what we're going to do is we'll control S to save, we'll close that up, and we now need to go to our main character. Go to our character. The first thing I'm going to do is let me put the adventurer idle here so that every time we're in the world, we're able to at least see the character there. Now we are going to add in a new element to our character. Now that we have that, let's quickly go over to the paper flipbook, and we want to drag our sound cue to the flipbook. I'm using Control and Space bar to raise this up. I'm holding down that sound cue and I'm dropping it on top of the paper flip book. Now it's here, play here footsteps. It's ready to be used. Now, as far as position, it starts out being in the middle of the character. I want to drop it down just a bit to near the ground but not below it, so it doesn't clip. Then after selecting that, go down on the sound cue and make sure that this right here is disabled, autoactivate. We do not want it to auto activate. Now with this sound cue setup as is, we also want to change attenuation. Right here, there is override attenuation. Just click on that. What that does is it turns the sound into a special sound, so the sound will have fall off. One of the best ways to have good sounding sound is when it comes to specialization, change the function from linear to natural sound. This is pretty much it. Then we'll come back and change the details of this later on. Speaking of sound, a very loud motorcycle passed by my office. How cool. Anyway, with all of this done and set up, you have the player footsteps, sound cue setup over here. Now, we need to simply make it so that when the player moves, it plays that sound. Now, to do that, we have all the sounds set up in the player. We simply need to tell the blueprint when to play them. So we'll go right up to player again. We'll go into animation. You can click on Animation source, or you can just go into this folder with animation sequences and double click on Run. Now you'll notice our run animation is here playing. So let me pause that. There is a track here called one, which we'll be using. So I'm going to get the play head, right, and I am going to simply drag it up to a point whereby I see the foot touching the ground. Boom, right there. At right here, about 1 second, okay? This first frame of animation when the foot touches the ground, then I'm going to add an animation Notify. I'll first right click. Make sure I notifies being shown, and then I'll come down here. And then I'm going to right click again, and then I'll say, Hey, New notify. Okay. Now there are multiple notifiers but we'll just use a New notify. This is basically to inform real engine. We want to do something on that frame, and then I'm going to call it footstep sound. Actually, let me make it a little bit longer. Player footstep sound. So at this point, we've created a notifier to play footstep sound. Let's move forward along the play along, and then again. So I will click on the footstep sound, Control C to copy. Come over here, Control V. It will put it right over there. So we have two points whereby want to play the sound. There we are. Boom, play the sound. That's all we need for this animation. So it should work correctly now. With these player footstep sound notifier setup, next, we simply go to the paper z the animation source, right? Rather not the source, we go to the blueprint. Now inside of the blueprint, notice that there are now new notifiers, click on the one that is correctly named, which is player footstep sound. And around here, we're ready. So the first thing we're going to do is we're going to get our hero character, drag it out over here. Get as hero. That's good. And then let's double check in the hero. This is called player footsteps. Okay. So let's drag it out, and we want to get player footsteps. Oh, sorry. Get player footsteps. There we are get player footsteps. This is the audio component and then drag that out, and we want to activate it. Here it is, activate Activate basically causes it to be active. Once we have done that, we now want to play the sound. I'll drag out from player footsteps and I'm going to type play, and here it is. Play, so it will play that sound. Let me connect it up here. Link these two. Right after it's activated, it plays that sound, start time zero. That's good. Let's have a quick overview of what we have right here. So we have after receive Notify as hero, the player footsteps, which is what we have as the audio component, activate it and play. So with that, we should now hear the player footsteps being played. Now, let's go. Perfect. Now we have our footsteps connected to our two D sprite animation. Now, one cool thing is because we have it specially attenuated, if I go into the hero, going into the camera and I increased its location to move it backwards, let's say about 500 units, negative 500 units. Negative 500 units. You'll notice that the sound is significantly less loud. That's why we use specialization because if you just play the sound, it will be as if it is everywhere in the world. But when you use attenuation, you're going to have sounds being location based, and we also made sure to position the sound queue in a natural place. That's good. Now let's move forward to the jump animation. We'll start off with setting up the code in the next video. 18. 017 Using Comments To Organise Blueprint Nodes: Alright, so now our player character can move left and right, and we are able to hear them. The next thing we're going to do is add a quick jump function to our blueprints. 19. 018 Control Setup And Code For Adding A Jump: All right, so let's add the jump input. So we have our movement there. We're simply going to go into inputs and then we're going to add in an input action. We will call this input action jump. That Jomo? Where's the P. Okay, it's called jump. Now, let's quickly double click on the jump input action. So action description, I think let's describe it as jump input. I think that's simple enough. Is it triggered when paused? No. What's its value digital boolean? For a jump action, I think that Boolean is perfectly fine. Now, with all of that setup, we'll close that up. And now that we have our jump here setup, let's go into the player map once again, the input map. It has all over inputs for movement. That's cool. We'll add another Whoa. We'd go away, add another mapping. So that mapping, it will be an input action. Let's come over here, and the one we want to select is jump since that's the asset we just created. That's cool. We'll go under jump, and now we need to make a decision of what we want the jump to be? I'm going to set it on keyboard to be W W is fine. Let's add another one. W is core. It keeps expanding them. But anyway, let me also make it space bar. I think that works perfectly fine. But then let me quickly connect my controller. So now the controller is connected. Okay. Yes, NRL Engine has recognized that I've connected my controller. So we'll add in another one. And I want, I guess, anytime the player presses A, but it's A on Xbox or X on X on, you know, No, it is A on Xbox, X on PlayStation. So this should be working correctly. So now our jump action is set up. It works when we press W. It works when we press Space Bar, and it works when I press that X button on the controller or A, if you're on Xbox. Anyway, so with everything you're setup, let's go back into the player blueprint. And we're going to add in some code to handle the jump. So let's zoom in. I want to look for jump, and then I'll go down and it should be enhanced action events. There we are. Let me zoom in a bit more. Enhanced input action, jam. The action value is a Boolean, so it's on or off. So once this is done, what we need is to simply drag out triggered and let's say, Hey, jump. Essentially, we have a jump done just those two nodes. So to test it out, control S to save, and then I'm going to come over here and compile. Now let's go into the level. Go to play within the level. And then, let's test it out spaceb. That's cool. Space B is working, but that's not what I wanted. Let me turn off that being recorded, being no, no, no, I don't need that. Press press press Space bar? Okay, we have a jump. Moving left, moving right, cool. Jump with Spacebar is working, jump of W is working. And then hold up, Exon controller isn't working. That's a problem. Let's go back and quickly double check. This might be entirely a M issue. Oh, not here. I need to check the input in the player map. Oh, Control S to save to double check again, click on that. Gamepad, face, bottom, bottom. Okay, cool. I guess I must have done something wrong. Gamepad, perfect. Okay. It should be working correctly now. Once again, quick test. W is working, Spaceb is working. X on the controller or rather the face button down work. Okay, cool. Now that we have the jump working in terms of code, the next thing to do, remember, DCAA, design code art animation. Next, let's go and add in some art. 20. 019 Adding A Jump Start Animation: Now the beautiful thing is you already have some nice sprites for the jump. We'll simply go back up characters, the player art, and this is all the art. We're just quickly going to type in jump. Okay, so we have a couple of different jump animations, okay? So we shall simply select these three, okay, these adventure jump zero, zero to jump 003. These will work. And then with all of these organized, we shall simply right click Sprite Actions and then, you know, create sprites. So now that we have created those sprites, we'll type in jump again, just double check and see. So there we have it. We have those three sprites. Let's simply click on all of them, and then come over here and create a flipbook. We'll create a flipbook and right now it's saying adventure jump. We can call it jump start. The reason we're calling it jump start and you can see it over there. That's the animation is because the animation of starting the jump might be different than the animation when he's dropping down and we'll get into that next, but this is good enough to get started with, we'll simply select this and dope. Now that we have that basic animation setup, go back out to characters once again. Now, let's close of the text, the player animation, and we'll go to animation source, paper D. It already has our idol. It has our run, and we're simply going to add new. And double click on that. Let me rename it. We're going to call it jump, dash start. Okay, because it's just going to be for the start of the jump. After clicking it, come over here, and then there we are jump start. And that's the animation. So we have our jump start. We have our run animation, have our idle animation, then have our jumping. Yeah. So next thing we're going to do is we want to test this out. We're eventually going to come back and adjust the frames so that it fits with the character more, but this is good enough to start. Next, we're going to come back to the hero. Here we are, we have this basic jump. Now once it's triggered, is when we want to play that animation of Hey, the character is jumping. When the character is in the air, we want to know that hey, they are jumping. Now that we have that, we have this here and our animations. Let's also open up the animation blueprint. We had it on receive Notify. We can close that. We are back here. We are back here. We have our idle, we have a run, and next we're going to create a new animation set, and we're going to call this call it jump start. Okay. Because there is just the start and then there is when the character is falling to the ground. Now, we'll drag out from idle to the jump start. We'll also drag out from running to the jump start, okay? And we'll go from, let's see, from the jump start, mm mm. Let's see. No, why move. Come on, move. I want to move. You okay. So this is it. So this is our map right now. 21. 020 Jump Animation Transitions Logic: Now we have this proper set of nodes ready. We will go and double click inside of the jump start so that we can actually attach the output animation and then we'll simply hit play jump start. So those initial starting frames after the character has jumped. So now that I've saved that we'll go back to the graph. So anytime we add in the code, it will go from idle to hey, it has started jumping. Now, this simple way to know when the character should go from idle to jump is we'll go inside. We'll bring out the as hero as always. And then now that we have access to that, we shall come out here and we shall get velocity. And we want to have access to its velocity. This is the really simple way to know when a character is jumping. And then we'll say a greater as long as it's greater than zero, it should be able to enter that. So let's compile. So basically, if its vertical velocity is greater than zero, we should see that jam animation. Now, let's quickly show this. So right now, the characters in ido have hit Spacebar. Notice, it's playing the jump animation, but it's not coming out of the jump animation. So to make sure it comes out of the jump animation, we go back to the blueprint. We will click and drag from the jump start back to idle. And then inside of idle, actually, I prefer to just copy this so I don't have to re type everything. But inside of here, I'll add in the same code going from hey as the hero, the velocity. But this time, instead of saying, Hey, are you greater than, I'll simply say, Hey, are you equal to? So if it's equal to zero, it can go back to idle. Let's quickly compile that, go back into the level. We at IDO, we're jumping, we're back to id. We can walk. We're jumping back to idle, we can walk around, jumping, move around. Okay. That's cool. That's actually not bad, not bad at all. Now, there are many ways we can handle that jump. One way we can handle that jump is by simply going to let's see where is the jump we go to at on jump. Keep typing Jumo for some reason. So we'll go to the jump start. We'll go to that flip book. One way to handle it is to simply come over here and just set it something like three frames per second to start. Okay, that's fine. Alternatively, I may just delete the first key frame, set it to only play the last two frames. So let me delete the second as well. So now it's only playing that kind of floaty animation thing. Let me increase it to six frames per second. So it looks like it's doing that, then we can just close that out. So now, I think that's a much more realistic and reasonable jump animation. But notice if we're moving left to right and we jump, we do not have that animation transitioned into only when we are at IDO that we're able to do that. To fix that, we go back to the blueprint and we'll use the same kind of logic, go back to the animation graph inside that state machine. Now we can go from Run and we'll basically get the same code come in here, copy all of that. To go from run to jumpstart, as long as the Z velocity is greater than zero, it will go into that animation. Then we'll copy the same code. So now, oh, no, no, that's going from jump start back to run. Paste this. So anytime the Z velocity is exactly equal to zero, it will go back to that animation. Now, let's see what that looks like. Here we are. Notice that I jumped and it's playing that jump animation. So it's kind of chilling in the air. And that is basically the simplified and fundamental way you can set up your jump animation. Now we have our jump animation. We have the code for the jump. The code for the jump is basically here. And if you ever want to change any of the jump characteristics, you simply go to the character movement component, and then on the right side, under details, there is a lot of variables to play with. Let me just quickly type in jump so that we can see some of those. And you can just see a lot of things that it will show you. I will show you jump velocity. You can increase that, break deceleration, and there's a couple of others. Now, we can go into this later when we start talking about creating levels and designing that because generally speaking, you base your levels of how you want your character to move. So we'll get into that. But for now, you have a grasp of the basics. The next thing we're going to do, remember, DCAA is now to add some sound because we want there to be an audio playing right after the character jumps. Let's get into. 22. 21 Jump Start Sound: Okay. Now, let's go in and just add in a jumping sound. Now, inside of your course files, I have added in some basic jumping sounds. So let me quickly go to audio and create a separate folder called jumping. And inside, there are two jumping sounds. Number one is the jump start. Okay, it's a bit too silent, but there's a jump start sound, and then there is a jump landing sound for when you land on the ground. Okay, so those are the two sounds that we will be using. But let's start with just a jump start sound. So currently, let me zoom back out. If you go in, you can hear that sound when you move left and right. But there is no nice mity sound when the player jumps. So we are going to correct that. So let's go over into our player again, and then we're going to add that jump sound. Let's go into it. So this time we will not use the animation blueprint for adding that sound because this is a sound that you want to have just once. Now, there is a way to add the sound. It's simply going to be we'll start by Control Space bar. We have this player jump start sound. We're going to select it, and then up here, we're going to create a queue. Now that the queue is created, I'm going to name the player. Let's call it jump start. That's the start of the jump. Now I'll get that and I'm going to drag it under the paper flipbook. Want it under the paper flip book. It's right under here. I'll select it. Let me go back into the viewport. This is a reasonable location for the sound to be. I think that's an okay location. I'll leave it over there and of course, come down here. Make sure. Let's see override attenuation is clicked. We'll leave it there and we'll set this to natural sound. And then we want to make sure that it doesn't play on start, so we'll scroll down. We look for auto activate and turn off auto activate. Now with that done, let's tell this jump start to play when the player jumps. Now, there are two ways to do it. Actually, there are many ways, but I just wanted to show you something about how unreal engine thinks. If we drag it here and we pull it out and say, Hey, play. We basically told it to play. We've told it to play. If we connect it under triggered, you said when triggered, do the jump animation, and then after that play that sound. If we connect it here, compile, go in. Now listen. Okay. Now you can hear it actually. I'm going to need to increase its volume and it's actually working correctly. Come in. But it's playing when I release the button. Let me put my buttons on screen so you can see. If you move. Notice it plays the sound when I release the button. We don't want that. Let's break this link. We want it to be here on start. Now that we've set it up to work on start, come in. It plays immediately, it starts. Now, to make the sound even better, let's come over here to the jump start component, okay? This one right here. And then what we want to do is want to increase the volume. So I'm going to increase the volume to something like two. So let's listen in. Hopefully, it will be much more audible because there are some things you want the player to really hear like jumping. Okay. Yes, at two times the volume, the jump sounds good. Now, now that you're done with that, let's move on. We've added in a jumping sound. Now remember, it's DCAA, design, code, art, and audio. We've done the code for the jumping. We've done the art, and we are now done with the audio. Let's move on. And in the next video, let's just add some sound when the player lands. 23. 22 Jump Landing Sound: All right, welcome. So now we are going to do a simple jump landing sound. Okay, so to do that, the first thing that we're going to do is we're going to go to the Iroharacter blueprint. So as we've organized before, if you simply come back in and click on that, right? And for anyone else, you basically press Control Space bar. We've organized our blueprints properly, go back into the player. The hero blueprint, and we'll go to where we set up our jump handling. Now, for the sake of simplicity, I'm just going to copy that basic comment box, put it here, and then I'm going to say, Hey, jump landing sound, so that I know that all of the code in here is for managing the jump landing sound. Now that we have that, the next thing is to simply come back to where we put the player footsteps, and then I'm going to select to duplicate it because we already have some basic settings like for audio management that I want to keep the same. Now that that's done, we'll simply call this jump landing. Now that we have that jump landing object set up within our player, let me compile. I'll drag that out and drop it right here. This is where we actually get deep inside of the basic code. I've zoomed in. There is a jump landing node. We want to drag this out. After dragging it out, I'm going to press play. So we'll bring out the play node. So we have our jump landing and we have our play node, which is good. And now we simply need a simple way for Unreal Engine to tell us that the player has jumped. So the simple way to do that is I'm going to simply right click and I'm going to type and, and notice there is already an event called On event On Landed. I'll drag this out. I'll connect it to play. And we are done, fundamentally, kind of, but we're not yet fully done. We'll go back to the jump landing. Now that I've clicked it, you can see that right now it's still set to clear footsteps. I'll go down, rather, sorry, I'm selecting the sound. Inside of the assets is already the asset for player jump landing sound. Now click that. But now it is set up so that it will play the player jump landing sound now that that's done I come in here. With everything set up, I compile, come into the level, press play. Yes, you should be hearing that. Nice. Now, of course, just for quick testing, break the link. Let's quickly. Did we compile? Make sure it's compiled? No landing sound. Come back here and then connect the event on landed to that play, compile. Now there's a landing sound. Yes, I hope that's audible. If you can't hear it clearly in the video, maybe because I've kept the desktop sound too low. I apologize, but it should be very easy to hear that in game. So next, I'm going to upload some new lessons all about designing platforms for your two D game. Now, one thing a lot of you may or may not have noticed if you are getting this course later is I disappeared for about a month. I was actually in hospital, but now I'm back. Everyone else, don't worry about it. Just enjoy the rest of the videos. Let's go. 24. 23 Adding Platforms For Platforming: All right. So now that we have some baseline movement working, now we're just going to add some platforms that we want the player to interact with. So to do so, essentially, we'll come over here to quickly add an object, select shapes, and I would like to add in a simple cube, and there is our simple cube. But where it's positioned now, if I move the player, the player won't interact with the cube. So I will want that cube. I'm going to select it. And then in terms of its position, I will make sure that, hold on, it the Object that has a problem? No. Okay. I've selected the object. Set it to zero on the y axis. Actually a bit more than zero because we want it to No, zero is perfect. So zero and then on the X axis, I'll set it to zero. Now, that moves it right into the player. So let's have it a bit more to the right and then a bit further to the ground. So on Z, I'll set it to at 50. Okay, so this is a nice simple platform. Now, when the player jumps, basically, when I press up, notice the player is now on top of the platform. Come back here, boom. But we have a little bit of a problem. Notice that where the player's feet is just above the platform. So when the player is here, the player is above the platform, which is not really what we want. The reason why this is happening is because the capsule collider is interacting with the world. So we want the player's feet to actually be touching the platform, and we'll need to stop the capsule collider around the player from interacting with the world. So when we come in a bit closer, you'll notice you see that space, that space right under there. Want to get rid of that space. Now, in order to do that, we're just going to change the position of the paper flip book so that where the feet are is on the ground. So let's go into the character right over here. Cool, that's where our flipbook is. And then I'm selecting the flip book, and I'm just going to adjust slightly its Z position. There we go. So just I've dropped it down just a bit on the z location. Now let's have a look at that in game. Now it actually looks like the character's feet are actually touching the ground, the surface, which is really, really good. Okay. So there is this short object that is now in the wall, and we are able to jump on it, and we can start considering adding in some more platforms. Here we are standing on it, jumping off it, coming off it. Okay. This is a start. Now let's add in a bit more to the platform. Since we have that one platform over here, we shall simply select it. Let's do a quick copy and paste, and let's see let's set it up. We know that this platform is about what? It's about 50 on the Xaxis. So let's bring this up to about 100 on the Xaxis. And move it a bit more to the left and see, can the player make this jump? Yes, it is possible to make that jump, but it's not possible to make this jump. The player's jump right now is really, really short, and a short jump means that we can't really do all that cool platforming. So in the next video, we're going to look at how to adjust the player's jump height and a couple of other things to make the jump a bit more enjoyable for a platform. 25. 24 How to Customize player movement and jump: So when we go into our best asset, there is something known as the character movement component. This is the one that determines all of the properties of character movement. Now, quickly, if we look into it, there are going to be a couple of things. We have gravity. So right now the gravity is set to one. Now, if we go into game and the character jumps, that is how fast it goes back to the ground. But if we go back and we change the gravity from gravity one to gravity, let's say, five, so we can see a big difference. When we go back, let's quickly compile. When we go back, now, the character comes back to the ground very quickly. Now, if we go for something a bit softer like gravity to, I just change the gravity two too. Now we come back and the gravity is now set to two. Gravity determines how quickly your player character falls back to the ground. Now, since we've increased the gravity, we need to increase the jump. We want the jump to be much higher. Now inside of these settings, notice there is a lot, acceleration, breaking factor that's slowing down, estimated mass, default movement, don't worry about swimming. We don't need that here. Then we are talking about walking. Now what is a step? A step is the highest height, your character can walk over something. You have ground friction and walk speed. You can always adjust these to your liking. What we really want to do is to change the jam. Now, currently, the jump Z velocity is all 20 centimeters/second. Since we've doubled the gravity, to get the same jump height, we need to double the jump z velocity. Let's make that eight 40 centimeters, sorry, eight 40 centimeters second, which is 8.4 meters/second, which is okay. Now let's quickly zoom out, compile, go back in and see the difference that makes in our jump. So notice it jumps high and then comes down to the ground quickly. And now we have what I would like to call reasonable movement for a platformer. We do need to make a couple of changes, though. Now notice, let me put my inputs on the screen so you can see what I am pressing. Notice that right now when we move left and right on the ground, we move at a certain speed. However, when I jump, I basically lose, I've jumped, I'm pressing, right, I can't. I've jumped, I'm pressing left, barely any movement, which isn't really smooth for movement platformers. Notice if I'm moving, I can make that jump. However, if I'm not moving and I jump, I can't make that jump. That is controlled by something called air control. Now, when we go back into our hero, we want to look for air control. Right now, air control is set to 0.05. Let's set that to. Let's set that to one. And now when we go back in and we are changing how it feels to play a character, when I jump, notice I jumped and I still have that movement. So when I'm here, I can press jump and still move to the right and still make it. Now, just those few basic changes, I think we've made a reasonable enough platform in terms of basic platforms that we can have. However, because we are using the DCAA philosophy, now we have some basic platforming that we can set up. This is how you think about platforms. They're just things the player needs to manage and you can set this up anyway you like in your game. We now need to figure out, how do we add some art to the platforms so that they look good? And we're going to make a small camera change in terms of how the camera looks, and then we're going to come in and adjust some of the art on the platforms. Now for the camera change, I'll simply go back to the hero blueprint. I will select the camera, and one change that I like when I'm working on platformers is to slightly increase the Z height location of the camera. Let me add maybe just 50 units, which that change, what it means is that now when we look at how the player is being looked at here, the camera is slightly above the player character. So notice it's not flat with the ground. We've raised it just a little bit so that we have an easier look at the different platforms, which is core now what we could do on top of that is we can slightly adjust the rotation. Now, the rotation we're going to select is probably, let me double check. Is it X? No, it's not X rotation. It should be the rotation on this yes. We're going to rotate it down by negative ten. That's it. On the Y axis as far as rotation. Which means that the camera is slightly pointed down. As you can see, when I adjust the Y rotation, I can point it down, I'm making it negative ten. It's a slight thing, but it just helps the player able to see more of the level because they are looking downwards slightly. Now after making that change, we can actually raise the camera let me raise it up to about 80 units. So that should give us a good view of the world when we are looking down. This is good. And you can make all kinds of adjustments to this to make it look just right for what you want. Like, now, I think I want to bring the camera in a little bit closer. From negative 500 to maybe negative 450 to keep it looking good. And let me raise it up in the sky to about 100 units on the Z axis. On the Z axis, it's up by around 100 units. This is just to teach you, feel free to adjust them to something that you are comfortable with. But for me, this is good for platforming. We get to see a lot of the background. We get to see the ground of the platforms when we are on them. This is cool enough. Alright, now in the next video, let's just add some art to the world because we have a basic character movement dialed. We have some reasonable movement and jumping, and we've seen how to put some platforms in the world. Let's do that in the next video. 26. 25 Adding Platformer 3D Platform Assets From Quixel: All right. When it comes to adding in assets, the first thing we're going to do is a little bit of organization. So make sure you create a folder in your content folder, and please call it environment. I have also added a folder under called Village because you really want to have your environment assets organized and then create a blueprint and call it platform Village. And the type of blueprint you should create is a simple Actor blueprint. Highly recommended. Now, when you double click inside that blueprint. Oh, open full blueprint Editor, okay? Notice, it is a basic simple empty object. And if I come into game and I drag it and put it in front of the player, there's nothing. Now let's add in some environment assets. So if you are a three D modeler and you have the skills, you can simply design your own models and import them. Or you can add them in from NRL Engine Marketplace. Personally, just for today, I'm going to show you how to use QuisLbidge. Now in Quisle you'll sign in using your UNRLEngine developer account. And then let me just type bridge since we're in Quisle Bridge and type search for bridges. And let's see what it brings up. This is all core. Let me select the Japanese stone bridge, and I'm bringing it in in low quality. The reason why I'm bringing it in in low quality is because this is a 2.5 d game, and I don't load it up with a lot of needless assets in terms of complexity. That puts a lot of pressure on GPU VA. That's an optimization thing, but you can do what you want. Once it's downloaded, you can quickly add it to the project. Once you're done, adding it to the project, we'll simply go back. Notice that there is now a new folder old mega scans and go into it, Japanese Stone Bridge and double click the Japanese Stone Bridge. Now, while we have this asset here, if we just drag and drop it into our platform village, it's not going to have any collision. So what you want to do is inside of details, you want to search for collision. Which gives us access to all the collision settings. Make sure you select the simple collision mesh to be its own base mesh, okay. Make sure to select it so that its mesh is being used for those collisions. It shouldn't be on none. It should be on its own mesh. And then set it's collision complexity to use complex collision as simple. Basically, it makes sure that the collision only works on the part where there is actual three D object. It's a really cool, simple change. The player can walk through here, but everything else has collision working. Now with that setter, let's go back to the platform. Now, inside of the platform, I'm hitting Control and Space Bar, and I'm just dragon dropping it in over there. And with that drag and drop, let's go into game, and there it is. And when I hit play, the player can walk over it, which is really cool. Which is really cool. And we can simply get this and copy and paste it, and then drag it out here. So now we have a little bridge being made, which is really cool. Okay, which is really, really cool and really, really simple to have. And if we want to now start making platforms, we could just get this copy and paste it, drag this out here, and raise this up. Let's see if the player can make the jump. Coming here. Boom, and the player can make the jump. That is the simple way to import assets, make sure they have the right collision for your 2.5 the platformer. One last piece of advice is try to. There are a couple of other things we could do with the platforming, like adding in jump safety, but I don't recommend doing that. I think it's just better to test your jumps. It is less headache for you in terms of bug fixing and other issues, and it is better to design levels clean so that every jump is possible. With that, let's move on on adding some environment to the world so that we can bring it a bit more to life. So adding in a three day environment. 27. 26 How to add assets from unreal engine store for your environemnts: All right. So we are now in the Epic Games store, and now we have gone, and we've picked out an environment. Find any environment that you like. In my library, I find that I have a couple of environments. If you want to keep it simple, you could pick up any of Unreal engines free samples. So like right now in the marketplace, if you go in and these change week to week depending on when you get this tutorial, there is a free cavins. There's a couple of other assets like there's a stylized Paris Street. These are available to you for free to use for learning projects, so feel free to utilize any. For today, though, the environment that I really wanted to add in was this stylized environment, and adding it to a project is really simple. You simply click Add to Project. You select your project, and it will add that to the project. Now, in the next video, I'm going to show you how to access all the environments here in your project, and we get into uh, moving on from there into some other little technical details. Now, let's go into that. I'm here waiting for a download. I'm not going to make a long video as we all wait. Just move forward to the next video. 28. 27 Adding Assets Part 2: All right. So I have added the Infinity Blade temple to the project. So let's go in and see what we get. So now you'll notice there's something Environment Park two, which has blueprints, effects, maps, materials. It has everything, right? But let's start with the measures, right? So these are the measures. Those are all three D objects that we can use. And if we look at the world right now, so there is a couple of things. There's the active area. And in the 2.5 d game, this line over here is the active area where the player is. And then there's all this over here. That's the background. And the background is something we want to add some life to. So let's do this step by step. For starters, let's add some life to the ground. So we'll simply select the ground. And in terms of materials, we'll change the material. I'm going to search for a material that is more the ground. So let me search ground. There's the ground, there's dam material, there's pet ground. Let me do dam ground to start. Let's see what this looks like. All right. So now all of a sudden, the ground beneath the player is looking a lot more granular, a lot more real. Then the next thing we'll do, let's add in some background. So let me see. So inside of this, there is this huge pillar over here. Let me add that in. So even just adding in the ground and the pillar, we're slowly getting a much more lively environment. Let me add in a couple of more assets. I'll add a little house over here. Notice that that's a very big house. I don't want it to be here as a large house, I'll select it. No. Interesting. Why is that? Okay. That was definitely an interaction. I'll move this for a bit further backwards there with you. So we have that big temple in the background, and this is how you add in assets. Now, depending on what you want and how you want the look of your environment to be, you can add in different elements to the world. Now, another thing is, you'll notice that right now we can see the edges of the world. What we can do to stop seeing the edges is you can quickly select the ground object, which is the floor. Go to scale and we'll simply scale it to about 50 on all sides. So now all of a sudden, it's fully scaled, so we can't see its edges. It looks like general ground going to the distance. If 50 is kind of too big, that's fine. We do 25, it will still have the same effect. Alternatively, you could set it up so that there are multiple ground tiles that spread out in different directions. Just don't be too resource intensive. Now, keep in mind us as the developers we see all this however, a player will only see this over here. Okay? Now, we're going to adjust the sprite so that it fits in a bit better with the world as it is. We want it to have a material which allows it to cast shadows. Since there is so much texture everywhere, having the player cast shadows is going to be better for the look. Let's get into that in the next video. And actually, before the next video, I want you to know I'm going to be doing some general addition of assets. It won't be any assets on the main line where the play actually is, just some environment assets. You can do that as well. It's just window dressing for the background to the next video. 29. 28 Watch me do some basic level design and how I think about basic levels: Okay, so this video is just kind of mis speeding through some basic for lack of a better word. I won't even call it level design, mostly just placing some things within the level and just adjusting them. Is that level design, I guess that's level design. But essentially just using these assets and trying to position them in a way that is logical or going from the beginning to the end of the level. That's cool. And then I want to just have it make it so hole Oh, wait. What? Okay. So I'm using a lot of the keyboard. Let me even show the keyboard, actually, 'cause I'm using a lot of hoping and pasting things. Uh huh. Okay, that's cool. But then I want, so there's this cool arch. Nope, I'm deleting that. I don't need that. Essentially, I just want to have a set of a couple of different assets that kind of make logical sense to have so that there is sort of an environment. Okay, that's just a plate. Now, if the sap good that we have some continuity. And then we'll add in some cliffs. I'm going to rotate these because without the rotation, they don't make any sense. Perfect. And then drop this down into the ground, move it slightly to the left and then bring this further back. So we have that. Let me see what the player would see. The player will see like rock, and oh, actually, let me change the position of the sun. I remember correctly, adjust it. Just the positioning of the sun a bit. Oh, to adjust the position of the sun, I'm pressing Control L. Just control and L. I mean, I can't have it be total dark. Color will be fine for now. Maybe it won't be that fine. For some reason, my sprite is being super luminous. So all I'm going to do is come back into the hero. I'm going to select that paper, flip book, masked, lit. Let me see. Illumination is usually what it is. Oh, my goodness no. Let me see. It's being way too bright. Let's see. Bright color. Let me drop down its brightness value from here. Hopefully that will help reduce how bright it is. Let's sees play. No, I helped a bit, but it's just bright. I think what I need to do is I'm going to go in to project settings. And then I'm going to search for something called auto exposure. Yeah, you see this auto exxposures the one that's messing with us. I'm going to click Auto Exposure off. And with that, let's see how the world looks. Yeah, this is much more reasonable with Auto Exposure O. But now let me adjust Control L. Let me adjust the position of the sun once again. Yeah, much more reasonable. And now let's have a look at which material. It's using a mask sprite lit material. We want sprite sprite lit material. Okay, it's not showing me the material here, but to fix that, I'll go back here. And then I will request, let me see the settings. One of the settings should be one of the settings here should be Show engine content. Okay, so now it's showing engine content. Now that it's showing engine content, I should see more materials. So I'm going to say sprite. You've got to be kidding me. No, I need lit Sprite. Oh, sprite. Although I need to make sure I'm using the right name mask unlit sprite material. And masked it. You've got to be kidding me. Oh, my goodness. Where's the mask lit sprite material? You got to be kidding me. I was typing this material. Okay, so it's not showing me that here. Let me go back. Coming back here under settings. Let me see. Show localization, show developer content, Show developer content. That shouldn't change anything. Actually, let me see engine content. Nope. No, I don't need any of that. This is actually going to be difficult to find. Where is that material? Come back to hero paper, flipbook, look for shadow cast shadow. The flipbook is false, I've set that to true. So let's see, does it cast shadows correctly yet? It is casting a shadow of some kind, but let me adjust the sun double check. The sun is now there? Yes. Now it's casting a shadow somewhat correctly. That's fine. That will be enough. Then just the sun once again, man, let me zoom out a bit as I'm adjusting this. Huh? Where did I move the sun? There it is. Way back there. I want it to come here. You know, it's working on it's basically making it so the sun is moving to the negative direction. So I'm not used to moving like that. That's why I'm kind of struggling. But yeah, there we are with a proper shadow on our spite and proper lighting. I think this is a lot better. However, let's look at the logical spacing of the world. So what we'll set it up as is we're going to make it so that the player character starts here. So since it's starting here, let me actually hide engine content. That's clattering up everything. I'll select measures. And then I want the player to start. So the player starts here, which means that I can adjust this and make it negative 90 degrees. So this is where the player is going to start from, okay? And then I want behind that to be this. So it's clear Oh, man, that's a kind of terribly placed asset. Let me get that and copy and paste it, bring it back here. I want it to be clear to the player that there's no moving back from here. Okay. But that's clipping. I don't like that clipping. By clipping, I mean those two assets are connecting in a way that doesn't look natural. So I'll bring this back. Actually, I turn it I could just do that, and that solves the clipping problem. This looks a bit more natural. Maybe let me move it forward just a bit. Okay. Perfect. So we have. This looks reasonable. And then when I hit play, actually, let me quickly move the player asset from here. Now let's, let's select that player asset, move it way back. I want it to be right here. This is good. I have hit play. Okay. Not bad. However, I don't like this thing's collision. I don't like its collision. Let me now do a quick check. Is it adjusting the positioning on the X or Zaxs? Is it seems to be adjusting where the player is on one of the axes. I don't like that because that means it's going to start interrupting where the player is. So I'll select this again. I will move its position. Move it solution here to be zero, zero on the y axis. This can really stay in the same position. It won't change anything. Oh, no, it's leaving a hole. I don't want there to be that hole. Let's move this forward a bit as well. So this is where the player starts. But for protection, we are going to add in some bounds. Now, what do I mean by bound? What we are going to do is we're going to add what we want to have it called a block? Yes, this is a blocking volume. And we're going to place this right over here. Is it in the right place? No. Let's move it forward here. Basically, it's an invisible wall, so the player cannot cross. So now when I hit play, the player can't cross. The player cannot cross, which I think is really cool. All right. Now that we have that up, I am going to also add something else. I think I'm going to add in let me see. I'll come here visual effects, post processing. Exponential height fog. Now, with that fog, let's see. I want to add in exponential height fog. Fog density, let me increase that Boys good. Ah. This fog is not interacting well with the world, so I'll delete that. I'll come over here to our baseline exponential height fog. Oh, it has to be way, way, way high to start interacting. So I'll raise this up by a bit. I'm trying to get back up to the world. Was my main actor. Hero, double click on him so I can get back up. Okay, so I'll select the exponential height fog and then let me raise it up. Okay, so yeah, that adds a bit more fog. So at around 3,000 Perfect. That I think is just the right amount of fog. Now we need to fill in these gaps because there is a hole in the level there that I don't like. Maybe I'll capture this. I'll copy and paste it, drag it here, bring it back, and then I'm going to rotate it a bit so that it doesn't look like it's the same rock formation. Click that, bring this back as well. Let's see how it looks beginning to end. It looks like there's some rocky formation there. Rocky formation again. And let's move forward through. Look, there's a watch tower like thing here, but I can't tell what it is. We're just that so that this is closer to the ground and see that. Then there are these two platforms. But I want there to be even more stuff here. Copy and paste that rag this out here. No, this won't look good enough. But let me rotate it a bit, see if it fits together. Okay, kind of sort of fits kind of sort of kind of ish. This is kind of sa. Bring it here. Okay? It kind of fits there. Will anyone notice this gap I think people will notice. Okay, so then I'll select this. I'll double click on that, raise this up a bit, move it backwards a bit so that that rock formation is there. I just want then we rotate it. The X axis, no. Spin it a bit on the Y. Just a bit. I don't want the player to see anything weird, but we need all these gaps filled up. How will it look from the ground? Yes, there is clipping there, so I'll move it backwards. Okay, so now there's no clipping. This looks like an actual proper rock formation. But now these two, I'm going to select both of them using shift, bring them a bit closer here. And with those two there, I'm going to add in. I want another mesh. I need another mesh. Need another mesh, give me something cool. I think what do I want stairs, maybe another gate. No. What I want is a mountain. Since I want let me first see if there is a mountain in these assets. Nope. So in order for me to have a mountain formation, I'm just going to double click this, push this backwards, and then I'm going to scale it up. And then move it backwards, backwards a bit. Then let me copy and paste that. And then I'm going to drag this out right over here. Then I'm going to push it in once again so that it matches up there. And then last but not least, I'm going to get this, and then I'm going to copy and paste it. But the paste, I'm going to move it along the X axis by about what? Move it along. Let me zoom out a bit. Let me just drag it right out here. Let the world keeps going on from here. Drag that out. Boom. Then I'll get this. Copy and paste that, drag it here. I'm going to spin it around on the Y, bring it in close, copy and paste it again, drag it here, spin it around again on the Y. Push it out here and then push it in here. Now, okay, I think in terms of like super basic level design or rather environment design, this should work. So I'm going to come down right over here. When I hit play, the player starts from here. They really can't see much of anything else. This looks kind of sort of normal. Nothing very sas yet. You move. These are some rock formations. I we need to add some platforms there to give it some life. But then you keep going, Oh, these are the little platforms that we are using to test jumping. That's cool. Okay, bye bye. Keep moving. Oh, look at this. There are like these two stone statues over here. I wonder what's happening next. Oh. Oh, this isn't on the ground, but that's easy to fix. And then move, move, move. Oh, Bosht area. Okay, hold on. Hold up, hold up. Get this. Make sure it's in the right position, bring it into the ground a bit. Let me select the player. Where's the player? The player, let me move it to 3,000, which is right over here. I've moved it forward. So let's do this test, rap, ra, ra, ra, ra, boom. And then this area over here is going to be where the boss fight is hard. And then there'll need to be a blocking volume there. So that the player never gets the idea to cross that. So to do that, let me see what would I want to add Let me just no, no, no, actually. Yeah, no, I'll use this. No, I don't want to use this. I want to use something else, something simple, which will just block off that area. Oh, this looks good. This looks good. So I'll get that connect it over here. And boom, now the player can't move past here until they've defeated the final boss. Now let's also scale that up a bit. And now that it's scaled, let me move it back a bit. Bring it forward and perfect. This is it. I think this is the baseline. Okay, this is a good enough generalized level layout. Now let me select the player. Drag him all the way back all the way back. Over here. I play. So this is where the player starts and move back. Okay, one moment, someone's at my door. Back from answering my dog. This is really normal game development stuff, by the way. Um, life doesn't stop 'cause you're game diving. Okay, so when I look at this now, it's not the best thing ever. But all do, you can always, with more time and more love, add in even more things to the world. It's cool. Hmm. Anyway, let's move on. And in the next video, we're going to go in a bit deeper with platforms and see how to do that, as well as, you know, managing a death and health system. This has been kind of different. This isn't really a tutorial video. I do hope you learned something. I wanted to show you a bit of how to add in and organize assets to make a level. But I am so sure you can make one way prettier than this. And when you do, hey, send me the picture, okay? I'm actually interested. Good staff, let's move. 30. 29 Share Feedback Teachingand Learning Quality: Now that you have spent some time in the course and learning, I am interested in getting your feedback on how the teaching is being received and how your learning is going. I know what it means to go from basically near the bottom of the class to the top. And what strategies are used. So if you're having any challenges learning, just reach out to me. I reply to all messages within 24 hours. And then as far as my teaching style, please give me feedback on if anything is unclear or not well explained and demonstrated. It is really my responsibility make sure that all the knowledge is presented well and you have everything you need. Who practice everything that's taught in this tutorial. Besides that, we're moving on with more lessons on how to create combat systems and AI for the 2.5 d platform. Let's move on and p learning. 31. 30 Course Progress knowledge check: Now, in this video, I want you to do a quick knowledge check, and you only need to ask two questions. Number one, can you do it? Number two, if you don't have the ability to do it, go back, re learn and practice doing it once or twice, and then you are able to move forward. This is the most important and pivotal key to truly learning things. With that, let's go through each of the things that you've learned so far. So we started out with learning how to get Unreal Engine and make a project in Unreal. And then we moved on to how to make a basic developer level that is plain for us to start filling it out with what we need. And once we were done figuring out how to set up that developer level, we moved on installing paper Z D, which is unofficially supported plug in, which we're going to use for managing our different sprite assets and animations in game. Then we moved on to adding a basic player character to the world, which is going to be the thing that would be using to interact with our game world. This was the initial setup without adding any ability to move through the world for the player character. And then we moved on to how to import sprite art into Unreal Engine. And then we moved on to setting up idle animations for the character in the game. Once that was done and we had interacted with Unreal Engine, we moved on to some general tips on how to plan out your game designs as a game developer, which is basically meant to teach you how to reduce the amount of time you'll waste and focus on the things that you've laid out for your game. And after that, we moved on to understanding how controller inputs work within Unreal engine and how to utilize them. Now, with that dialed in, we went on to how to actually add movement, left and right lateral movement to the player character. And right after that, we moved on to actually adding in the animation for running when the player is doing the movement actions. And then there are multiple videos on how to add in the right sound for jumping, landing, and moving in the world through running. And then we got into how to add three D assets into the world, bringing some life into it and how to work on their collision so that they're interactable. And the last video was all about general level design and some recommendations on how to organize your assets in your levels. And with all of that out of the way, that is the end of the general basics of the course. And now that we have that foundation laid out. Let's move on and get into some much deeper understanding of in game AI, as well as combat systems. If you have and have a good understanding of everything covered so far, please feel free to move on. If anything is not yet dialed in, feel free to go back and learn before progressing. With that out of the way, let's move forward and keep learning game development. Let's go. 32. 31 Resetting The Developer Level To Clear: Now to make some quick preparations for what we are going to be doing next, we are going to now set aside and separate the main level, which is one level, which we will have created by the end of all these tutorials and our developer level. Now you'll notice right now we have a ton of assets placed in here, but let's make some adjustments. So control spacebar right now under levels. We have a developer level, which is this. I am simply going to select it, and I am going to duplicate. Okay, there is the duplicate option right there. And after hitting duplicate, I'm going to call it 001 dash level one. Okay. So that's its name. 001 dash level one. And then I'll select the developer level. Zoom out. And what I do want is to remove a lot of these assets. So on the developer level, I'm going to just delete that, delete that, I don't want that. I'll delete that volume. I want the developer level to be as sparse as possible because I want the developer level to have just a handful of assets. It's where we're going to be testing out our MAI, there is no need for it to have a lot of stuff inside it. Always good to have the staff just to learn about how to place assets. That was the purpose of that video. But now we have this, and then I'm going to select the player character, and I'm going to adjust its location on the X axis from negative 8,000, select our hero to zero. So now it's back here. Then I've selected the ground. And I am going to notice what I'm clicking here. Going to just slightly revert it. So I'm going to reset that property. I've clicked on Reset the property, and that should be that. And now that I've reset that over here, I've reset it to its default material by clicking on that reset over here, clicking that. Let's zoom out. I'll select that extra platform and delete it. And now we're back to here with just our basic player character. Okay. Now, with this ready to rock, let's move forward and get into some combat systems. However, you'll also notice that if we double click on level one, that's Sat, we still have this. So when we want to come and look at all these assets in play, we can come here. However, I want to go back to the straight developer level, where we will develop our systems. This is it. And I will always recommend having a developer level to develop the systems, and then you can add them into the levels themselves. That done, let's move forward. In the next video, we are going to create a simple health system. 33. 32 Creating A Simple Health System Part 0: This is an updated video showing you how to create a widget. Now, the first things first, make sure to keep things organized. You have a folder called interface. Now here, the widget is already created. It is called Health bar, but this is showing you how to create it. To create it, you simply right click and then you want to go down to user interface and select Widget Blueprint. Then it's going to say, Hey, create a user Widget. Yes, and now our blueprint is created, and you can call it health bar. Here, I'm just going to call it health Br two. Now that our Widget Health two is created, simply double click on that. Now it takes us to the Widget interface where we get to decide on what's showing on the UI when we call the widget. It's going to make a lot of sense in the next video. Just follow along. The first thing is we want to click on Zoom to fit. It's that little icon over there. Click on Zoom to fit, that's good. And we want to add the first user interface element for the widget. You come over to the search and you want to look for Canvas. Now the Canvas panel is basically going to let us drag and drop in our screen. You can see the entire screen is here. Now that you have the screen up, we're simply going to add some text, come back here and we want to look for text, and I'll select the text and I'll drag that right over here. Now that I have that text dragged here, I will come over to the properties of the text block and I'm going to rename it to HeL bar. And with that, I've hit Control S to serve, and now in game, you have a widget with the text health bar that is usable. Next, let's get into creating the health system. 34. 32 Creating A Simple Health System Part 1: Now in this video, what we are going to do is we're going to create a very simple health system, and the reason why health is important is because that's what makes games fun, knowing that you could fail and your clear character can die. Now, right now, our baseline character can simply move around and jam. Let's quickly add to them some basic health. If we, let's quickly close all the other windows and open up the player right? We'll go and select the player blueprint, okay, right now called Hero. Why is this jump leaning sound? It should be jump landing sound, okay? Now that we're out of that. All we are going to do is we are going to add in a number or rather variable that will contain the player health. So right now, we'll go to variables, which is over here. We'll click on AD. We will select instead of Bolean, let's set it up as an integer. Okay? The reason why we want to set it up as an integer is because we just want to make the health 100 and then here, instead of it being called NUVA, let's call it player health. Okay. And now that we have that now to add the widget to the screen, we shall simply start from the second level of the sequence over there. We will drag it out and we are going to type Create Widget, which is going to lead to that nod of Create Widget. And then it's asking for a class. We shall simply type Health Bar which is the class that we created. And then once we are done with that, we'll simply drag this out, and then we'll simply type add to view port, which is going to show this up. So we shall add that to the viewport and then return the value, we'll drag that to the target itself. And with just that, okay, with just that, we compile, have hit Compile, and then go into the developer level, and when we hit play, now, notice in the top left corner, there is text that says health bar, and now we have that widget. Let's change it from some text into an actual health bar numerically speaking, and then we shall figure out how to add some damage so we can see that clear health bar going down. 35. 33 Creating A Simple Health System Part 2: Now a health bar, yes, we are back to the health bar widget that we have. A health bar is fundamentally a progress bar. An easy way to get access is I'm simply going to type progress. There we are. We have our progress bar. I'll get that progress bar, and I will drop it into the Canvas panel. Okay. Now, let me move it over here. Now we have that progress bar. Let me move it right up here. Let me extend it a little bit, you know, increase its width. So this progress bar is going to be the thing that contains our health. The only thing that we're going to change to start with is simply after clicking on it, we'll just change it to be red. Change its color to be red. That's all we need for now. And then we're going to make some minor adjustments to it. The big one being in the top area, notice that there is an option to make it variable. We shall make it variable. And then we are going to call it player health bar. That is what we are going to call it. Now that our player health bar is properly named here, we have the text saying health bar. We have the player health bar, and we have our canvas ready. We can now go on to adjusting it so that the player is going to be the thing that controls how far this progress bar is. As it is right now, if we go into the developer level and hit play, notice that health bar is not showing any progress, which is not really what we want. We want this progress bar to match up with the health bar one to one. So to do that, we need to link these two up. So we'll go back into the hero. And what we really want is for this health bar widget to be connected with the player health integer component. So inside of the player characters blueprint again, we'll go and look at the point where everything keeps being added to the viewport, which is here. So right after creating the Health Bar widget, we add it to the viewport. This time, we're going to add in a couple of steps in between. So the first thing we'll do is let's extend the space here because there's going to be a lot more happening. And from Create Health bar widget, which is that we're going to come out. And from the Health Bar widget, keep in mind this health Bar widget is going to contain all of this information. It has access to this text, and it has access to the player health bar that we have now made into a variable so we can access it. So from here, we are first going to create a new variable. Create Health B widget, if you right click, there's going to be an option here called promote to variable, select it. Now, what promote to variable does is it creates a new variable. Which is going to be a separate item that stores the data of the widget. I hope that makes sense. If it doesn't, don't worry, you will get used to it in Unreal Engine. And we are going to call that player health widget. That's what that variable is going to be called. Now, now that we have this player health widget here and it is a variable, let us quickly break this link and break this link as well. We now have our player health widget right over here. Now, the next thing we're going to do is we're going to drag out from the player health widget. And what we want is we want to look for the player health bar. So we shall simply, you see that, get player health bar. So now we have got the player health bar. And for clarity, the player health bar is this bar over here, and it is the same player health bar over here that we turned into a variable so that we can access it. Now, now that we have called for that player health bar, we are going to drag this out and we want to set the percentage. Now, this right here, notice set percent is what we want to do. So we shall simply set percent and if we look, it's looking for a percentage to set the health bar too. Now, this set percent over here, okay? That right over there is going to be what we use to change the amount of health in that health bar. Now, in order to do that effectively, let's put this out over here. Let me drag this over here for organization purposes. And so after creating that widget, let's drag this here. I hope you can see this clearly. So after creating that widget, we are going to set it as a percentage, and then we shall finish adding to viewpot and then we shall simply connect that health bar, rather, sorry, we shall get that return value, and it is going to be the one that we add to the viewpot. Now, I'm hoping this is all making sense. I'm taking this as slow as possible because there are many things we are managing. The next thing we are going to do is we shall go to the player health. Currently, the player health is set up as an integer and it's set to be 100. We are going to simply make one adjustment instead of a binary integer. Since we need to use it as a percentage, we shall set it up as a float because we are changing it to a percentage. And then we shall get the player health and we are going to drag it out and we want to get player health and then drag it out again. And we want to look for the function called divide. And you should see that. So we want to use divide. And we want to divide by 100 because that is how you get a percentage. And since 100 is the maximum amount of health the player has, and then I'm going to drag this out to the percent and that is essentially all we need to do. Now, let's go step by step. So from the point event begin play sequence, the first thing we do is we create a widget, health bar. And then we shall simply set it up as a variable called player Health widget. We will target the health bar within it, and we want to set up its percentage. Now we will get the player health. That is the variable within the player. We shall divide it by 100 to get the percentage. It will go there into the percent which we used to set as the player health bar, and then we add to the viewport. I hope I have taken it really step by step. I don't want you to miss anything. Now we'll compile that, and when we hit play, notice that now the health bar is full. We have a full health bar, and if we come back into the hero, select the player hell, and adjust it so that the default value is 90, we compile. Now notice it's 90% filled, it's 90% filled. If we go and we set up the default value to ten, Now, it is 10% filled up. So now we have a working health bar where the player health variable determines how full that health bar is. Now, we'll go back in. Let me set this up at a baseline of 100. So we start with a full health bar. Okay, we start with that full health bar. And now, next, we are going to create some simple obstacles where when the player hits that obstacle, it changes the amount of help the player has. Let's do that in the next video. 36. 34 Creating A Simple Health System Part 3 Adding A Damage Object: Now that we have a basic health bar on our player character, we're going to add in a simple way to damage the character. So after pressing Control Space bar, I have created a new folder, and I've called this folder damage object, so we can have a single place to put in that damage object. Now, inside that folder, I will simply write click and I want to create a blueprint class. And as far as what it is, I'm just going to call it a Blueprint actor, and then I'm just going to call it damage Object. Because this is going to be a very simple thing to have. So double clicking on the damage object. Now I'm going to add in a cube to the damaged object. So now there is a cube around it, which is good. And with that, I go into the developer level, and then I just want to place this cube somewhere in the world. So I've put it somewhere in the world right in front of the player, making sure, of course, it's in the right axis, the right position. Now when I try to go near it, nothing happens. However, I'll go into this. Now, I'm going to add a hat box around it. So we'll simply click Add. And then what we want, we want to add in a box collider, actually. We'll add in a box collider. So the box collider is there right now. I'm simply going to scale it up. So that it is just notice I can make it too big, that's not good. Just outside of the box, okay? Just outside. That's perfect. And then as far as collision, I'm going to type collision. Now, I want it to not be overlap dynamic. I want to set it up so that it's set to overlap only the pawn. That's a very good option to select, so that that collider only detects the pawn. With that done, we'll simply compile and then go into the event graph. Now, inside of the object itself, we have this box collider. I'm simply going to get it and then right click and then add event, and then on component, begin overlap. This is the one we want. So it's going to it's going to bring this up. On component begin overlap, right? That box. So once we have this here on component, begin overlap, we now want to know, which component is it overlapping and what do we do? So let's start with something simple. Let's drag this out. And then we'll say destroy Actorself. That's all it's going to do. Once we start overlapping, it's going to destroy itself now quickly to test it out. Actually, before we go on, let's make one change. We've already set up begin overlap, destroy actor self. But let's make another adjustment, we'll select the box collider again and we'll switch from overlap on the pn. Let's switch it from that. We overlap all dynamic. So that this is a bit more reliable. So now, when you hit play, it disappears, it destroys itself. So hit play destroys itself. Now, we go back to the damage object. If we break this link, when we come in, look at that. Now it stays there. But we know for a fact that the hat box around it is working. That's a good way to testify box is working. It destroys itself. Now, with that setup, let's now make it so that when it overlaps with the hero, it does damage to the hero. Okay. So with that in mind, let's come over here back to the damage object, and we want to add in some more nodes. More nodes. Here is how we will manage it. Now, unreal engine built in has a couple of simple functions that are useful to knowing when damage has been applied. Now there are many ways to apply damage. We're going to use the simplest one. Now, that is simply with a node called apply damage. Now, notice that when we bring in applied damage, it has a couple of other connections. It has damaged actor, the base damage, event instigator casa, none of those things are very meaningful for us right now. The only thing that we want to adjust is the base damage, which is a number, so we'll call it ten. It's a float. Now we simply need to decide on the damaged actor, which is going to be the hero, and then we are done. So we shall simply come in, and then the other actor will drag it out and we shall cast to hero. Oh, sorry, I mist it. Cast to hero. And there we are because it understands that there is a character called the hero. And there it is. So we have cast to hero ready. And as hero, this is not important. We'll first connect this. So the damaged actor is going to be the hero, and the base damage is going to be ten. And then once we're done with that, we shall destroy the actor. With that, we shall quickly compile. Now, notice that when we go back into game, if we hit it, it just disappears, but there is no clearly indicated damage in the health bar. That is because the health bar whereas the hero. The health bar has been updated only on event begin play. Notice that from event begin play, the first thing we do is we set up the health bar and we set up its percentage. So we simply need to add in another function, which is going to keep the health bar updated. There are many ways to do it. This is the last processor intensive that is good to use. So let me copy that and paste this. Adding in a comment, of course, you can make a comment by just pressing C. Okay. But I just like sometimes, since it already has the style settings I want, then this is simply going to be called update Health bar on damage. That is what it is called. And then inside of here, we shall simply add in a function. It is called on any damage. Then we want any damage. Yes, this is what we want. We want that event event on any damage. Drag this out over here. Now, once we have event on any damage ready, we shall simply drag this out, and then we want to now start adjusting the player health value. So immediately the damage has been done. The first thing we want to do, let's drag out player health. Let's get player health. We start by getting the player health, and then we're going to drag it out, and we're going to subtract. Subtract. Now with that subtract functioning, we are going to link the damage to what we want it to subtract. So we are subtracting the damage that has been done from the player health. Very important. Once we have subtracted the damage done from the player health, we want to drag out that value and we want to divide it and what are we dividing it by? We are dividing it by 100. Okay, because we want it to be set up as a percentage. And now that we have that, we now have the percentage of health that the player has right now. Let me bring this over here. Bring this over here. Then what we are going to do is we are going to get the player health widget and bring it in. Want to get the player health widget, and then we want to drag it out, and we want to look for player health bar. We want to get the health bar from inside the widget. Okay, we are getting the player health bar from the screen, and then we want to simply set its percentage. Okay. So we want to set the percentage, and we are going to drag out the percentage as the damage that has just been taken. And that is going to be that. So with that, we can simply with that in mind, we can now simply connect event on any damage. We want to update that percentage. Let me go over it one more time. On the damage object, we want to cast to the hero, that is the player character. Okay, want to cast to the hero, that is the other actor. It is the damaged actor. And then after that, it's going to destroy itself. That's what our damage object is going to do. And then on the player character side, of course, the best damage has been set to ten on the hero side, on any damage, that means when any damage is taken, we get that damage, we subtract it from the player health. We divide that by 100. And then we come here and then player health widget, we want to update the percentage. And actually, there's one more thing missing. Because while we are dividing the player health, we haven't yet properly updated the player health. So let's drag this out a bit. In between from when we subtract, we are simply going to set player health. So this value, drag it up is now going to be the new player health value. And then that player health value is going to be the one connected as the set percent for the health bar. I hope this is making sense. Please, if it isn't making clear sense, go over it again. I've tried to be as precise as possible. So with that, let's test it out in game. So now, when I go over the damage object, there we are. My health bar has reduced. Now, let's say that I get these objects have copy pasted. They are now two, copy paste. They are now three, copy paste, let me zoom out a bit and drag this here, four, copy paste, five, and then 67, eight, nine, ten. Okay, so I've made ten damage objects. First one has reduced the player health by 10%. Second, 20, 30, 40, 50, 60, 70, 80, 90, and 100%. Now we have found how to apply the damage to the player and make sure the health buy is updated correctly. Now, in the next video, we are going to add in a simple death screen, and then we'll dive in a bit deeper on AI after that. So in the next video, we are making a death screen so that when the player has gone below a certain percentage on health, they are dead, which is what we want. Let's go. 37. 35 Checking if the player is alive or dead on taking damage: Okay, now that we have our character having their health ba being able to be depleted by objects. Let's now add a simple death state. So we will check. And once the player health goes below zero, we say, the player has passed on. So to do that, let's go back into the hero blueprint. Let's quickly put this out over here, line these up and organize them so they look neat. Just a little bit of neatness. You know, it goes a long way with this over here and this over here, and this over here. Now, remember this is Update Health Bar on damage and then we'll get this. And then I'm just going to copy that dialog. Of course, as always, you can make another comment box by simply pressing C, but I like a certain styling with black text because that's more readable for me. And then this is going to be check if layer is alive. That's all it's going to do. So right after it has done that, what I want to do, let me drag this over here to give it some space. And then I'm going to drag this out type sequence because I want this to be a basic sequence node. And then I'll drag this out over here. And then what I want to do is I want to look for a branch BRA NCH branch, right? Now this branch is basically going to be the thing that checks to see if the player is still alive, and how are we going to do that? It's quite simple. We are going to drag in the player health and we want to get the player health. Then what we want to do is we want to look for less than or equal, less than equal. We'll get that if it is less than or equal to zero, that will be our condition. What that means is if the player health is zero, this is true. If the player health is less than zero, this is also true. Now, with that, let us simply say, Hey, if it is false, let us start with something simple like a print string, and we will say we will type in capital letters live, okay? Then let's control paste that over here. If it is true that it is less than equal to zero, we can simply type dead. We're just doing that to simplify checking if this basic branch check is working correctly. With that, let us compile go back in to the developer level alive, alive, alive, right. It keeps saying alive, and then dead. You can see in the top left corner of your screen, there is the text that said dead. So now we have a good way to detect the player being alive or dead when they're done taking damage. Now that we have that, let's move on and actually add in a simple death screen. 38. 36 Making a death screen user interface: Now, to add in a death screen, the first thing we're going to do is to create a new UI object. It's going to be very similar to how we created the health bar, which is over here, and let's do that. So I've pressed Control and Space bar. And now I am looking in, and I am here in the content folder. I am going to create let me check inside of the character inside of player under Interface. This is actually a very good place to put this. And under interface, we have our health bar. I am going to create a new widget. Let me not search here. User interface, Widget blueprint. It is a user widget, and then we're going to call this death screen. Okay. So death screen. Now with that, let's double click on the death screen. Let's put it up in the main window so we don't need to hop around. And then just as before, the first thing you're going to put in, you want to put in a Canvas panel and then click on Zoom to fit, okay? This baton hera Zoom to fit. This one, Zoom to fit. So it zooms in and makes it fit on screen. Now, just for simplicity, we are going to add an image background. Okay. And as far as anchors, let's anchor to the top left corner. We'll give it position zero and zero. On this side, we'll make it zero and zero. Size, I'm going to make it actually, no, let me align it across everything. And then I'm using this one, this over here. This is going to be good for making it fill up the whole screen. Press that. And then on the offset, I'm going to offset zero and offset zero. All right. Now, for the color and opacity, I'm going to double click. I want its color to be black. And then it's opacity. Opacity is this lower value, RGBA, A is for Alpha or opacity. I want to drop that down to maybe something like 0.4. It's going to act as a nice dark background. That's good. Now with that image over there, just compile. The next thing we're going to do is we want to add in some text. So let's get this text, drag and drop it in over here, and inside the text, we'll say player is dead. Now, of course, you can really put in whichever text you want. This is just to demonstrate how you do it. Now with that text over here, I'm going to select the anchor in the middle. I'm going to change its position to zero, zero, and then its size on X, let's see, let me change its size here to 300 and size Y also to 300. No, let me jup that 100 and then just line it up over here. It's basic text. Now, to increase the size of the text, let's come over here back to where the properties are. Let's type size. Going to show the font size of the text. Let me increase it to something like 80. Yeah, 80 is good. Oh, sorry, I clicked on the wrong thing. Let me click on that again. Okay. Excellent. Now, I need to make sure. Oh, no, it stacks down. Everything above is below, no problem. Now, Control S to save. Let's quickly compile. Now we have some very basic death screen. But this is not good enough. Let's add in something a bit extra. We are going back into art inside of the adventurer. Let me see. Do we have some death sprites? No, we don't. I'm going to add in let me just add in the wall slide animation, rather than wall slide over here. And I'm pressing let me see. No, I need to scale this wall slide. Now that I have selected the wall slide, make an appearance. That's the appearance. Now I have selected its size. Right now it's set to 140. Let me set it up to something about twice that, which means 280. Okay. Still not big enough. I think let me make this now 400 and 160 pixels. Okay. Yes, this works reasonably well. Put this up over here. So this is our desk screen. Currently. Let's add in one more thing, which is a simple button. Oh, it's not in the hierarchy. I have to search over here, search for button. And then we are going to drag and drop this button right over here. Increase its size bit. Now I'm going to get that and add in another button, just to copy it here. This is good. So we have a simple image that text a player is dead, and we have two buttons. Cool. Now that we have our two buttons, let's add some text. I'll add the text to the first button, and then I'll drag that text again to the second button. Notice how it has auto positioned itself in the middle. And for the first text block, I'll select its text over here. I'll say the text will say restart. And then the last text block is going to be called exit. That's on the text. Now for the buttons, I'm going to change this button so that the button name itself over here is going to be called exit. And then on the restart, the button name itself, I'm going to change it to restart, restart, okay? Now with that changed, when it comes to the order, notice the text is not important. The real name that matters is the name on the button. Now that we have that dialed in, let's organize these so that they stay in line with each other. So we are going to search for something called a vertical box. Okay. Now we'll get that vertical box and we'll drag it into the scene. And as far as anchors, we want to anchor it to the fourth medal. Up, one moment. All right. I have sorted out the call and all of the challenges that it brought up. I love being useful. And when you're in game development, you have to keep your life organized. Now, back to the tutorial. Now that I've put in this vertical box, Notice, there is nothing inside of it just yet, okay? Oh, my God. Zoom out. I was distracted. Now that I have this vertical box, I've selected the vertical box. Let's open it up. It is, I think, a good size. We want to put many elements inside of the vertical box. We want them to be inside of it so that it can organize them. That's the purpose of a vertical box in general. It organizes elements within itself. Now, let's put the elements inside of the vertical box. Zooming into the hierarchy area, let's simply tighten this up. All we're going to do is we're going to get these two buttons, and we're going to drop them into the vertical box and then we'll get this image of the player is dead and that image, which should be the little graphic of the player and drop them into the vertical box too. And now when we zoom back out, oh, look at that organization. They've changed their order. They've changed their size. So we now need to adjust the size and order to make sense. For starters, we shall drag the text. So to drag the text, I want the players dead to be the second thing. So I'll select the text of the players dead inside of the vertical box. I'll put it up here, and now look, it's at the top. Then I'll come back to this image. I'll drag it above the text, and I'll stop it. Oh, no, it's going too far. Put it over the text there we are. And now the image is coming first, the image is first, and the text, then the buttons. This is exactly what we need. Now that these are organized in that way, let's start by fixing the image size. So I have selected the image, and on the right side, notice it's set to vertical alignment and horizontal alignment. So we'll set its vertical alignment to center horizontally. And just from clicking center horizontally, it has stopped I stopped being squished, okay. And now that it's not being stretched out, it's still small, but it's not being stretched out. Now, I'll select the image once again, and we want to change its sizing just a bit because we do not want it to be this little tiny thing over here. So let's now change its size and make it large. So the image selected, we now want it to be much larger. Simply select the image. And then in the properties panel, notice there is the brush. Go into the brush, and then there is image size. So simply change it from 32 by 32 to something like 200 by 200. That should give us a much more reasonably sized image. I like this a lot. Let's make it even bigger. Let's make it 300, 300. That is good. Let's make it even bigger. Let's do 400 by, 400, 300 seems to make it appear clearly. This is a good image size. Now, click on the text of Play is dead. Let's make sure it's horizontal alignment over here is in the middle. And with that, we are happy. Then we'll now select the button. The first thing we're going to do is we need to change the color of these buttons. I think let's change the color to something like, Okay? No, that's the button. The text color, rest control Z to change that. Change the background color to something a bit more That's fine. The buttons can be fully black. I think I'm okay with that. But with white text, which is always good for readability. I'm a big believer in black backgrounds, white text. And now let's add some spacing in between the player in between the play is dead. Select the plays dead text. On the left side, there is an option called padding. Okay. This is it. And we want to add some padding to the bottom. Let's add about 200 pixels, which gives that amount of space, that's too much, 50 pixels. Perfect. So just 50 pixels of bottom padding is doing the job. And now we have our buttons. So I will double select the buttons by holding shift. When I'm clicking on the buttons so that we can change the values of both the buttons all at once. So I am coming here under appearance. Let me see. I want to add some padding. I think to both of them to the top, I will add 20 pixels to give them some spacing to the right 50 to give them some spacing and to the left 50. Oh, not to the bottom. To the bottom should remain 20. So to the left and right, we'll have 50 pixels. Maybe let's add more. So 100 to the left, 100 to the right. With that, compile V. This is our death screen as it is right now, and I can just slightly adjust the vertical box, and you'll see how adjusting the vertical box is going to change the position of everything in, so we have a reasonable user interface. Now, I'm going to make sure the vertical box is anchored to the top center. Position X is let me set that quickly to zero. Okay? That's going to put that there. I do not want that. Let's align it properly to the top center again. And I want the vertical box position to be a lot more. Oh, I closed that up. Let's come back here. I want it to be a lot more to somewhere in the middle. So it size X, let me make it size X 700. Is size Y 800. And so that is going to let me accurately position it. Since I know that its X size is 700, 700/2 is 350, so I can simply come in and set it position X to negative 350. Okay? So now we have a basic menu, which is what works on death quickly compile, and it's not going to work yet, but what's going to happen is once this player is dead, we want to see this death screen. Let's get into adding this death screen to the game. 39. 37 Adding The DeathScreen on Death: Now that we have the user interface created, whereas the screen over here. Now, we simply need to make sure once that health bar goes to zero, that user interface comes on screen. So let's go back to the hero character. Now, we know how to check dead or alive, and this is what we are going to use. Now let's remove the alive part. We already know that this is working correctly, and let's delete that string. We don't need those print screens because we know that it is working correctly. Now the next thing we're going to do is we want to simply add the widget to the screen. Now, much like the same way we did it for the health bar, we'll simply bring this out. And the first thing we're going to do is we're going to pause the game. So we're going to set the game pause and we'll set the post value to be true. Okay. That's it. We've set the post value to be true. And with that done, the next thing we're going to do, we'll drag this out is we're going to create a widget. Which widget, simple, it's going to be the death screen widget. So let's type death screen, and it is going to create the death screen over here. Now, in terms of owning player, we're going to do it the exact same way that we added the health baro over here. So we're going to come in here and we're going to get the local player from ID. So get Okay. And we want this to be player zero. So we've created that death screen widget. Okay. Next, we're going to simply add it to the viewport type ad to viewport. And there it is. And let's connect it over here. That's the return value. And with that done, where now let me extend this a bit. Then we're going to set the mouse coursa to be visible. So let's drag this out. And we want to type set show mouse, actually, set mouse cosa. No, no, no, no. What we actually, what we'll do is we'll get the local player from ID, and then from there, we'll drag this for the local player. We shall set mouse. Let's see Cursor. Yeah, here we are. No, this is not the one we want. We won't set the mouse cursor. Yes, here we are set Show mouse cursor. This is the one we want. We've gotten that out from the Get Local player from ID. And we want the mouse cursor to be visible. Okay? And then after that, what we want to do is we want to change the input mode so that we are no longer inputting into the game world. We shall simply set input mode. Okay, and we shall set it to user interface only. And which player controller is going to be that same player controller. And then in widget to focus, we want, where is the desk screen widget. Want to be focused within the death screen widget. And with just that, okay, let's test it out in game. So developer level, it play live, alive. Actually, let's speed this up. I'm going to select the damage object, and I'm going to increase the damage 10-25, so I only need to go over four of those objects to trigger one, two, three, four. Look at that. Player is dead, and now it is showing us the screen. That's cool. So, one, two, three, four. Boom. Player is dead. Now we have the death screen showing up correctly. Now that it's here, let's go back to the death screen and add some nodes to make sure that these buttons do what they say. We're going to make this button restart the level, and we're going to make this button exit the game. Let's go. 40. 38 Adding Functionality to the Death Screen: All right. Now that we have a death screen, let's give it some actually usable and useful menu options. First things first, let's go right over to the death screen. Okay. And now, we're going to start by making the restart and exit buttons actually work. To begin with, we're going to come over here and you see that is variable, select it so that we make it a variable. And for the exit, also make it a variable. Making it a variable is what's going to allow us access to it and to use it for a couple of different functions. Next, come down and notice there are some events here. Quickly make an unclicked event. That is for the exit. Okay, so here it is OnClickedEit. And then let's go back to the design page again, and then click the Restart, and then write down here, make another unclicked event. And so we have OnClick restart and OnClick Exit. And now we want to add in the functions to this button, to these buttons. Now the functions. Mm hmm. Excuse me. The functions are pretty simple. Let's start with the more basic one exiting the game. Now, to exit the game, let's first add in a comment, drag this in, rag it out. And then as usual, let's change. I love the black background white text. Increase the text size to something like 50, but it's big and drag this out. I'll say exit the game. That's all. So on click Exit, we'll simply drag it out, and then we will type quit Game. That's all. Okay. So quit. Just quit. That's all. Exit, quit the game. Okay. Okay, fine. Maybe this text size is a bit big. Let's make it 24. Okay, much better. And then I'm going to copy and paste this. Drag it. Okay, this is way too tall. Come back down here. Okay. And then click restart. So I'm going to say restart the level. Okay. Now, the restart, we're going to get a bit more complex. The first thing we're going to do is that we're going to drag this out here. And then what we want is to get current level name, okay? This is going to get the name of the current level. That's the first thing we are going to do. Now that we're done with that, the next thing we'll do is we want to open level by name. Okay. And we are going to link the current level name with open level by name. I'm sure it's self explanatory what this is going to do. It gets the level name and it says open the level, and it will be the current level we are in. So that is very good. And this is reliable. There are many ways to do this, but this is the most reliable way to do it. It will always work. Get current level name, open level by name. With just this, this will work. But what we want to do is we want to make sure that the input mode is set correctly. So we shall call, actually, no, we shall first call, get local player by ID. Let's see, get Local player from ID, perfect. And we want players zero, and then we'll drag this out and set input. Let's see, set input mode. And we want to set the input mode to game only. Then we'll drag this out over here. And there we are. So let's go through it. Exiting the game, it's simple. On click, quit game. Simple. However, for restarting the level on click for Restart, we start with G current level name, open level by name, and then we get the player controller from ID, and we set the input mode to game only. And with that, let's go into the developer level. I'm dead, I can click Exit and I'm out. However, I could also when I'm dead, I click Restart, and it restarts the level. Restart. Perfect. So now we have a working death system. The player can die, and then they're able to exit the game or restart the game, and it is working fundamentally soundly, and it still works. We're able to move everything else is working. That's a good enough base line that is fantastic. So now let's move on to making the player, now that the player can take damage, let's give the player the ability to dish out damage by giving him an attack and creating a practice dummy, which we can hit and deplete it health to zero. Let's do that in the next set of lessons. 41. 39 Adding Player Attack Inputs: All right. In this video, what we're going to do is we're going to go through everything about how to quickly add in a sword attack input. We just want to set up the input. Now, currently, in game, when IPressPlay, if IPressckrather, left click on the controller, notice that in the top left area, text that says attack shows. I as I'm moving around, I press E, text that says attack shows, and then on my controller, when I'm moving left or right, I can immediately press the X button on Xbox and the attack text shows. This is how you're going to set it up. Now, go back to Controls, which is this folder over here. It's the same folder you use to set up your jump and your movement and player map in Unreal Engine. You're going to create a new input action and call it Mele attack, MELEE attack. Now, when you go into it, you can leave it as is and it can remain a digital boolean. You don't need to make any changes to it. Just set up the action, call it Melata. Once you're done with that, you want to go and go into the player map, which is the input mapping context. When you go into the player map, the input mapping context, what you want is to make sure that you come right over here and you add in a new mapping. Once you're done adding in that new mapping, you're going to add it in as a My attack you select from a drop down. Find the Mattach input action. Okay. Once that's done, add in new inputs, add in the left mouse button to trigger the mea attack, add in E on your keyboard to trigger the mea attack. And then if you have a controller, if you don't, it's okay you can skip this. But if you have a controller, you also add in pressing that button, o as a trigger for the metack. Once you're done with this step, which is very, very similar to how you set up the movement, okay. Once you're done with that step, now you need to find your player blueprint. Now, the player blueprint should be found under characters player, and there it is our hero Blueprint class. Now, inside of the hero blueprint, this part is very easy to understand. Of course, create a comment box which is going to hold the data and say, Hey, this is where those nodes are located for organization. And then you're going to right click and look for me attack, which will bring up adding in the me attack input. Once that input is in, simply ask it to print the string and call that string attack. And with just that, you're done. Now we have the baseline code for our Me attack setup. So the meal attack is ready. So now we are ready to begin adding and implementing, adding in the hit box, and then the animation. But let's get into that in the next video. 42. 40 Creating A Combat Dummy Part 1: So now that we have the baseline of what our attack event is going to be, we're going to need something to practice it against. So to do that, we need a basic attack dummy, which we're going to use. So to do that, we're simply going to go back into our character's folder. And this time, we're going to create a new folder, and we're going to call this folder. We're going to call this folder attack dummy, okay? Because we're going to add in and create a basic attack dammi here. So we're going to create a blueprint class, and we want it to be let's see. We want it to be a basic let's see, let's see. Let's see. What do we want? Let's have it be a character, okay. But it's still going to just be an attack dummy. Okay? This is going to be our attack dummy. And let's quickly double click the attack dummy. And what we really want with the attack dummy right? Is we're going to add to it a basic cube this is all we need to add to it. As far as the material, I mean, we could pick practically any material. It doesn't matter. Okay. It really doesn't matter. But this is what we are going to use, okay? So let's quickly compile that. And with that attack, Dummy let's drag and drop it into the world. Make sure that it is zero on the Y axis in terms of its position because I want it to be slightly to the right of the player. That's cool. The next thing is we want to add, you know, something pretty basic to it. We want to add a health bad to it. So inside of the attack dammi, we want to have a health bar inside. Now, to add the health bar here, the first thing we're going to do is we're going to go into the event graph, and then we're going to go into variables, and we want to create a new variable. And this variable type is it's going to be a float. And we're going to call this variable. We're going to call it Dam health. Okay, that's going to be a variable. And we want to set up the let's call Let's make the dummy Health 100, okay? The dammi health is going to be 100. That's going to keep it simple. Now that the dammi health is 100, we are going to be able to add in the health bar to the dammi itself so that it has a health bar above its head. Now, when we last created the health bar, going to the player interface, we created this simple health bar for the player in this way, okay? So we're going to do the exact same thing, but this time for our dammi. So we'll go just to keep it organized, we're going to go into the attack damming. We're going to create a new folder, and we're going to call that folder interface, keep it organized. So inside of that, we're going to write click and we want to create a user interface item. And the item we want to create is a Widget Blueprint. You should be able to see it at the on your side, Widget Blueprint, okay? And yes, we want to create a user Widget. That's fine. And we're going to call it dammi Health bar. Okay. So that's what we're calling it. We're calling it dammi Health bar. So, double click on the dummy health bar. First things first, we want to add in a canvas panel as always. And then after adding in the canvas panel, what we want is we want to have a progress bar. Ragatin. We want to anchor it we want to anchor it to the center, really. So you can pick any center, but I like to put it right in the middle. And then for position and offset, I want it to be offset zero and offset zero because this is going to be kind of big, you know? And then I want to increase its Y size to something like 300. Okay, so just make a nice big meaty health bar. Hip position zero, zero. No, actually, let's make it position negative 150. So essentially, what I've done is upset it to the mid anchor, upset it offset left to zero, offset right to zero. And position Y is negative 150 because its size Y is 300, so this brings it to this size. And then fill color, I think I'll have it be yellow. Okay. That's cool. And now that the fill color is set to yellow, let's think about its progress. Is percent is going to be I think it's percent will be zero to start. Okay? This is cool. So this is now our health bar. Now notice right now it's called progress bar. Let's change that up. And actually, we can't even leave it progress, let's just call it dummy Help. Progress bar. Now that we have our DamiHalthPgress bar set, we must make sure to set it up as a variable. And with all of that done, we are essentially finished here. Now, let's go back to the attack dammi, okay? We now want our attack dammi to once it's loaded into the world, Okay, this attack dummy, we want it to have a health bar above its head. Okay. Now, to do that, we're going to go into the attack dummy and we need to add some code into its begin play. Now, create a big comment box, okay, so that this says, Hey, this adds health bar to the dummy and we will start from the event begin play, okay? So I'm going to drag this out, and we want to create a widget, okay? So what we want, want to create Widget. Now we'll select that. And the widget class that we want is DamiHalth Br. You can see DamiHalth bar over there because Areal is good at keeping track of what you've created. And now that we have that, we have the owning player, and essentially it's just going to create that dummy health bar widget. Let's quickly test this out and see how it looks. Okay. Now, if we compile here, there should be nothing on screen. So what we need to do next is we actually need to add this to the screen. So we want to add to viewport. Okay. So start by just adding it to the viewport. Make sure that at least it is spawning in correctly. Let's double C. There we go. So right now it's working correctly, but it's being added to the viewport. Let's adjust that. Okay. So now that we've confirmed our health bar is able to be spawning properly, let's delete adding it to the view port, and then we're going to come over here and we're going to add it to the character themselves. So we want to add add widget and add that widget in. Now, quickly, let's go into the view port, okay? So you'll see that now there's this up white widget. There's this object here, right, that is going to be our widget. Now what we want to do is now that we have it, move it a bit to the left, hold on. That's what we want. That's the cube. It's the widget I want selected. Now that we have the widget selected, we want to select which type of widget it is. So selecting the widget, if you come over here, you'll notice there's the option to select the widget class, and, of course, look for Dami health bar, and there it is. So it has added the dammi health bar to it. Now let's look at what this looks like in game. Okay. So you basically can't really see it from here. Okay, but you can see where it is. So let's go back to the attack damming. So right now, it's showing the health bar is not visible from here, but it is from here. So let's do some basic movement. So we'll select its rotation. Let's see. And we want to rotate it on the Z axis by 90 degrees. Okay? So that's over here. Z axis, 90 degrees. That's cool. And then once that's done, let's scale it down slightly. To about 0.5. Now that's done, and then we want to raise it up in rotation. So I want it to be slightly higher. There we go, compile that. And now in the while, you can see that widget is over there. Okay? Yeah, the player got moved due to the hit box, but we'll deal with that a little later. Okay. So essentially, there it is. Now now that we have this, you can see that bar over there. Let's slightly drop down how tall it is. Want it to be a health bar, not a health gigantic square. Okay. So we'll go in and we'll unlock the scaling and we'll reduce its scaling on the Z axis to be a bit more reasonable. You can scale it down on the Z axis. So there it is. So now we have that basic health bar, but it's not yet connected to show off any health data. So what we want to do, let's get back to the event graph. Now that this is here, come over here. So slide in. Now, on event, begin play, pull this out. Hold on. We want to update that health bar with the correct data. So we're going to get the widget, drag it out here as an object. Okay. And then from the widget, we want to get dummy No. We want to actually bring out the widget component. So let's get that here. Promote it to a variable. It's currently set to the variable widget zero. I don't want it to be the variable widget zero. So I'm going to call that variable. Instead of Widget zero, let me quickly call it Health bar. So that's what we are going to call it, okay? It'll be called the Health bar. So now that it's set up here as a variable, we now want to drag that out, and we want to say, Hey, get dammi No, no, no, get. One moment, need to double check the names. Okay, now hold up. Let's get rid of all that initial code because I was using a long roundabout method, and yet there is an easy quick method to get it done. Let's come back down. You see this health bar widget. We don't need it at. We really don't need it at all. Let me delete that that's not needed. We'll go back to the baseline widget. All we have is the dummy health bar setup as a widget, and in the world right now that is how it looks. We'll go back to the attack dummy, and after the event begin play, instead of needing to do all that work to call it, we're going to keep it simple. Now, this time, all we have to do is go get the widget and drag it out to here. And now we have our widget component. The widget component is now here. I already has the dammi health bar ready to go. Now, let me drag the south. The next thing we're going to do is we're going to cast to let's see, we want to cast to help bar. No, no, no, want to cast. What do you want to cast two? Which component? Which component? Okay, before we cast, actually, we need to come back. So we have our widget. We don't cast directly. The first thing we want to do is we want to get widget. So if you scroll down, if you type in G, you have to get widget, which means Widget This isn't the widget This is the widget component. Then we want to get the widget inside the component. Once we have that, now, we can drag that out and say cast two, and we want to cast to DamiHLth bar. So there we are. And let's quickly connect this. So now it is casting to the dammi health bar. Let's put this under for organization. Keep it nice and organized. So we got our widget component. We got the widget within it inside it, and then we are casting to the dammi health bar. Now, as the dammi health bar, let's drag this out and say, Hey, get let's see. I want to get the dammi Health progress bar that right over there. You g this out here. And then the next thing we want to do is we want to set its percentage. Okay. So let's quickly set its percentage on that progress bar. So let's quickly set the percentage. Put this out over here and connect these two links over here. Now, before making any proper changes to the percentage, I'm going to set that to 100 in terms of setting the percent. Let's quickly compile that and boom, we now have our health bar over that combat dummy completely yellowed out. That's cool. We'll go back into the attack dam and this time, what we're going to do. So this is when the game launches, want to get the dammi health, drag it out over here, and we want to say, Hey, get the dammi health. And after we get the dammi health, we want to drag this out and want to divide, and we want to divide it by 100. Okay, by 100. Then drag that out here as the percent, and that's going to be essentially y. Let's compile. So when you hit play, there it is. There it is. However, it doesn't take any damage yet. It doesn't have any of those capabilities. We just have a basic dummy with a health bar. The next thing we're going to do is we want to make sure that on any damage, it updates that health bar properly. So let's copy this. Okay? Drag this out. And this is A, add health bar to the dummy. No, change health on any damage. Okay? So we're going to bring this out, and we're going to be doing practically the exact same thing as we did when it comes to our baseline character, okay? We update the health bar on any damage. So in a very similar way, we come over here. We will say, Hey, any damage. That's the event. So the event is on any damage. Okay. So we'll get that damage. And the first thing we're going to do is we're going to get the dammi health. Drop it in over here. Want to get the dammi health. And then the next thing we want to do, let's drag the dammi health in again. And this time we are setting the dammi health. So we will get the dummy health, and then we will subtract, subtract, and we will subtract the damage that it has taken that is going to be the new health. So we'll set it up there. And then once we are done with this, what we're going to do is we're going to come over here and we want to change this percentage as well. So we're going to get basically all of this code over here, copy that and paste it over here. And so right after that, we are going to cast to that health bar over here and go through that exact same process. Okay? So we're going to get the dammi health bar and then we're going to update its progress bar to the new dammi health. That's everything that needs to be done. Now with this code ready to set up, let's now go back and give the player some damage so they can actually hit that enemy and do damage to it. 43. 41 Making A Player Attack Part 1: All right. So now that we have a basic attack dummy, okay, we are going to go back to the hero character and back to the meat tack, and we want to actually add something to the meat tack. And I'm going to share with you one very effective way to have attacks inside of your game that is pretty reliable and reasonable, and that's just going to work every time you call it and it's reliable. However, let's quickly also go back to our characters, and I'm going to open up the attack dammi folder and make sure that both the hero and the attack dammi are opened up because we're going to need to go back and forth between them, make sure the code is working correctly because these two are going to be interacting. Now, let's come over here. Just a quick review. On loading in, we add the health bar to the Damik we set it up at that percentage. And then on any damage, on any damage, we get the dammi health, and then we change the number in the health bar. This code should be understandable to you and you should have all of it ready to go. Now, with all of that, what we do need is something to perform any damage, and let's get into that. A very good way to add that in, I've hit Space bar. I'm going back to the characters. I'm going back to the player, and I'm going to create a new folder. And inside of this new folder, I am going to rather, I'm going to call the new folder called damage it box, right? Or sometimes I like to call it damage objects, right? So damage objects. Now, that's one way of calling it, but let me actually rename that I've used this name before. I don't want this to be confusing. So let me change it to damage at box. And the reason why is because I want to be able to have different attacks, have different damaged hit boxes, and you want to have that separate from the main character. Let's go in and let me explain this clearly. So inside, we are going to create a blueprint class, and what we want is we want a simple blueprint actor. So let's simply call this SWOD dash. Actually, let's call it SWOD attack underscore one. Okay? So this is SWOd attack under score one. Double click on that to bring it up. Let me add it up here. And inside of SWOD attack one, we simply want to add we want to add a collision. Okay? What kind of collision? We want to add a basic box collision so that. And then just for clarity, let's also add in because you can see we've added that box collision. Let's also add in a simple cube. Oh, sorry. Let's add a cube. Don't know why there we are. So we've added in a cube, right? Now, we could actually decide to just ignore the box slider and use the cube alone. But let's quickly I've unlinked its scaling. So I want to scale it on the Y axis to be Let me leave it on one on the y axis. Oh, not ten, ten is too big. I want it on one. But then I want it to be a bit shorter on the vertical axis. So I've scaled it down on the vertical to about 0.2. So this right here is our simple SOD attack. Now, here, it's not doing anything. It's just a simple SWOD attack. It's just kind of, you know, sitting there. So what we want is to spawn the scene. Keep in mind, it's not doing anything, but we'll just call the SOD attack one. So we'll go back to the hero under the mele attack. And what we want is instead of just printing a text called attack, we want it to also span in the sword attack one. We'll go back to the hero and right after the text that says attack is where we're going to add in the nodes that are going to spawn it in. Now, spawning in is pretty simple. We'll drag this out and we'll type span Okay. And spun actor from class is what we will select. Now, what we will bring in, we want to look for sword attack one. Perfect. Now we need to decide on where it is going to spawn and its collision handling override, okay? But that's fine. We don't need to touch that for now. We'll select the spawn transform, and then we'll simply split this up because we want it to spawn at a certain location. Right now it's spawning at zero, zero, zero. So if we come back, we zoom out if we compile. Basically, it's spawning it rather, sorry, let me pit play. So anytime, notice, it just spawns that. That's all it does. It's spawning an object in right over there. So it spawns it in over there. We want it to spawn around the middle area of the character, okay? So we'll go back to hero and we want to change where it is going to spawn. So where we want it to spawn is around the place where the paper flip book is. So let me drag in the paper flipbook. And then I want to just get word location, get world location because I want to get where it is. This is good. And just after getting its location, we connect this to the span. Actually, let me break this link. No, no, no. Please recombine structure pin. Yeah, okay? Let's just Why am I splitting? I want to recombine. I don't want to split. Okay, so let's quickly attach it right over there, right? So we have gotten the paper flipbook we dragged it in, get the wild location, and then that is going to connect to the spawn transform. And this is what you get now. So let's press play. Boom, notice where it spawned in. Okay? Now, let's go back. The one problem we have is when we spun it in, it's kind of colliding with the actor, which is not what we want. So we are going to select this sword attack over here. This cube over here, and we are going to look for collision. And right now, it's collision is set to block all dynamic, and we don't want that. Let's call it overlap all dynamic. Overlap means that it will overlap. It will be able to collide with things and go over them, but not block them out. So let's try spinning it in. And notice it just overlaps. And anytime I click attack, it spawns in one of those, okay? And if I just hold the attack button down, it's infinitely spawning them. But that's dumb, but we'll deal with that later. Okay? At least now, we know for certain that we can click the attack button, and it spawns that in. That's awesome. Now that we have that dialed in, we now need to just add in a bit more clever positioning. So for starters, this Sword attack, let's go back to the hero. So right now, it's getting the wild location and then spawning it exactly on the wild location. But maybe that's not what we want, right? So what we're going to do is, let's quickly break this link, okay? So let's split this up. And then let's also hold on, let this up. Now we know for a fact that this is the X, this plane, the horizontal plane is the X. So as far as, that's fine. It can spawn at the same place on the Z. It can spawn at the same place on the y axis. But on the X, we'll simply get it and then add 120 units, which is going to push it a bit forward on the X axis. Come over here, connect that up. Excellent. And with that, let's compile. So now this time, every time that we come in and we press the attack button, it spawns just a bit ahead of the character. Yes, I know it's not working on the left side, but don't worry, we will deal with that later. We first want to make sure it does damage. So that's around where the hit box is going to spawn. That's cool. Now that we have the character just spawning in something simple into the world, let's now make some adjustments. So we have the attack dammi over here. We want it to do damage to the attack dummy. So when I come in and I spun it in, it should do damage to the attack dummy. Now, to get that working, all we have to do is to link it. We want to link it to the attack dummy. So inside of its event graph, right? We're going to get this cube we're going to come over here. I want to add an event on component begin overlap, cube. Okay. So this is the one we want. Okay. Component begin overlap. Now, as far as the other actor, the other actor is going to be the attack dummy. So we want to cast to attack dammi. Okay? So this over here, okay, cast to attack dammi. And then set it up so that the other actor is going to be set to be the attack dummy. Okay. And then after remember, every time it overlaps with the attack damming, then we want to apply damage. Okay. So that's it, the applied damage node. And the amount of damage you want to apply is ten, ok. And right after we have applied the damage of ten, we want to destroy actor and destroy which actor self. So it destroys itself, which is cool. Okay? So what we want it to do is it's going to show up on anytime it overlaps as the cube with the attack damming, it's going to apply ten damage and then destroy itself. Now, with just that simple interaction coddin let's come in. Okay. So it's attacking, but it's not properly. It seems to not be doing damage, but let's double check that, right? So let's come to the attack dummy. And quickly on any damage, let me quickly. This is just troubleshooting, okay. On any damage, let me drag this out into a sequence. Okay, so sequence basically means it will do one thing then another. And then on the next, I'm going to apply a print string, and then I'm going to call it taken damage to see if damage is being done. So I'm here. Okay, so it is not currently receiving damage, which means that the cast is not working correctly. Let's go back and revisit the cast. Ah, this is why. Because the damaged actor has not been selected, so let me select it as the damaged actor. I've saved, go back, come back in and test it again. Good. Notice it is taking damage. Excellent. So now you will have it working so that when I click to attack, the dummy is taking damage. It's still rudimentary. There's a lot more code to actually make this work effectively, but this is good. We now have the ability to spawn in a simple heat box, which does damage. Let's move forward and clean it up. Next, we're just going to do a bit of cleaning up the code to make it work more effectively. 44. 42 Making A Player Attack Part 2 Code Changes: All right. So now that we have, you know, the most basic version of a player sword attack, let's go back and revisit the DCAA of this attack. So from a design standpoint, the player swing sword to do damage. Cool. Code, apply damage to enemy objects, we have that dialed in now. And then at the Soder tack animation and the soda tack sound. And we'll get into these last two bits in the coming videos. But for now, let's clean up a lot of the code that is all about applying damage to enemy objects. Now, the way that it works currently is every time you press any attack button. Notice it's doing a lot of damage instances. So let's sort these out one by one. We are going to make sure that it only does one damage instance. Okay. And then we need to make sure that when he's facing to the left, it spawns on the left side. When he's facing to the right, it spawns on the right side. It's already doing that. But yes, that's the first thing we are going to solve. So right now, if we go back to the hero, it is getting the current wild location. And then it is adding 120 units to the position, and that's why it's spawning in. Okay. But we're going to make a quick change. Now that we know that it works, we can remove all of that code, and we're still spawning in the Sword tack one. But now, its position is not going to be determined solely by the paper flipbook. Now, let's go into the view port, right? We have a couple of things. There is the paper flip book. There is where we set up the player footsteps audio, where the jump start audio comes from, and the jump landing audio, where it comes from. Since everything the player does is attached to the paper flipbook, this is the idea location to add in all these other objects. So we're going to quickly add in a simple collision. Actually, no. We'll add in a simple let me see, add in a simple we need something visible. Let's add in a simple box collision. Okay. And this box, we're going to drop down its scale. I want it to be really low, okay? And then its position, we're going to drag it right in front. I'm sure you can kind of see what's happening here. And we're going to rename this box and want to rename it to SWOT attack, location, underscore one. Okay. So it is SWOD attack location one, and we've set it up right here. Now, just to show you why this is important, let me add a simple cube, okay? Add in a simple cube, and I've added in the simple cube to the Sword attack, right? Where is this cube located? I want it to be visible. Where is it? I'm not seeing it. Is it that tiny? If it's tiny, we're going to need to make it bigger. Oh, snap. Okay, maybe it was too large. Let's make this smaller. Yes. Now let me quickly show you, oh, why is there a break? It's refusing to compile. Okay. Why is it not compiling? Because this spawn transform has nothing to connect. Let me break that link. Now it compiles correctly, okay. So notice that no matter what happens anytime the player changes direction, that hat box is in that same location. You can notice that, right? I hope you're seeing it clearly. That is good. So now that we have that location, right? That cube location, let me delete that cube. Let's quickly select to delete the cube. We now know that anytime we can call upon the location of that. So let me go back to the attack no, sorry, back to the hero event graph. We're going to relink this o, spawning the SOD attack. But this time, we're going to get the SWOD attack location one, drag it in here. Okay, drag it in here. Then we're going to get wild location. Okay, get its wild location, and that's what we are going to use as the place where the span transform connect. So let me stack this. I like to vertically stack this whenever I get the opportunity, so that all the nodes can be in one area and I can look from down to up to see what's going on. So let's compile that. And now all of a sudden, it spawns in front, spawns the right, spawns the left, sponsor the right, spas to the left. Nice. Now we need to solve the next problem. For starters, these SOD attacks are just staying on for way too long, okay, and they are way too many. So we need to fix it so that when we spawn in that SWODtack, it disappears after a certain amount of time, okay? So let's go back to the SWOD attack itself. And we're going to change it. So for starters, it says, Hey, on event begin overlap. If it overlaps with the attack dummy, it does damage, and then it destroys itself. But what we also want is on actor, rather, sorry, I don't need that. What we want is, let's see event begin play. That's what we want. We want event begin play. We want there to be a little delay. Okay. And this delay is going to be set to 0.01, and then destroy actor. That's one way of doing it. So if we come in, now, notice that anytime I spawn in the SOD attack, it is available for about 0.1 seconds, rather sorry, it is visible for about 0.1 seconds. And then it disappears. That's one way of doing it. Another way of doing it is instead of using event begin play to destroy it, we can use event Tech and T is called every frame. So let me break the event begin play. So I don't need delay if I am using the t. So event tech going to come over here, connect that over there. And basically, every time one frame is done, it destroys the actor. So the soda tack is going to exist for only one frame. Now notice. Basically, it's now invisible. So if I come here and I click, notice it's doing damage because it's being created, but it's disappearing right after one frame, okay? And that is how you now have your character able to do damage with an invisible hit box in a single frame. That's cool. However, while this is good, we still have a challenge of every time I press the attack button, it's doing multiple attacks. It's spawning in too many. So we need to adjust that. So let's go back to the hero once again. The enhanced input action maleta, we're going to make a change. This time we're going to use what we call the do once trigger, okay? Do once. So this time, dragging from triggered, we shall say, Hey, do once, so that it only does it once, and then it can't do it again. And then completed or rather or canceled, it resets. So let's go back. So I'm going to click. Oh, sorry, I'm still zoomed in. And no, no, it's still not working correctly. It's not canceled. Break that link. Want it to be completed, it resets, compile, come back. So now, if I press once, it does one attack. So when I press once, it does one attack. Okay? Notice, I click once, it does one attack or ten damage. However, if I click and hold, nothing comes out until I press it again, okay? I have to press it again in order for it to work. And with that, we have this working effectively and clearly. So let's first do another test. Okay. So does it do damage on the left? Yes, it does damage on the left. It does damage on the right. Perfect. Perfect. Perfect. So now we have the code part of our soda tack totally dialed in. There are still more changes, but if you have understood everything about it right now and how spawning it in works, we can now move on to working on the animation so that we have a Soder tack animation that looks good in game. 46. 44 Player Sword Attack Animation Part 2: All right, so as hero, drag out from as hero, we want to find sword attack one, which is here and want to do a double check, right? Is it equal Okay, is it equal to one because it's a Boolean? And if it is, can transition. Let's compile that. We're into the game. So when I press the attack button, now it's locked in to that attack animation. That's good. So let's go back to the blueprint. Want to go to the high level of the hero to go from SOD attack one back to idol. Let's just copy all of this. Okay, because I think anytime you can copy and save time and energy, to go back to idle. Basically, it will do this except if this is set to off, and then it should go back to idle. So idle, Hold on. Attack. Okay, so now hold on. No, it's not yet here. Okay, but the attack is still running, so we need to figure out how to make sure that the attack animation goes back. So we'll go back to the hero. Soda tack is set to one. Let me get this, put this in front. So right after it spawns in the SOD, soda tack is set to zero. That's a simplified way of doing it. So now, yeah, it's not working. It's working too fast. It's going from on to off too quickly, so I could introduce a quick delay. And we'll make the delay. Actually, to make the delay true, what we would want is we'll go back, look at the art for the player. And what we want is the soda tack. The soda tack is 15 frames. You can see it here. It's 15 frames, but it is five frames of animation. Let me drop that 15-5. So it does that. Let's see. Boom. Hmm. Interesting. So it's 15 frames of it's five frames of animation. We'll keep it at five for now, just for simplicity. Go back. So five. So that's going to be 1 second of delay. So let's come back here, attack, and then it's done. So it attacks, and then it's done. The reason why it's done is because as the hero, after a 1 second delay, it sets the Sword attack one, rather it sets the SWOD attack to be zero. We are going to come back and change this up. At least we know the baseline logic is making sense. So right now from idle and then it can start moving. So you can attack and move, attack and move, attack and still continue moving. So the attack animation plays out. Then it's done. But if you're moving, you can't transition into the attack animation. Let's quickly fix that. So now we'll go back, go back into the animation blueprint to a high level. We'll do the same thing for the run. Oh, let me go back and copy the code because I want it, you know, saving life and time. Come back. So going from run to soda tack, basically, you'll go from running to the soda tack one. If as hero is as hero, the Soder tack is running, okay? And then you can go from soda tack to running. As long as the soda tack is set to zero. So, in other words, you're moving forward, which is good. So now let's try that again. So I'm running. I'm soda taking, I can go back to running. I'm running, I'm soda taking, I can go back to running. Okay. This is good. Soil attacking, cool, sod tacking, cool, soil attacking. That's working perfectly well. So let's see. Oh, okay, there's damage. There's damage. There's damage. There's damage. There's damage. That's damage. There's damage. So yeah, it's now doing damage. Okay? It's working. It's working mostly as intended. Of course, there are still a couple of issues. For example, it's doing damage on the first frame, which is not what we want, wanted to do damage around the third frame. That's when it's dangerous, right? Because he goes down, then he hits, goes down, then he hits, then it's done, goes down, hits, he's done. We'll get into those adjustments a little bit later, but now the baseline is working properly. This is good. 47. 45 Air Sword Attack Animation: Okay, so now when it comes to the ground, anytime you're moving, you're able to do that attack. When you're standing still, you can do that simple basic attack. But what about when you've jumped? Well, now we need to add in a bit because you still get that same hit box when you're jumping, right? Like, you still get that same hit box when you're jumping. But how do we make sure that you can actually do damage? I mean, the damage we already set, sorted that out. But how do we have a nice air animation for the attack? Well, let's go in and have the jump attack animation added in. So we'll go back into the adventurer and you want to quickly search under the art for attack. Okay. And now notice there is a simple air attack animation, and it has three frames of animation. It goes 0-03. Find them. Okay, they're over here. I hope you can see it clearly, but you should be able to see it clearly based off the instruction in the air. And then you're going to make these into sprites. In other words, create sprite. And then with those same three that you've created as a sprite, create flipbook and simply call it Air sword attack, underscore one. Okay. So that's the name I recommend using air Sword attack, underscore one. So it's double click. So this is the air Sword attack. That really is it. Okay. Now notice it is four frames of animation. So let me change the animation to four. Okay. This will be adjusted later, but this is just for visual clarity, okay? Now, we'll go back to the animation source, and then we will add a new animation sequence. And, of course, we shall call it air SOD attack under score one, and there it is. Okay. Now with that, of course, we will give the animation data of Air SOD attack one, and there is the Air SOD attack. That's the one that we're going to use. Now, with that, let's go back into the animation blueprint. I'm going to go back to the top. And we'll simply select the jump animation. This is going to be the one, right? Let's keep everything near the jump animation. Sorry. How do I move this around? Yes, let's move it around just a bit. Oh, this could mess it up. Let's not do that. Anyway, have that. So let's create an animation stat, and we are going to call this stat air Sword, attack under square one. Okay, for organization and clarity. And then inside, we will type play air SWOd attack. Boom, there it is. And connect it. Now that it is connected, let's quickly compile. Let's go back, and we're going to link it from the jump start, and we're going to link it back to the jump start as well. Okay, let's link it back. And what we want, let's come over here, it's going to be the exact same thing. Okay. So going from jump start to AirSdata essentially, anytime the SOD attack one is playing, we can enter that transition. And then when the SOD attack is not playing, we can exit that transition. Okay? So let's quickly compile because this is just from jumping, only from jumping. So go back to the developer level. So if I'm on the ground, it plays that SOD attack by jump. It plays the air solar tuck. Look at that. Isn't that kind of cool? Plays the air solar tuck. That's the air slash. Air slash. So now we've set it up so that in the air, there is the air slash. And on the ground, there is the ground slash. It's looking kind of good. Now that we have that basic solder tack ready to rock in game. We're going to now go in and make some much more complex adjustments to the air solder tack and the ground solder tack and get into how to make a combo system so that we can have multiple different soda tacks and also get into how to link up the attacks, okay, how to link them and have them just look cool. So we're going to go in the next couple of videos, we're going to go into how to make a three hit combo. Which combos into itself, which is a reliable system using a dial in combo system. Okay, let's get into that in the next set of lessons. Let's go 48. 46 Using Custom animation notifies for sword hitbox: Okay. So we're going to make a very important change. Now, right now in our implementation, you will notice the moment I click, the damage is done. The reason why is because the hit box for damage is being created instantly once we click. I'm sure you can see me pressing the attack button and damage is done instantly. Let's change it up so that damage is only done at a certain point during the animation, and it is part of a couple of steps we are going to be doing to make the combat a lot cleaner and better. So right now, for the melee attack to function, what happens is that there is enhanced input, male attack, that's our actual attack. And then it performs a SOD attack. Okay. And then it spawns in the SOD attack one hit box. And then after a light delay, it says that of about 1 second, it sets the SOD attack to be off. All right. Now, what we want is to change what's spawning in that SOD attack. Instead of it being spawning here, we'll quickly break this. Let's break that link and break this link. Let me quickly expand the comment box. So all of this, which is actually spawning in that attack is going to be moved down and instead, we'll only leave the code, which decides on, okay, is the SOD attack one happening or not to last for 1 second. We'll leave that there. Now, outside of that, here, this is what's actually spawning in the damage at box. Now, before we compile, what we want is for the damage to be done around the time when that slash hits. You see that nice slashy bit, that's when the damage needs to actually hit the enemy. Now, in order to do that, we'll come in here. And what we need to do is we need to have a special function or event, which actually spawns in that sword attack. So we shall simply left click and then we want to add event. And then we want to add a custom event, okay? You see that? Add custom event, and then we shall call this event span. Let's call it spun, SWOT, hit box. That's what we're going to call it. We'll call the event spun SWOD hit box, and we'll drag this over to spawning in that it box, okay? Now, one thing that we can see is now that we have this heat box removed, when we go into the level, we'll be attacking, but no damage is being done. Now, what we want to do is we want to attach the spawning of the heat box when the sod is right after it has swept. Now, to do that, we'll simply go into your character, which is the player. And we want to go into the animation and open up the paper Zi sauce and the paper Zedi Animation blueprint. Now, when it comes to the animation sauce, head over to the SOD Attack animation. Once you're at the SOD Attack animation, we are going to go over right here to this notify track. Okay. And now let me play the animation. Okay. So around here is when I want to spawn in that SOD. So I am going to right click and add Notify. But what kind of notify, I want to use a new type of notify and we shall call it SOT Hit box. Stop. Immediately, let me zoom out a bit. Immediately, the main character is swinging. That's when the SWOd at box spawns. Now that we have this notify called Sword hit box made here, let's go back to the animation Blueprint. Now, you will notice that in the animation Blueprint, there is now a new function here called SWOdHitbx. Double click on Sword hit box. Okay. Actually, let's see, it's called Sword hit box. After double clicking on it, we are here inside of this notify. And what we want to do is we will drag the as hero, drag that variable in. And then what we want is to call out that event. So we want to call out the event let's see. The event is called spawn SOD Hit box. This is it. This function over here called spawn SOD Hit box, and that is it. And Valla simply coming in, making sure that there is a special function in our main character blueprint. Going to the animation source, creating a new notify, going to our animation Blueprint, finding that notify and calling out the hero and asking it to fire off that function of sword hit box, let's double check and make sure it's working correctly. Why? Yes, notice, it is doing damage on the slide. So it is working correctly, and it is spawning the sword heat box correctly and at the right time that is good. So now we have separated our damage heat box spawning, and we've put it and connected it to the animation. The next thing we shall do is we'll go back to the sauce. Let's quickly save this. This is save. Let's quickly select the air soda tack and the air Soda tack. Let's also do the same thing around this time. We'll add the notify and where is this notify? It's called SOD Hit box. We'll add the notify here. So now it is there on the air attack and on the ground attack. Both of them are able to do so it does damage by jump. I can do a sort normal and it will do the attack, and it will slash nice and it's doing damage. So now we have an Aerattack which does damage, and we have the attack over here. Okay? Aero attack, and we have the aatack as well. Aero attack works. Grounded attack works and it works reliably. Okay. That's a really cool thing and it is good. We have that dialed in. Next, we're going to talk about we're going to talk about an input buffer and go into how to set up combos. So we want to make it so that the car player will have a cool three hit combo. Of the first slash, a new secondary slash, and a third slash to show you how to set up a nice combo system. Let's get into that in the next 49. 47 Adding More Attack Animations For The Combo System: Now, before we get into the combo sequence, the first thing that we're going to do is we're going to go in and we're going to go into the animation. Now, rather, we'll go back to the player. Let's go back into art. And what we want to do is we want to set up a couple of more combo animations, okay? Because now we started off with the first sod attack. Now we want to have a couple of more SD attack animations. You'll notice this the second adventurer attack animation. So I'll do the exact same thing with Attack two. It has five frames. I'm going to using the sprite actions, create sprites. Okay. So now the Sword attack two, rather the adventurer attack two now has sprites. I need to find those sprites though. Here we are adventurer attack two goes from zero, one, two, three, four, five. And then I'm going to create a flip book with those, and then I'm going to call them Sword attack. Stored attack under score two. Okay. Now you'll notice the Sword attack one, that slash, Sporad attack two, is that lower slash. Is the vertical, There's the downwards. Now, for uniformity, we'll come back and uniform this in a bit. And then I'm going to look for adventurers attack three. So let's look for those animations. Okay, so there is attack three. I'm going to go sprite actions, create sprites. Want to have all those as sprites. And now as three, I'll select 0-5 and create a flipbook and we'll call it SWOD attack under score three. So let me zoom in. So you'll see we have SOD attack one, SOD attack two, and SOD attack three. Oh, right. Now, we're going to slow down the animations. This is SOD attack one. It is down to one, two, three, four, five frames. So what we're going to do and keep in mind, we're only doing this course for learning purposes. I'll drop the animations down from 15 frames to five frames just for now. And then Sword attack three. Going to drop it down frames per second 15-5 as well. Just slowing it down for visual clarity. Of course, when you're doing your final game development, you can adjust those timings. I just want this to be clear and easily visible for you. Next, we're going to go into the animation source. So we have Sword attack one here already. Let me make sure the names are visible, as you can see, Sword attack one is ready. We're going to add another one, and of course, it's going to be SOD tack under square two, and we'll add another one, and it will be SOD Attack under square three. So we have our three SOD attacks here. Let me double click on two, and I'm going to search for SOD attack two. You should be able to see it there, and here it is. Let's plate. Okay. So that's the second SOD attack, and then SOD Attack three. As far as animation data, I will search for SOD Attack three. Okay, those are our three Sword attack animations. That's cool. Now, good enough that these animations also include some new air SOD attacks as well. So I'm going back to the I'm going back to the main stage once again, Control spacebar. I want to find the next Air SWOD attack. So there's a second air SOD attack. You should be able to find it. It has four frames of animation, okay? So actually, let me type air so that it will simplify finding the air attacks. So this is the first one. Okay, air attack one. Okay. And then there is air attack two. That's the one. So you can basically use air attack two as the next attack, which rather as the next set of sprites. Let me zoom out a bit to simplify this. So Air attack two, we're going to turn that into a bunch of sprites or create sprites. So Air attack two sprites are ready. I'll click on those and create a flipbook and I'll simply call it air attack under score two. Okay? So air attack, rather, let me rename it. Let me rename it to Air SOD attack underscore two. Okay? Let me come in. Right now, it's set to 15 frames. That's too many. It is 12. It is three frames of animation. So we'll leave it as three frames of animation. Simple enough. And then we shall find the next Air SO data, which is the third one. You can go in and search for it. Let's see. One, two, three, boom. This one has just two frames of animation. It looks, so we'll need to come in and add in a couple of different ones. Let's see Air soda tack three. Okay, so depending on how they've been organized, it looks a little different. But fundamentally, you can simply okay, go from ready. Let's see. This is a bit complex depending on how your sprites are organized. But let me actually select all of these. And then let's see Sprite actions we're going to create a sprite. Then with those selected, I'm going to select all of them, and then I'm going to create a flipbook. Okay, what's the flip book called? Sometimes the flipbook shows up in, like, different. Let me control Z. Oh, man, I changed the frames per second. Hold on. So let me drop this back to four, leave this. Then let's see, I created multiple flipbooks which is not what we want. Let me delete those air attack three flipbooks. Yes, let us quickly delete those. Let me come back over here. And what I want, let me type in air. I want to look for the ARSOD attacks, match all of them, and then create a flipbook. It should create a single flipbook. It shouldn't be creating multiple flipbooks. Okay. For some reason, it creates multiple flip books, which is not really what I want. That's a sprite, that's a sprite. Okay, we'll have to do this the old fashion way. So we have this adventurer air attack right here, right? Let's call this, rename it air attack under score three. So it should be ARSOD attack. Let me change the naming air SOD attack three. Now I've selected it. And what I want to do is I'm going to let me first pause it from play pause Okay, now that I've stopped it from playing, I am going to the play area, and then actually, I'm just going to add a key frame. Let me set it up so that it is four frames of animation. Most of the air attacks are four frames of animation. And then I'm going to select the second key frame. Come over here. And then left click, okay? That's the one. Left click the next one, and then I want to pick a new sprite. I'm hoping this is clearly visible. And then let me look for air attack three end, okay? So let me see how this looks. Okay. So both of these are looking very similar. So what I'm going to do, no, what I'm actually going to do is let me cancel this. What I'll set it up is instead of having a questionable air attack three, let me delete that. We'll set it up so that the Air Soda attack one and AirSDatak two will loop into each other. So AirSdatak one is set to, let's see, one, two, three, four, okay. Soda tack two is looking like that. Let me adjust this. So what I'm going to do is I'm going to get Air soda Tak one, and I'm going to duplicate it, and it has already renamed itself AirSda Tak three. That's coll. Then I'm going to get AirSDa Tak two and delete it. And then I'm going to get AirSda tak one and then I'm going to duplicate it and notice it's called itself AirdaTak two. But what I'm going to do is I'm going to get it I'm going to pause rather, I'm going to pause it, and what I'm going to do is I'm going to switch around the order of the frames. So I'm going to get frame three, and then I'm going to drag it to the start. Let me come back, make sure this is going correctly. I want to drag the last frame to the end. Let's play this, make sure that I'm organizing it correctly. Stop. So frame four rather frame two is going to be the first frame. So we need to move it around. Moving it around is surprisingly difficult. I'll have to actually pick out the sprites. So let's see here, attack two will want that to be two. So want it to start from here. And then the second one is correct. Perfect. And then the third one, fake news sprite, we want it to be when his arm is up. So type air. I'm looking. I'm looking at each sprite. These are really tiny on your screen, but you should be able to see it a bit more visibly. So I want it to start from that side and end there. Okay, this is good. So this is air attack number two. Looks kind of junk. Hold up. That last bit. That last animation, I think I'm going to remove it. Let me delete it. So it's now let's see, one, two, three frame animation. Okay, so it's a three frame animation. Okay, slashing there. Okay? That makes sense. So now AirSOd attack one looks like this. It slashes starts up, goes down, then two starts rather play. It looks like it's slashing in the opposite direction. Of course, when you're making your own custom sprites, you can adjust that, but this is going to be reasonable enough for our initial combo system. So now we have multiple SOD attacks. Let's add in those air SOD attacks. New animation sequence, air SOD, Attack, underscore two, and another one air SOD, Attack, underscore three. So two. Let's sell. No, no, no, no, no. Two. Man, my mouse is huge. Okay, so two is going to be Air SWOD attack two, and three is going to be Air SWOD attack three. There we go. And then, of course, we need to add in the notifies. The same way we added in the notifies for the SWOD attacks, we'll need to add them here. So Air SWD attack two Oh, this isn't in. Was there solder tack two. Okay, yes, that's working let's save that. So on frame two, add notify a sauce notify, SOed heat box. Okay, let's see. Soda tack one. Solder tack three. Add notify, sauce notify, Sod heat box, we drag in over here. Good. Now, solder tack one has the notify, solder tack two. Hold on. Let me see where does it come up? Here it is. So here I will add go. Okay. Add Notify SOD. Hit box, and then SODA tack three. Let's see, at what point do we need to Soda tack three, do you mind playing, please, please. Can you play? Why is it just not playing? Oh, okay. Let me hit the play button. Okay. Now I'll drag around here. This is when you want to add that notify, So hit box, save after that saved. Now these are all ready to be used in a proper actual combo system. Now that we've set up all the animations and the notifies, let's move forward. 50. 48 Getting Started With Input Buffering: All right. So before we move forward, I want to introduce you to a very simple concept. We are going to create an input buffer that stores inputs, and then it eventually resets after a period of time. This is a very general understanding. Now let's get into the code. I want this to make total sense to you. Let's go. So the very first part of the input buffer needs us to go back to the melata, okay? You see the way that it works right now is it's listening in for the enhanced input, right, of the melee attack. Then it's going to do this once and it's going to set the SOD attack to one, and then there is a delay. That's how it's doing it right now. But we're going to change that. So instead of a press of that button leading to that do once and then resetting, what we're going to do is we're going to drag this out. Okay. Now, right now, it's set to make sod attack one, but we're going to break this up. Going to break this link. And what we want is we want to now now that we have this here, we want to add in something here that's going to store, how many times the players has pressed the button. Okay? Now, for simplicity, we're going to use a basic integer. Now, remember, we have access to three different attack animations, which means that we want to do a basic check. So why is this not working clearly? Hold on. Sometimes unreal engine does strange things. But stop this. Now it should be showing the Okay, now it's able to show the animations correctly. So we have access to three different attack animations, okay? We have animation two, which is slicing up. We have two which is slicing down, and the third one is a mid slash. Okay? That's our three head combo. So in order to create a buffer, what we want to do is make sure that we are able to save has the player pressed the button once, twice or three times. Then based off that, play either one, two, or three of these attack animations. That's the basic guest of it. Now that we've broken that up, let's actually go in and think about how to make a great input buffer. Essentially what we want is a node that captures how many sword attacks the player has pressed. If they have pressed once, it will carry out one action. If they have pressed twice, it will carry out a different action. If they have pressed three times, it carries out a different one, and for simplicity's sake, we'll leave it at that. Okay. So with that in mind, let's move forward. So we have all this space here, and let's start by creating a variable. That variable is going to be an integer and we'll call it SWOT Attack number. Okay. And for simplicity's sake, we are going to make it an integer, okay? Which means it is zero to one. It is big numbers, holistic numbers with no 0.1 or two, it is an integer. Now, as an integer, let's drag this. Let's drag it out. So we want to, uh start with setting the SOD attack number. Okay? So let's open this up here. Let's say the player has just pressed the Meletack button once. What do we want to do? We want to set the soda Attack number actually. I'm going to need to create some space. So I'm going to drag these out and push them for a debt. So the player has pressed the button once. What we want to do is we want to get the SoDtac number and increase its value by one. So you can drag back in the SDtack number Okay. And then we want to add one. You want to increment it, okay? Just set it up to one. And then boom, we've set that up. So what this does is it gets the SOD tack number and it adds one to it, okay? Because fundamentally, we want to increase the number of soda tacks. Now, let's say the player has pressed that button once. I will now say, Okay, the Soda tack value is now one. Now, to show you this working, we're going to need to do some developer text. So let's have a print string. And the print string is just going to be one. Okay? It's just going to be set to one. However, what if the player presses that button again? Okay? In other words, what happens when the player presses that button for a second time? What do you want to happen? It's pretty simple. We actually want to add another one increment to that variable called Sword attack number. But now we need to do a simple check, okay? We're going to do a simple check. And what that check fundamentally is is going to be a switch. So let's switch on integer. Okay, switch on end. That's what you want to look for. And then if you come down, it will highlight itself as switch on end. Now, what does a switch on end do? What it does is it changes the pathway of the flow of code based off the value you input, okay? So let's put the SD attack number into here and it's now set to switch on end. And we'll have a couple of different values. My goodness, this is getting longer. Let's stretch out the comment box, and let's push this a little bit further. Now, let's come back here. So the first string it's meant to print is one. Let's have three of them. So the first string is going to be one. The second string is going to be two. And the third string is going to be Oh, wait, wait, wait, click this properly. The third string is going to be three. So fundamentally, we want it. Let's quickly now start adding pins. So essentially, if it is zero, it does nothing. If it is one, it prints one. If it is two, it prints two, and if it is three, it prints three. Now, that's a very simple switch. Now, let's quickly go into the developer level. So when I press one in the top left corner, I should see one. Okay. I press again, it's shown two. I hope it's showing two for you. Okay. And when you press again, it shows three. But when you press again after that, it doesn't show anything. That's fantastic. Now, we'll go back to the sword rather we'll go back to the hero. We know for a fact that now we are able to set it up. So when the player presses the button once, it has a one. When the player presses a button two, it goes to two, and when the player presses the button three, it goes to three. That's good. That means we have a way to determine if the player has pressed the button once, if they have pressed the button twice, and if they have pressed the button three times, that's pretty cool. Now that we're done with that, let's drag this and bring this in over here. We're going to add in a bit more to this. This is the baseline of the input buffer. In the next video, we're going to add on some more code to make it work properly. 51. 49 Setting Up The Basic Combo With Hard Input Lockout: Okay. Now that we have this setup and ready to go, let's get into actually adding in the animations. So to start with we already have our Sword attack one ready to rock. So what we'll do is we're going to set it up in a very similar way to sword attack one, and we're going to change it so that the switch on int happens first. Let me show you what that looks like. So we already have all these strings that show you one, two, and three, right? Now, we're going to create some new variables. The first one is going to be called Sword attack under score two. That will be for our second SOD attack. And the next one is going to be SOD attack under score three. These are just going to be useful and let me put them underneath the attack number. So I'm going to drag the attack number up. Boom, let's reorder that nicely. Hey, player health, go back up. Okay. That's it. So we have our attack number, and then we have Booleans to show if the first attack, second or third are the ones that are active currently. So after a quick compile, come over here and we're going to essentially do a very similar setup. So we'll first not get want to set. So set Swedatak 22 on here. Copy that over here. Here it is off, and we'll add in the same delay of 1 second. Okay. Let's keep the 1 second delay. Now that we have that here, let's add in Swedatag three. Now, not get. I keep getting when I should be setting, not get. Let's set it up to set. We'll add in the same delay, the exact same delay of 1 second. Here it will be yes, while here, copy and paste this over here. Here, it will say no, you're no longer carrying out Sedatak three. So we'll quickly save that up. And then we're going to, let's break this link here of setting up the SWD attack number. Let me break this link. Break all of these, and we'll drag it out and change its position. Break, break. Good, good, good. Bring this out over here. And what we'll do is at this very start, we'll drag in the SODA tack number to be the first thing that it checks, and at the default value, keep in mind it just fired this off. At the default value, it's going to be zero. So since it starts at zero, it will then connect and have the number added to it. Okay. Now that we have that basic function, add let's move forward with this. So right after pressing it for the first time, it's going to say, Hey, it's going to press that first attack, and it's going to do SOD attack one and continue along with that. And then after the second time for starters, let's first go over this text. This text that basically, we're going to go over the notes that we're currently using to increment the number, drag over them, right click, and then we'll come down and say, Hey, collapse to a macro. So now this new macro is just acting like a single node, okay? It's a very simple function, and it's going to help us kind of clean up our blueprints. And then I am going to change its name. Let me zoom out. It's a simple macro. Let me copy and paste it here and copy and paste it in again. Remember all it's doing is it's adding one to the number. So on two, it will snap, I drag the whole thing. So once the button is pressed for the second time, the attack button, it will print out two, and then it's going to try and show that, hey, the player is trying to do sold attack two. And on three, rather third time, the number will go up to two. And then it will go through, and it will tell the unreal engine that the player is trying to do the third sold attack. Once it's done with that, Let me copy. Oh, snap I cut. No. Once it's done with that, let me copy. Come out here, and actually, I don't need copy. Lets drag out the Soda tack number stead, and we're going to set the Soda tack number way back to zero so that it's going to start again from the top. So remember, if the Soda tack number starts at zero, if it's zero, when you press the button the first time, it is going to increase the value by one to one. And then new string, it will print out the string one, and then it will do the first sword attack. Now, let's go into the blueprint to have a quick look at it. So this is the animation blueprint. Quickly compile and press play. So notice right now it's set to one, 02. Now it's not it is actually not accepting you to press that. Press three, now it's able to do the first attack again. Now, this is what we're going to do. Immediately the player presses the first button. We're going to set up an input window where they can press the second combo, okay, second button in the combo. But before we do that, let's establish how to actually press the other buttons in the combo. So let's go to the blueprint, and we already know that SWOD attack one is here. We'll create another animation state, and we're going to call this stored attack two under score two. Okay. Oh, the word state is still there. Let's remove the word state. So here we are SOD attack is ready almost, and then we'll create another animation state, and we shall call this SOD attack under score three within that animation state. Here we go. And we are going to set it up that from soda tack one, you can transition to soda tak two or you can transition back to eido. Okay. You can do one of those two things, and then there's Soda tak three, which you can go into from Soda tak two. Or you can go back to IDO. So that's essentially the loop setup. From idol, you can go to soda tack one. From soda tack one, you can go to soda tack two and from two, you can go to three. Now, the buttons aren't yet set up, so notice if we press the attack button multiple times, nothing happens, that's okay. So we'll go back into the blueprint and going from soda Tech one to two, all we need is let's come in, bring out as hero. Then what we want to look for is SOD attack two. So get Soda tack two. And what we want two is the exact equals node, okay? So that's how we want it set up. And if it's yes, that value is positive, then please transition into that animation. Let's have a closer look. So as hero, Soda tack two, if it is set to yes, it can transition. Okay? So let's get out of there. And then from soda tack two to soda tack three, we'll go through the same process, get as hero, SOD attack three. Okay, want to get SOD attack three. Want to check it against the equals value, and if the equals value is yes, can transition. Okay. That's all we need. Now let's set up what the soda tack is going to actually be. Now, keep in mind, going from solder tack one to idle can be done pretty easily by setting it to soda tack one being zero, okay. So to go from soda tack two to idle will do the exact same thing. Come over here, connect it except here it is empty. And then for SDA tack three, exact same thing as well. Back to idle. We simply paste our code and we uncheck the check box. This is the fundamental and simple and easy way to set this up. Then we'll double click inside of SDA tack two, and we want to type play SOD attack two. That's the animation we want played. And then in soda tack three, we type play Sword attack three. Okay. Which is the animation we want it to play. Double check, place Solder tack, two or three. Good. Now, with just that basic setup, if we go back into the developer level, and one, two, three. Okay. Notice that it does the combo, one, two, three. So we now have our basic combo working. So let's try to do the three hits on our practice dummy. One, two, three. Okay. Let's do it again. One, two, three. Nice. One, two, three. We have our combo. Okay. Now, here's the beautiful thing. Now that we have this setup, okay? The buttons actually working, you can see that there's a 1 second delay where you get to make the decision on whether or not you're going to continue doing this, or if you're going to stop, see? Now let's get into that. How do we set it up so that there is a light delay so that we know I can come in if I hit one, right? Right now it's set up with a very hard delay. You're either doing the full combo or it locks you out of pressing buttons. So let's say if I only press anime one attack, I can't press the others no matter what. Let's go in in the next video and adjust the code so that you have a lot more combo freedom. Let's go. 52. 50 A Brief overview before more integration of the combo system: All right. So now you have a reasonable understanding. You know how the baseline systems for animation works. You've understood to a certain level how animation notifies work, and you have understood how to create systems whereby, you know, health gets reduced. That is ultra cool. Now we are moving on to linking those systems up in a much tighter, much more integrated way. So let's go in to how to use notifies for our combo system. So let's start with what we have set up. This is the current hero blueprint, right? Every time the Me attack button is pressed, okay? Every single time. We now come in and we are able to look at let's look at these nodes. We go from Mela tack it's going to switch on t as it's counting the multiplier. It does some simple addition plus one. It prints out that string, and then it chooses which Seda tack. It will say, Hey, Seda tack one is being done. Then after delay, it says, Okay, we're done doing solder tack one. It does the same for two and three. That's how it's currently working, and I use this to just show you how the systems work. Now let's make it a lot more integrated and most of the logic is going to be done using the animation notifies. As an example, we know that the SOD span SOD hit box notifier is the only thing that's leading to the span SWOD attack one hit box is being brought in. So we're going to do the same thing, but we're going to be making adjustments to how the attacks are done. Fundamentally, this is what we will do. We will make sure that if the player is pressing the attack button, the combo gets fully run through. If the player stops, the character can reset. That's the generalized overview of what we are going to be doing next. And we are, let me press Control Space Bar, Animation, Animation blueprint. Okay. And next, open up the animation source. So we are going to be using entirely the notifier system to set up the animations and we will start off with the ground animations, then we'll move on and we are going to make some big adjustments to the air attacks to make them a lot more fun to use. Let's get into that in the next video. I hope you've understood everything up to the current point. If there's anything missing, please feel free to review the videos. So when you come back, you have that deep understanding and everything that happens next is going to make sense to you. Let's 53. 51 Adding Attack Link to first Sword Attack: Okay. So now let's get into linking our attacks with listening for the right input. Now, currently in the game, when you press the attack button, for starters, it stops listening after you press after you fail to input the combo. So that's the current code just to show you the baseline combo. Now, this is what we're going to do. When the player presses the fast attack, we are going to be listening to if the player has pressed the second attack button. If the player links the second attack button, then we will press both attacks. It will do both attacks. During the second attack, if the player does the third, the third attack is going to come out. In order to do that, let's move forward and set that up in game. The first things first, when we think back to the code, all that it's doing is the moment soda tack three is set to, it fires the Soda tack. Soda tack two, it does those things. But now we're going to set these up as connected to animation. So in order to do that, let me first shrink down the size of this MeleaTak comment box just a little bit. Let me actually get it. And, I don't know what that was. Copy it. Okay, I just want another box here. And I'm going to call this attack. Links. Okay. So to start with, we're going to start by keeping it very simple. We are going to have the first one be called SOD attack one. Okay. So let's come over here. Now we're going to fly off an event. Okay, we want to have a custom event. Okay. We're adding in a custom event. And then we're going to call this SOD. Let me zoom in properly. It will be called SOD attack. Under spot two, underscore, Link. Okay. That's all it's going to be called. It is called SOD attack to Link. That's what we want it to be. And what will we do after the SOD attack to Link? Well, it's quite simple. We're going to come out here and we want to check something. So what are we checking? Well, it's quite simple. We want to check and see if the SOD attack button, the second attack button has been pressed. In other words, if the SOD attack number is two. So in order to do that, we'll come here, we'll drag this out, and we'll say, Hey, get SWOD attack number. And we want to do a basic check, okay? So we'll do a simple branch. A branch is going to let us check and make a change in what happens if it's true or false. So with the SWD attack number, let me drag this out. I'm going to say equals two, okay? In other words, if it is exactly equals two, or let's drag this out. Let's make it greater equal, okay? So if the SWOd attack number is greater than one or equal to one, then it's going to play everything after that length. Now, let's come over here. And we'll start with a simple print screen. So it will print, and it's simply going to print out text saying, Hey, do SWOd SWtaT. That's it. Because we're just going to check and see if the code is running correctly, okay? Now with SWOD attack two link checked in, to prevent that from being interrupted by anything else, we'll come over here and we're going to, let's quickly break off the other links. Okay, we'll break this up. So after the attack button is pressed, when it's pressed once, it's going to carry out that first bit of code for the first SWOD attack, but it's not going to do anything else. Okay? So if we going into game right now, when I press once, yup, all of that is gone. So I can only press that attack button once. That's good. Now, we'll go back into the animation blueprint and we'll look for SWOD attack one. So there's this function here. Rather, there's this notify called SWOD hit box. Now, this is what we're going to do. At the very end of the animation, at the end of the last frame, okay? We're going to add in a new notify. Let me jump on the notify track. And it will add in a notify and it will be a new notifier. And we're going to call that notifier SWODtakUndscoe. Two, underscore Link. Okay. Now, that's a pretty long name, but, you know, it's slimmed like that for a reason because this is the link from SODA tack one going to two. So we'll call it SODA Tak two link, okay? Now, now that we have that ready, let's go straight back into the animation blueprint, and we will go into the event graph. We'll go into the event graph, and let's come here. We have receive Notify for the hit box that's called. Let's go into the receive Notify for Sword attack to link. Okay? This is the area where that code will be executed. We'll come in and say, Hey, as hero, we want SOD attack to link. Okay. Notice it's there. The function, SOD attack two link is there, execute that function. Okay. So there we go. Now that we have this setup, let's check it out in game. I'm going to press Play. First attack, second attack, it's doing SOD attack to link, checking that out. Now let's go into hero in order to get the SOD to actually update its number. Let's break this link here. We don't need any of the other code to run here. There is no need, but what we are going to do come over here. Let me grab this. So we'll get all this code that says, Hey, SOD attack two, after 1 second delay, make it off, and then we're going to just grab this code and cut it. Okay? So we're taking it away to be used elsewhere. Okay? So let's come into the attack link, and this is what we're going to do. We're going to put that code here. So let me go through this slowly. The moment the SwedaTak two link custom event is fired, it's going to double check the SwedaTak number. And if the SWDatak number is greater than one, right, which means that the player has pressed the SWDatak button more than one time, right? It's going to come here, say it's true core. So it will print out the string. Do Swedatak two. And then it is going to let me link this. Hey, let's zoom in again. It will say, Hey, Soda tack two, thumbs up, it is being done, and after a delay of 1 second, it's going to set SWOD attack to being off. That's all it's going to do, okay? That's all that function is going to do. Now that it's done, let's see if it's going to function properly here. So Did you see that? So let's do that start that over again. So when I pressed it once, it actually properly played the second animation. Okay? So it is working correctly. Okay, it's working correctly. And the reason it's working correctly, I'll go through the logic one more time. Every time the player goes through that first soda attack, at the end of the Sedatack at the end is when the game is going to come back and check, and it's going to carry out this action. SodatackT length. It double checks. Hey, what's the Soda tack number? Is the Soda tack number greater than one? Rather, is it equal to or greater than one? Then, okay, carry out the full attack. Now, let's do a quick logic check. Okay. So immediately you press the attack button once. This macro basically increments it 0-1. So it's going to make it one and carry that out good. So we'll need to change this code to not greater equal to one, but greater equal to two. That means the SOD attack button has been pressed more than once. That means the player wants two or more attacks. Let's try it once. Press once. Nothing happens. Good. Try it again. Press twice. Ah, that's the problem. Let's try it again. Press twice. It's not playing the second hit. Okay, so let's go back and do a quick check. The reason why it's not playing the second hit, here it is. It's not playing the second hit because this macro is not connected. Let's connect it up again. Do a quick compile, go back and test it out again. Press the SWOD attack button once. Okay, the attack comes out. Press it twice. Both attacks come out. Perfect. Now it is working correctly because every time you press the SWD tack number is being reset, rather it is being incremented by one. That is a good thing, the code is running correctly. Now, just to make sure that this is working fully correctly, let's come back. If the SWD tack number on the SdTakTink is not greater than or equal to two, we want to reset the Seda tax back to zero. So we'll come over here, I'll simply say set Okay, SOD attack number. I'll bring it over here. I'm going to set the SDtack number two. I'll come over here. Let me first break that link to zero. So this is what's going to happen. It will check if the SD attack number is two or greater. If it checks and that's good, it does and does the SD attack to. If it is not, then it will reset the SOD attack number back to zero. And the reason we are doing that but Okay, the reason we're doing that is so that back here, this initial code running of the SOD attack number, it will start checking from zero once again. This should be working correctly. Let's see it in game. So So data one, two, nice, it does. So da tack one. Okay, it's not working correctly yet. Let's go back and do another quick check. So doing it once does that. This is working correctly as intended. This should be working correctly as intended. That's if it is one, break this link. If it is two, it should be increasing it above two, that's okay. So if it is one, it will become two. If it is greater than two, that's fine because I pressed more than twice. So let's double check and see one, two, it does that. Okay. Perfect. Perfect. Now we're going to make one more adjustment. So what we're going to do is we need to do a basic check coming over here. So right after this delay, because there is a delay of 1 second after the first SWOD attack, what we want to do, let me copy this. Bring this in over here. I actually want to do this check, but let's not check it here. What we want to do is check here. We are checking to see is the number greater than two? If it's greater than two, carry out the string. That's okay. If the number is less than two, meaning if the number is one, it will set SOD attack back to zero. So let's have some text here. Let's print some text, and we'll call it attack reset. Because we want to make sure we can see when the attack is reset. Let me change that color. I guess pink is fine. Go back into game, making sure the code is running correctly once, twice. Okay, it does it. But it's not able to go back and do it again. Okay, we're going to have a quick code revisit in the next video. 54. 52 Adding Attack Link to the second Sword Attack: Okay, now moving on. Currently, if I press the attack button twice, the player will do the buttons, but it doesn't reset yet. But if I press it once, it will reset, letting me do the attack. Now, the point where the resetting is done, let's open the Hero blueprint is if it finds out that the number of times you've pressed the attack is greater than or equal to two, it will do the combo, but there's no resetting after that. That's okay. We will deal with the resetting later. But if you press once, it will reset the sword attack number back to zero and print the string attack reset. So this is what it looks like in game. Press once, attack, reset. Press once, attack, reset. Press twice. It does both attacks, but there is no reset. That is good. It's working as intended. Now let's move on to attack number two. We will go back to the animation Blueprint sauce, and we will select attack number two. Now, with attack number two, let's quickly play. Good. Now, right after the sword hit box is span, at the end of the animation, we will add a new notify. Okay. So we will add one of these notifiers we want a new notify, and we are going to call, actually. Let's first go back. I want the naming to be SWOD attack two link that's CO. So on SWOD attack three, we are going to add a new notify, and it is going to be called SWOD Attack Underscore three, underscore Link. Okay. That is its name, and it is at the very end of the animation. That's when we want to do it because that's when the animation is completely done. That's cool. And then in the animation blueprint, Okay. Let's go. Now SWOd attack two's first double cricket. What happens on that link is we get the hero and we play the event SWOd attack to Link. So let's set up the event in our character blueprint class under attack Links. So the SWOD attack two Link over here. What we now want to do is we want to set up another custom event, and we will call this custom event SWOD attack underscore three, underscore ink. We want to have the naming be as uniform as possible. Very good for organization. And then with that, I'm basically going to copy all of this over, okay? I don't think there's a reason for me to rewrite all of it. There is going to be some rewriting. But for speed and simplicity, let's just copy it over and go through it once again. Now, what have we copied over? SWOD attack to link. Let's zoom in a little bit more. We get the SWOD attack number. If it is greater than or equal to two, True. Do soda tack two. That's what's printed out. It sets Soda tack two to be active. After 1 second delay, it activates it. Okay. And then if it is less than two, it simply plays the false nodes. Sodtac number gets set back to zero and prints the string attack reset. That's core. Now, on soda tack three, we will simply link it over here. Now, if the SOD tacks are either greater than or equal to three, it will play out all three of those. Okay. It comes over here. Instead of setting SDtack two, we'll change that to setting SOD attack three. So let's get SOD attack three and drag it in and set it as set Zoom in. So we shall set it to, yes, SOD attack three is on. It is being carried out. We'll link the delay we'll copy and paste this over here, drag this out and set it to now being off after 1 second. Okay. And then here we can see. So the attack number is set to zero, and there is an attack reset. Okay. Now, let's quickly compile this and voila. So let's go to the level. Let's hit Play. One attack reset, one, two. Okay. I didn't run through that code properly. We'll need to have a quick check. One attack reset, one, two, okay? Oh, yes, the function's not done. We just got done setting it up here. Oh, that's me. Okay, let's go back to the animation blueprint. Open up SWOd attack three ink. Okay. Now that we have SWOT attack three ink setup, I'm going to add this in, get as hero, and then we want SWOT attack three link to be what plays after. So let's play that after. Now it should work properly. It play one attack reset, one, two, I'm not seeing the attack reset. Let's go back and have another look. So on the first SWD attack, we have SWD attack to link, and it's working correctly. On the second SOD attack, let me quickly save that, make sure everything is saved. Save all, save all the changes. We have SOD Attack three link set up over here. We'll go back to the animation blueprint. Sword attach three link seems to be working correctly. Sword attach three link is working correctly. Now let's come back, make sure that everything else is working correctly. Okay. If the number set is, here's where the problem is. Okay, let's quickly add a pin. So if the number is three, get this macro and recopy it. That means that the button has been pressed three times. Increase the number by one. That's probably not the problem, but let's have it added in. That means the button has been pressed three times. Then come over here, Sword attack three. Meaning three attacks should be pressed. So Sword attack two is playing out correctly. I hope you're following. I hope this makes sense. We come here, Sword attack. Do SWOd attack three. That is the correct text. Comes over here, Sword attack three. Delay, delay. Done. Okay, let's come back here. Press once. Attack reset, press twice. Okay, it does the second sowed attack. Perfect. Now, what's the problem is that after finishing the second soda tack, it does not reset it. Let's see. Why is it not resetting after the second Soder tack? Because after that, this is being played. Let's do some basic troubleshooting. Let's see if this is actually playing out. Print string hello hello should be fine enough. Compile. I press once. The reset is working. I press twice. The reset is working. I press once. Okay. Understood. I'm going to need to do some double checking to see what's working. Hm. Either way, I think I'm actually quite a bit tired. I've been on this for a long time. I'll come back and update some of this code. 55. 53 Finalizing Combo Links and Resets For The Grounded Combo: Okay, so some coffee has been drunk and some time has passed. So coming back and setting up this system properly. So let's go back and do it from first principles. For starters, make sure to have the animation sauce. Here, make sure to have the Z animation blueprint. Okay? Here, we can check out the animation graph. And we're going to go one by one to check on the attacks. So every time the attack button is pressed, enhanced input action mele attack is fired off. Okay. Once that's done, we go into a do once that only resets when the button is let go of and we go to a switch on integer based off the SWODattack number. So let's start by going through the fast attack. So with the fast attack after increasing the number by one, so now the SOD attack number is set to one. We print out a string called one. That's fine. We make sure SWD attack one is set to true. There is a delay of 1 second, and then SWD tack one is set to false. Now, when the SOD tack is actually being done, what happens is that SOD attack two link, that node is fired off, which changes the soda I checks the Sdtack number if it is greater than or equal to two. That will be the condition. If it is true, that it's greater than no equal to two. In other words, the player has pressed the soda attack button multiple times. It prints the string, do solder attack two. It sets sold attack two to being fired off. There's a delay, and then sold attack two is canceled. If it is false, it resets sold attack number to zero, and it prints out attack reset. Now we're going to make a couple of changes. For starters Okay. For starters, we are going to remove the delay. We do not need that delay, and we are going to get the node that sets Swadata animation one to being off. Two, let's first start by putting that off here. Now, the reason why we want to do that is we want this to only fire off I want this to fire off based off animation, not based off a time delay. Now the reason why we're doing it is because let's go back to the papers de animation of sod attack one. So you will notice that at the end of the Seder tack, Okay, sorry. Scroll here. At the end of the swedatak is when this is fired. Let me drag it forward a bit to the maximum time. So I want to set Swedatak off just around here, right at the end when it's fired off. Okay. Now, let me zoom back out. That's essentially what we want. So with just that simple change to the code, let's come back. So the positioning of setting soda Attack one, two off should be somewhere here. Let me drag a lot of these forward, drag this forward to make the space. Okay, organizing them up. I'll stack these vertically, then connect this. So the first thing it does trying to link to the second solder tack is it checks it makes sure that the variable solder tack one is set off, okay? That's essentially what it's going to be set to. Now with that set, let's do a quick check. So this is just the first solder tack. Once the melee button is pressed once, it does the simple do once, switch on int, it starts at zero, and then it is going to set Suder tack 121 to start playing that animation. I'll come over here. So that custom event set Seda tack one being off, there is a simple branch condition check. It will do the swedatack two. And then it will set Swedatak two to being more. We'll start off with just that and let's see if that leads to cleaner animations for us. Let's see. Press once. Hold on. Okay, I didn't do the proper reset. Once? No, it doesn't. Press once. Okay, attack reset. The attack reset is working well. Press once, tack reset, press twice. It didn't finish doing SwedaTa two. Now the reason why it didn't finish doing SwedaTak two comes down to the animation blueprint. So right now, it can only go from SwedaTak one to Seda Tak two. That's essentially all it can do. But we're going to change this. So let's quickly let's quickly come over here. So the code from SOD tack one to two is if Sud Atak two is activated. So let's just copy that code and we'll drag from idle to Swedtak two, paste it in, connect that. Okay, let's make sure I really love organization. I really, really do. Let me align them in the middle. Okay. Now, with just that simple change, we have made it so that it can transition from idle to SOD attack two, which is fine. So let's come over here, we're idle. Word attack one reset. Okay, so now it can transition it can transition from Okay. I can do it only once, though. We need to work on the resets. It can do that. So there I played both animations. But we need to do a little bit more cleanup because as much as it's nice that it can go from idle to Swedatack too, you will need to also set it so that it can go from running to Soda tack two, which is going to add a lot more to this area. Now, one moment. Now, doing that solves that problem, but we still want it to be able to transition from Sedatak one to two. What if we go back to the blueprint? Right? This is the character blueprint. What if instead we only made Seda tack one go off let's first remove that duration delay for turning off Sed attack two. We only made that go off around here, right? So right after turning Sed attack two on, would it allow Sdtack one to run right after? However, also, we need to do this so that on attack reset, right after the reset, also turns off the Sudtack one. So let's try that. Okay. Oh. Okay, so Soder tack two is just running. So right here, one, a reset, good. Nice. Now the second attack is coming out. This is good. So that's a much better implementation. So we'll go from let's see. So Soder tack two we'll turn it on. We'll turn off Solder tack one, and we'll move forward from there. Good. Now, for a last test, there is idle over here. Let's break the link here, let's delete that. Let's compile, turn it on. One, attack reset, one attack reset, one, two. Well, didn't do Sedatack two. Try that again. One, attack reset, one. I'm seeing the text of D SDTack two, but I'm not seeing the actual SdTack two coming out. Hmm. Hm. Why would it do that? Okay, so let's come in here. Let's add a delay. I think a delay of 0.2 seconds is reasonable. Let's drop that down to even less. So that delay is now 0.1 seconds and see if it will carry out the attack correctly. Once once reset. Once reset once, twice. Okay. Okay. Now it's working correctly. Okay, that's good. Adding in that minor delay prevented the code from firing off too fast so that we can turn solder tack off right when the second solder tack is actually firing off. Now with that in mind, we have done the first solder attack. Now for the second solder tack, that's come in over here. That's Soder tack three length, which is what we fire off when let's open up SWD attack two. Let's quickly save all. Always important to save all. So right after that downswing, we have SOD attack three link, which is the next thing we need to look at. So we'll go into the SWOD attack three link, and it's set. So the way it's set up, this is at the end of the SWD attack two comes over here if the attack number is greater than or equal to three. Okay, I will do that check if it's less. It sets SWD attack number 20 and does an attack reset. Good. If it is true, it will do SWD attack three and set SWD attack 32 on. Okay, this is good. This is very good. Now that this is done, let's come over here. What we want is SWOD attack two to be turned off and we want it to be turned off around here. So I'll sweat that up too. Let me get that. Paste that over here. Want it to be set off. And then on reset, we also want it to be set two off. We'll get this delay, and we will drop it down to 0.1, compile, go back and now test it. After compiling, let's do this test. One, two, three. Okay, good. That's working correctly. Let's do that again. One, attack reset, one, two, Attack reset, one, two, Attack is reset. Let's do it three times. A, nice. Now, we simply need a function to end the third SOD attack. Let's come out. We'll go into the animation source once again, go to SOD attack three, and then at the end, we're going to add in a new notify and we're going to call it sword combo. Okay. Drag it to the end, drag it over there. Okay, so it's the Sword combo end. Now that we have the SWOd combo end set up over there, we'll go into the hero, and we are going to create a new event, and it will be a custom event. Now, we shall call this custom event sword, combo and Okay, want to keep the names consistent. That's it. SOD Combo end. That's the one we'll be using. Now, inside of SOD combo end, all we are going to do is number one, we're going to do a basic reset. So we are setting the attack count back down to zero, and we are going to get SWODAttack three, put it in here and turn it off. That's all we're going to do. So quickly hit compile. And there we are. Sword tack three is set off. Sword tack number is set to zero. And now we go back to the animation blueprint. Let me quickly save all and compile. That's a good compile. And what we want is to look for receive notify sword combo end. Good. Then we will say, Hey, as player, rather, get as hero. Here, one sword combo end, you fire off. Perfect. Compile. And then just for the sake of simplicity, let's come here and drag this out. And we want to print string, and we will call the string combo end and let me turn its color to a color we'll notice, turn it to red, nice deep red. So that will be able to see clearly whether or not everything is working correctly. So here we are attack reset. When I press the attack button once, I get an attack reset. When I press it twice. Mm hmm. Good. And then I get the attack reset. Then if I press it three times, it does that and it does the combo end. One, two, three, and it does the combo end. That's actually pretty good. So now we have a very basic combo system for the grounded attacks. So I've pressed the attack button three times and it's done. Now, keep in mind the reason why I'm having the attacks so slow is mostly for learning and teaching. You can speed up the frame rate of the attacks based off what you find to be appropriate. For the kind of attacks that you want in your game. So right now, these ones are really slow, okay? But you can have it so that they are much faster than this. So let me show you what that looks like. So we shall go back into the let's see. Now, let's go into the animations. No, no, no, going to the art. Yes, yes, yes. Then scroll down. So sod attack one, for instance, is set to five frames per second. Okay. But we can go and set it up differently. We can set it up to 15 frames per second. So that's a much faster sod attack one. Then now that we have this at 15 frames per second, let's check in the paper the animation. Notice it's a much faster animation. Then let us attack. Notice it comes out quicker. Nice. Notice, fires off once and resets. Nice. And then there are those other attacks. Those attacks are slower. Now, let me adjust the attack animation to be not that fast. Let me reduce it to ten frames per second. So this is how the animations look now. Okay, so those two are slow. Let's speed them up. So soda tak two, let me increase it from five frames per second to ten frames per second. Load that. And then soda tack three. I also increase it from five frames per second to ten frames per second. Okay, one, two, so it does both attacks. Then look at that. One, two, three, one, two, three, one, two, three. Okay, so you can dial them in, or you can sort of semi precision time it, okay? So there we are. Now we have a simple player attack. Okay. So that is essentially it. That is how to set up a simple combo system for our player. So now that we have a simple combo system, for our grounded attacks, let's do the same thing for our air attacks because notice when he jumps, okay? When our hero jumps, all they're doing is a single slash, and the animations kind of broken. So we'll come in and adjust those air attack animations in the next video. Let's go. 56. 54 Checking if player is aerial for sword attack routes: All right. So now that we have our grounded combos set up properly, right? We now want our air to also be properly set up. So let's set up a air combo system. Now, essentially, we will be doing the same thing we did for the grounded, but there are going to be a couple of changes, okay? But we'll get into that. So let's go back into the animation sauce. So this is our first air combo attack. There's that air slice. Next is that down slice while in the air, and the final one is a downward slash while in the air. Okay, so this is essentially what we have for our air combos. We're going to carry out a very similar sort of organization to how we want the air combos to interact. Now let's have a quick look at the animation blueprint. So this is the animation graph. So what we are able to do is we can go from any SOD attack back to idle. We can go from SOD attack one, back to the running animation or back to idle. And then from here, as you can see, we can currently go from a jumping start back to air SOD attack one, okay? So rather back to Seda tack. But Seda tack is currently set up to be Sword Attack one. Now, we are going to adjust this so that we can separate our air combo checks from our grounded combo checks. So let's quickly go into the hero animation, and that's where we're going to start. So here we are. There are all these different attack links, and what we'll simply do is we're going to rather, we're going to get this box, going to copy it, and we're going to put it over here. Okay, below because you want them to be nearby. And what we'll do is we'll change this name from attack links to attack links grounded. And these will be set to attack links air. So this will hold our grounded attack links, and this is going to have our air attack links. Now, let's come back to the me attack. So this is the me attack, normal, okay. Let me quickly get this and drag this down over here. Just to give us a little bit of space to work with. And now we are going to add a new check. Now, that check is going to be a simple check to see if the player is jumping. And the way we're going to do that, we'll simply grab all of this content from the switch on end, move it a bit to the right, come over here and let's first break this, right? What we just want to do is we want to have a simple es jumping function. We need to get whether or not the player is jumping, and the best way to do that is we want to use the character movement component. Now, if you go back to the left area, right, let's scroll down. Notice that there is a character movement component. We want to access information from that component. Now to access the information from the character movement component, we're going to drag this out and we want to ask is falling. Now, is falling is going to always return true if the player is in a jumping state. So anytime the player is in a jumping state is falling is going to be set to true. If the player is on the ground, it will be set to falls. Now, let's open up a quick branch. And from that branch, what we want is connect this over here, okay? Want to connect the check of whether or not the player is falling to that branch. And we want to have let me first zoom out real quick because I want to have even more space for this, drag this out over here, okay? Give us the space. We need the space. Okay, let's go back in. Now, what we want is if it is true that the player is falling, simply print out in big bold letters. Yes. Okay. And in which color, let's make the color green. Yes, the player is jumping, is falling rather. Okay? I'm copy pasting. Okay. L over here. However, if it is false, let's set it up to say no. Okay. That's essentially going to be it. And in which color, let's change it to the color red. Now, what we have done fundamentally is pretty simple. We've set up the attack animation, the attack button to check if the player is jumping, say yes. If the player is falling, say no. Okay. If the player is grounded, if the player is grounded, say no. If the player is in an area state, say yes. So let's move around. I pressed, it's saying, no, no, no, no, no, because the player is on the ground. So that's going to be good for our grounded combos, okay? It's just no. But when I'm in the air, it's saying yes. Notice that, right? Any jump state, it's going to say yes. But when it's grounded, it will say no. When when I'm jumping, it says yes. Grounded, no. Jumping. Perfect. So we have the first thing we need right now in play. So let's quickly save all. It's always good to save unreal engine from time to time. Let's close this up, close this up, come over here and close this. So now that we have these two working as intended, let's now set up our connection. Now, we know for a fact, right, that this switch on t works like this. Once the attack button is pressed, once it's pressed, it does the increment, then it comes here and it sets up SWOD attack one to be active. Okay. Which leads to the flow chart whereby it starts processing through the attack links of SWODattack link two and three, and then eventually the combo end. All of that is done through that. So what we want now is to organize it so that we'll leave the switch as normal. We can leave the switch as normal, if need be, we can leave it as normal. However, what we will do is we'll set it up so that right around here, it is going to instead of setting up SOD attack one, it's going to set up the Aero SOD attack one. And from there, we'll go through the same process to set up the SWOD attack combos. That's how we're going to do it. 57. 55 Setting Up Animation Blueprints For Air Combo: So now that we basically have the simple way to do the check available to us. Let's now get this, cut all of that. Get all of these nodes, put them back from the switch on int. And this time, instead of printing that string, let's paste this all here, and this is what we're going to do is the player falling. Okay? If the player is not falling, start off with Sword attack one. Cool. That's essentially it. That's all we're doing. If the player is falling, turn on SWOd attack one. Okay, set that boolean to one. Now we're going to create three other booleans. For that one, we're going to call it air SWOD attack under square one. We're going to add another one, and we're going to call it air SOD attack under score two, and another one called air SOD attack under score three. So we have our three air SOD attack variables set up. Now what we are going to do, we'll come over here and we'll drag in air SOD attack one, and we will set it. We turned on. And we'll drag and connect these two together, and then we'll do a quick compile. Now, if we are on the ground, let's go back. I need to make sure this is being done correctly. I hadn't connected this initial link, let's fix that quickly back out and then compile, go back once again, grounded I can do my three hit grounded combo. I can do my two hit grounded combo. I can do my three hit grounded combo. I can do my two hits. One, two, three. Nice. Perfect. So the grounded combos are working very well. But if I jump up, notice Uh huh. It's not doing anything yet. That's cool. Let's now start implementing the code to do the air attack. Now, we'll go back into the paper Z D animation. The first attack is that swipe, which is air attack one. So we'll go into the animation blueprint once again, and going from jumpstart to Air Swedatak is what we want. So come into here. But this time instead of looking for Swedatak one, we will be looking for air SWOD attack one. Hold on. Yes, I want to get Air Sword attack one and link it in over here. If it's true, it can transition, and then we'll back out. And then we'll go under here and then he set this up to Air SOD attack as well. Rag this out. Air SWOD attack one. Perfect. And yes, if it's empty, it will stop. This time, on the ground, I get my attack. In the air, I get my air SOD attack. That's good. It's not yet resetting, but we know that this is working. The next step, of course, it's the same way we did it for the others is we're going to now add in new animation states. We'll call this air SWOD attack under square two and we'll add another animation state. And we'll call it a SOD attack under score three. And we'll organize them the exact same way. So you can go from air SWODtack one to AirSDtak two. You can go from AirSDtack two. Back to jump start, from AirSWdtack three to jump start and from AirSWDtack two to AirSODtack three. Make sure these are connected properly. Now that these are connected properly, we're going to make some more adjustments to do a quick double check. Okay? This is working well. Everything should be making logical sense. Let me just move these up. Let's just move up their positions a bit, make it look more like, like that. So there's a box of animations. I like how that looks design wise. And let me also move this up like this, look more like a box. I like this. This looks pretty cool. All right. Now, we know that to go from jump start can go from jump start to AirSOD attack one. And what we are doing is we are checking AirSOD attack one. Now, from AirSOD attack one to two, what we want is we'll get as hero. And we will check air SWDatak two. Okay. And we want to see equal. Is it exactly equal to, it is turned on? If it is exactly equal to turned on, it can transition. So you can transition there. Let's copy this to simplify what we need to do next. Then from AirSwdatak two back to JumpStart, that is pretty simple. If Air SOD Attack two is off, it can do that transition. Now, how about going from AirSOD attack two to three? That's pretty simple. The only thing we change is this time we are getting Air Word attack three. Okay, we are getting it. Connect it over here. If it's on nice, perfect, you can do that transition. But then from airs warder tack three, going back to Jump Start, it's the same thing except this time we make sure that it's set to not be active, okay. And that's all we need to set this up. Now that we've set this up, we'll compile. And with everything compiled the way that it's set up right now, we are still a bit away from having everything working as intended because we've set up the animation nodes, but we've not set up the animations. So we'll go into the animation node and we'll say, Hey, play air SWOd attack two. So it's set to play that animation, come out on SWD attack three. Play air. So of course, you know which animation, Air SWD Attack three. And now that all of these attack animations are set up, we are in a much better state. Of course, it's not yet properly working, simply because when you jump, it will only do one attack, and then there is no resetting. So next, we are going to do the resets and add in a little bit of code, finalize that for the air combo. 58. 56 Setting Up Air Combo Logic: So now that we have that basic animation linking, then we are going to use the same flow of logic to set up inside our notifies for SOD attacks, okay? So we shall go into the animation source for the air SOD attack, and at the end of the air SOD attack, we shall simply add a notify. It will be a new notify and it will be air SOT attack. Underscore. Let's see Air SOD attack two, underscore ink. There it is Air SWODtackUndercore. Link is fully set up and we want to use the exact same convention we used with the normal SOD tack. If I'm to click on the normal SODA tack Hold on. That's SODA tack I'm over here. Let's zoom out just a bit. I think I'm too zoomed in. Okay. So you'll notice ARSOd Attack three Link is set up over there. I need to zoom out. Why is it not showing this correctly? Okay, it is not showing the frames correctly. Anyway, regardless, we'll need to come and adjust this later, but before we do, yeah, this is much better. You can see spawn hit box. And then SOD combo ender, the notifiers are there. We'll come and clean this up, but a little bit later. So as you can see, the spawn heat box is there, and then at the end is the Air SODA Tak two link. And then at the end of ARSODATac two, we're going to drop a notifier and we'll create a new notifier and we're going to call it air SWODTaUnder Score three, underscore, Link. Okay, that's the next notifier. And then at the end, we'll come down over here again, and this is our third one. So just add the notify a new notify, and it will simply be air combo. That's all it's going to be air combo end. So right after the third air attack, the combo comes to an end. Now, we shall now go back to the player blueprint. And literally since the logic is the same, we'll simply connect all of these, copy them. Okay, copying and pasting saves you a lot of time. Trust me, bro. Okay, we'll stop here. Now, it has set up different custom events for us here. Now we'll quickly come, double click on this. I've pressed F two so that we can change them. So this is air, SOD, attack, underscore two, underscore link. Okay? That's the name of that event. So that's what we need. So we have Soder tack two link here. Here we have Soda tack three, cool. So we'll do the exact same thing here. So we've started with air SWOD attack two Link. Let's rename this as well. Air SOD, attack, underscore three, underscore Link. No, that's incorrect spelling. Underscore ink with a K, not with an L. And then for the last one, this is the combo ender. So let's first go back and to make sure this is the exact same name. It's air combo end. Good. So come here. We'll zoom in. So I will rename this and I will call it air combo end and we're done. Next, we need to replace all of the SODA tacks with their correct version. I let me type this air combo end. We now replace the SODA tax with the air SOD attacks. So delete that and essentially that's Sod tack three. We simply come over here, we'll drag in AR Soda tack three, and want to set it, set it two off, and we'll connect those nodes, and we're going to do the exact same thing for all the different properties. So this is Soder tack two. So we'll get Air Soder tack two, and we'll drag it in and we'll set it up as a set. We'll get rid of the Soder tack. Because the combos will all work using the exact same logic. So this is Air Sword attack two will be set off. So attack number reset. Then here we are, make sure these are working correctly. So Attack two again, instead, what we want is air Sword attack two. So we shall replace that and then here where there is air soda tack three. Rather Soder tack three, we can remove that. We get Air soda tack three, set it up, and we set it to on since that's what it was. The logic is the exact same. This is us just really saving time by utilizing the exact same logic tree for our air soda tax and for our grounded soda tax. That's essentially it, it's a very good way to save time. Because all you're doing is you're using the exact same logic. Now we are going to make some adjustments to the air soda tax to change up their style, but we'll get into that next. For starters, let's first make sure the soda tacks are comboing into each other properly. Now that this is entirely setup, Okay, let's check the logic ARSODtakT links. Okay, this seems to be doing good. Now that we have the events set up properly here, we'll go back to the animation blueprint, and we want to adjust the notifiers. So we'll go to the notifier of AISDta link. And then what we want is get as hero. And then drag out our as hero. And we want to look for the event air SOD attack to link. And that's the exact code we want to play when that notifier gets called upon, okay? And then let's head over to Air SOD attack three ink, drop in the G as hero, and then we are doing the exact same thing. Air SOD attack three link. That's perfect. So now that is set up to work correctly. Then we'll go to Air Combo end and we'll bring in the as hero. And the function we want to play is air combo and boom, and done and dusted. There we go, and we are done with our basic air combo system. Let's see how it's working in game. So I'm on the ground. My note fires are working correctly. Now if I jump. Hold on. Jump, attack. Okay, the attack hasn't reset correctly. Let's go back and double check on why. We'll start by looking at the hero. Does it detect properly if the player is falling? Yes. So it is setting this up to do the air sdtack normal. Let's start by checking that. Nice. Jump. It's doing the air sdtack and resetting correctly. Ah, nice. Okay. So now that is working correctly, the only d, let's quickly save all. We need to make sure everything is saved so that it is working correctly. Do another test. When I jump, I can do one sword slash. But immediately, notice that there is a problem. The code isn't working correctly because at some point, the player will land back on the ground. So in order to reset that, we need to make it so that when the player is in the air doing his attacks, they stay in an air bound state. Let's do that in the next video. 59. 57 Polishing The Air Combo Logic: Okay. So now that we have our Air Combo code available, the only thing we're seeing is that, you know, the players hitting the ground really quickly. So we want to make a basic chain. What we really want to do is we want to keep the player in air for Air combos. Why? Because it looks kind of cool. Okay. Now, from a gameplay perspective, a simple way to think about it is that when the player is in the air and comboing, we want them. So let's say I as the player move and I jump, I want to fall down normally. But if I as the player attack, I want as the player to stay in air for longer. Now, yes, technically, this could disrupt the game play a bit, but don't worry to counter the fact that you're in air longer. What we'll also do is we're going to slow down the horizontal movement speed so that the player can't just come, like, hit attacks and extend the jump distance. Okay? So Okay? Like, you can see, we can do the combo there. But if I try to do the combo, I'll end up on the ground at some point. Okay? So let's get into the code. So inside of the hero right now, the mela tag when in air is going to lead to setting air solder tacks on and then at the end of the attack length, we check if the player is still attacking. If they are, set the sod attack number back to zero rather if they are not and then do an attack reset and turn off Sodtak one. If they are still pressing, turn on sod Attack two. Then after a minor duration, turn off sod Attack ones variable. Now, what we are going to do is we're going to add in a little bit of sauce. So right when the player starts doing their air soda tacks, we are going to go and get the character movement component, okay? And we're going to drag it in. And then what we want to do is we want to set gravity scale. Okay. Want to set gravity scale, and we want to set it. Let's start off by setting it to zero just to show you what would be happening. Okay. Now that we've set it to zero, let's compile and go back in game. So now when the character jumps, notice that they can do their full air combos without gravity. But that's with it set to zero. Let's set it to something more sensible. Let's set it to something like 0.25. That means once the player is comboing, they get a quarter the gravity. So now, when the player jumps, they get a quarter of the gravity, and they can do their air attack normals. Okay. That's cool. However, notice that there is a bit of a problem when they get back on the ground, if they jump normally, no problem. They have the normal jump that we have set up for them. However, if they do a combo and they come back to the ground, when they jump back, the gravity scale is retained. So let's get back to the hero blueprint, and then we'll copy over the gravity changing nodes and we'll do this. Immediately right after if the player resets and they are not continuing the combo, set the gravity scale back to one. Okay. So if the player has stopped the combo at any time, set the gravity scale to one. Okay. And we'll add that same set of nodes on all of our hold on. This might be the wrong attacks. I think I put this on SOD attack. This is SOD attack Oops. Come down to attack inks air. Want to be in the attack links of air. Let's put it here. So on every reset, we reset gravity back to one, come down here. This is the second reset. We reset gravity back to one. There we go. Then of course on combo ending, we reset gravity back to one. I hope this makes sense and makes logical sense to you. All we are doing is every reset, we reset gravity scale back to one. If the combo is continuing, we let the color floating gravity stick around. Let's see how that looks like now. So let me do a jump. Do. Oh, my God. Oh, sorry. Stop that. I don't want to do any debugs, please, thank you. I'm not in a debugging mode. Let's start from here. So stop the play. Okay, jump. Okay. See? So I come, I slash. Once I'm done with a slash, my gravity is set back to normal. Don I slash, my gravity is reset back to normal. D with a slash, my gravity is reset back to normal. Jump, slash, gravity is reset back to normal. Jump, slash and slash the second time. Reset. About the triple slash, three slashes, and then gravity reset, and we don't need to readjust the gravity each and every single time. Now, let's go back in, make sure that this is working correctly. Let me see. This reset resets to one, reset to one, resets to one, reset to one. Not bad. But I need to also double check something. When I open the character movement component, let me look for gravity scale. So gravity scale, normally, for a normal jump is set to two. So let me make an adjustment so that the jump does not change at all. Back to the event graph. This time when it's resetting Sorry, when it's resetting, let's reset its gravity scale to two to keep it the same. Now, of course, the smart way is to have a variable with, let's say, base gravity and set it up here. But that's for you to add on. Let's do that again. So this time, I jump, I slash. Gravity set back to two. I jump, I slash. We set gravity to two. Jump, I do all three slashes. I'm back on the ground. I do two slashes. Oh, I did three. Do two slashes. Back on the ground. I jump, I slash. I'm back on the ground. I jump, I slash, I'm reset. I jump, I slash, it resets. I jump, I slash, it resets, okay? I jump, I do the triple slash, I let go, it resets. So that is essentially how we keep the player in the air when they are doing air combos. Okay? Now, we'll go back over here, and we want to make one last additional change. Let's quickly double check gravity scale two. Here, it's set to two. Yeah, it's set to two. Good. Here, the gravity scale gets set to 0.25. I think let me drop that down to 0.15. I think 15 els better. Of course, you can adjust this to whatever value you feel yields better. Although there, it leads to a higher jam. Ooh. Okay. So now that we notice it's leading to a higher jump, what we will do is we're going to come over here. We are going to get let's see, we are going to set velocity. Let's see, set velocity. Okay. We are going to set the velocity. We'll get the character movement component again, and we're going to get velocity. Get the velocity. Let's see where is get velocity. Okay, want to get velocity. Let's split these up. Okay. Split them up. Also this, let's split them up. And we want the X velocity to be the same, W the Y velocity to be the same, but we want the velocity on Z to be exactly zero. Now, what does that mean? Oh, target, W the character component, right? Let's compile. Now, this is what we want, right? We went when the player is floating in air, let's see. This is only a set for a fast attack. They stop gaining vertical velocity. You see what we did there? We set it up so that the player doesn't gain increased vertical velocity. And that fast attack, good. But they can complete their three aerial attacks. Nice, not too bad, not too bad at all. But now that I've seen it, I think this jump is kind of weak. It's not high enough, you know. Okay. But now that we've done that, I think now let me drop the gravity scale. It's funny, we keep making all these adjustments. Let's now drop the gravity scale to, uh let's make it 0.05, okay? I think 0.05 is a reasonable gravity scale because we've significantly cut down the jump height. So we come. Nice. So the player can complete Oh, I'm still zoomed in. Apologies. The player can still complete their triple sword slashes, and then they're back on the ground. And that is the quick overview of how to have a nice aero combo attack system. And the nice thing is, the player retains the ability to change direction even when they're attacking and slashing while in the air. That's a cool thing. Okay? That's pretty much it. Okay, so let's see this is a normal jump. This is an attacking jump. The attacking jump moves faster. So what we will do will come back to the hero once again. So now that we are back in the character movement, we are back inside of rather over main character again. We want to get another component from our character because there is another burgle feature. If I do a basic jump, notice, when I jump, I can jump about 1.5 squares. But if I jump and I start attacking, I can jump about three, which means that we are making air attacks into jump movement tech, which we don't want. I mean, if you want it, you can have it in your game. But I'm going to show you how to make sure that air attacking doesn't change your jumps because later on we're going to go into how to develop platforming that is engaging and fun. So we shall drag out the character movement component. And we want to look for air controls, want to set air control. It is that thing called air controls, want to set air control. We'll put it here. And what we are going to do is we're going to set air control to let's say something like 0.3. Because at best, the way that we set it up when we're setting up the character movement, air control is higher. Let's quickly have a look at its the details. I want, open the details. Okay, so my details aren't viewing, so I'll go to view, and here we are. I'll click on details, and it will bring back up that details window. Now, I want to look for air control. Under the character movement component. So you can see the best air control is set to one, okay? So what we are doing by setting air control to 0.3, is we are reducing the players ability to control diagonal velocity when they have jumped and they're tacking. So they are here. Okay, so air control has been reduced, but although air control has been reduced, the player can still do that. No, this might not be the right solution. Let me remove the change to air control. So changing the air control might not do exactly what would like from the character feel. So instead, let's quickly change the actual work speed. Mm. Okay. So here we have the walk speed variable. Now, let's suggest just that variable. Let's see, we have actually set walk speed. So here we are. Let's change the max walk speed. Now, it starts at 600. Let's suggest it down to 300 and see if that will make the right amount of difference or making sure that the player is not able to increase their jump distance. Let's see. No, not enough. Let's drop it down to 150. That's the character movement. Okay, so it slowed down. Okay? Let's drop it down to 50. Okay? Really drop it down so we can see the difference in impact it's having. No, not good enough. Mm. Going to need to make another adjustment. So if changing the work speed isn't working for this use case, let's see. I think what we could change is the air friction. I need to change the friction while in air. They actually a lot of different ways to do this. Each one with its own set of problems that it itself will cause. Let's return to this later. Now, fundamentally, now that we are done with this, what we do have is the ability to set up a nice three hit animation and carry out those hits there, and also let's say do a quick jump in. We can jump in and do aerial attacks. We have aerial attacks. Then we have grounded attacks. We have aerial attacks. Although the aerial attacks are slow, something which we can remedy really quickly. Let's see. Let me go into art. And select the air sod attack. This is set to four frames per second. Let me update that to eight frames per second to make it faster. And then the second, let's see, one, two, three. Okay, that's set to four frames per second. Let me set that up to six frames per second to make it faster. And the last one is set up at what you want? Actually, what I'm going to do, I'm going to change this one up let me see. What's the third animation. Let me delete that. I'm just going to set this up at four frames per second. So that's going to be the last sword tack. No, keep it simple. So with that, just those couple of changes, let's see how they looked. So these are the grounded sword tacks. And then when I jump, much faster. One, two, three. Okay, then they're done. Good. One, two, three, one, two, three. Okay. Then when you jump, one, two, three. I'm actually kind of liking being able to control the movement when I'm in air like that. It's kind of cool. Anyway, that's it. For now, we have our Baseline combo system setup. Now that we have the combo system set up in the next set of videos, we're going to talk briefly through some stuff we can do with the AI because hitting a block is fun, but hitting an actual creature that can attack you and end your life is way more fun. Let's get into that. 60. 58 Detecting the player in range: Now that we have some combat available for our player, let's give the player something to fight, which is going to be our first melee enemy. Now, the first thing that we're going to do is set up and create the baseline melee enemy blueprint, okay? So in order to do that, let's go into characters. Now notice there are some folders here. We have our attack, damage object, and then the player. So let's create a new folder, okay, we'll call it melee enemy. We'll keep it simple, okay? That's what it's going to be called. Now, this is the melee enemy. And if we go, we're going to create the melee enemy as a child class of the attack dummy. So get the attack dummy. It's going to get it. And then up at the top, there's the option to create a child blueprint class. And we are going to call that child blueprint class me enemy. Quickly cut that we'll cut that, go back into the melee enemy, and then quickly paste the content here. Hold up, actually, let me come back. Where is copy? I want to actually copy this in its entirety. Real engine. Where is the simple copy function? Okay, I'm not seeing copy. I'm just going to drag it and drop it into melenem. It says, Okay, move here. Yes, that is what I want to do. Very interesting editor. Anyway, now that we are inside of the melee enemy, we want to add in a couple of other folders. So we'll create one folder that we are going to call art. We'll create another folder called animation where we'll put our animations in, and we'll create another folder called audio. Okay. So we have art audio and animation, and we will add in more folders based off what is needed. But for now, these three will be enough. Now, while it's been nice having this dummy over here, let's set the dummy aside. Let me move it away. Come on, Cameoa. F over here. Cool. Okay. Now, quickly, let's drop the melee enemy into the world as make sure that it is zero on ZY axis. Okay. So this is our first actual enemy in the game. This is it right now. It's here. Now, let's open up the blueprint and see what's inside. So on opening, let me add it here, okay? So opening it up, notice that there are a couple of things. There's a basic capsule collision. There's a basic cube over here. There's a basic character mesh. There's the widget, that is the health bar over there, and there is a character movement component that is good. The first thing we're going to do is we're going to come in. We're going to select the cube, and we are going to simply for now, let's leave it in for now as we just do one thing. But we are going to add another component here. Now, the first thing that the AI needs to do before it does anything else is it needs to be able to detect the player and know when the player is in a certain range of it. So we're going to go to the components, and we want to add a component called pawn sensing. That is it. So this is it, the pawn sensing. Let me rename it to player detection. That is going to be the name I am going to use for it because it is meant for player detection. And then when you zoom out, notice that's a pretty crazy radius, right? It's a massive radius. So we want to drop that radius down. Now, on the details panel, we can reduce the site radius. Right now it's on 5,000. Let me drop it down to 1,000 units. Okay. I think 1,000 units is going to be good. And then hearing threshold, we can make that zero so that it is not able to hear the player and LOS hearing threshold. We will turn that to zero. So all it has is a sight radius. Now, keep in mind this is actually a sphere. It looks like it's a straight line, but it's not. It's a full sphere around the entire character, right? Now, let's do a quick check and make sure that the point sensing component, which I've called clear detection is working. So we'll go into the event graph. Let me come down here and we are going to create. We're going to let me actually drag it in drag in player detection. So clear detection is now here. And we want to add in a simple event to detect the player so go back to clear detection. We'll add an event. We could use on here noise, but that's not usable right now. I want to add on CPN, which is going to lead to this being added. So on CPO, which is basically for the player detection, what do we want to do? We want to simply print out a simple string, and we want to call it player is visible. That's it. Once the player is within detectable range, it simply says, Hey, player is visible. That's all we need to get started. Okay? So let's go back into the world. I press play. Okay, so right now, it's not detecting the player. So we'll come back into the blueprint. So I'm looking at the blueprint on CPN. It should be detecting the player regardless. Let's come back. So when I jump over to this side, there it is. So it's now stating that the player is visible. If I come back, the player is no longer visible. I come back this side, the player is visible. That's cool. Now we know that it is able to see the player as long as they are on the right side of their sight range. Now, let's expand their sight so that instead of them looking to the right side, it's able to see the player on both the left and right sides. And to increase the angle of the vision range, notice over here, peripheral vision angle on the player detection. So let's have a look. We can adjust that number up or down. I'm going to increase that number to 179 degrees, not entirely 180 but 179. I've found that that tends to work really well in most use cases. So now, notice the player is visible. I walk out of the range. The player is no longer visible. The player is visible. Let me walk out. The player is no longer visible. That's good. So our basic AI is now able to simply detect the player. Next, let's figure out how to make it so that when the player is visible, the AI moves towards the player's location. 61. 59 Make AI Move towards the player: Now that we have the player being detected, so right now I'm out of visible range, and now I'm back in visible range. The next thing we want is to make sure that the melee enemy moves towards the player anytime that the player is visible. Now, in order to do that, we need to first of all, create navigation, and we'll do that by setting up a nerve mesh bounds. Now, what is that? Let me quickly show you, right? For starters, let's say that we have this object over here, right? That's our AI. If we zoom out and then come into the top left corner, and we want to add something and you simply add nerve mesh bounds in every nerve mesh bounds volume. Let's add that to the game world. Zooming back out. This here is going to create what is known as a nerve mesh. Now, this box is a bit small, so I have selected it, and then I'm going to increase it scale to 50 on all units, okay? 50 because I want it to be big. Much better. Now this is properly big. So you see this green area. This green area over here shows you the nerve mesh. In other words, which areas is the AI able to navigate to. Now you'll notice our box here, rather our melee enemy is able to move along that green area. Now, let me move here. You'll notice this area around these objects, the AI is told to not be able to navigate around, and that is good. Now, just in case you're seeing any spaces under here, what you're going to need to do is check, double click on not the melee enemy. Let's go to the attack dummy. Make sure that the cube its collision is set to simply overlap all dynamic. It should not be blocking because any block collision is going to cause there to be a space where the nerve mesh isn't being seen. Now, if I click on the nerve box again, and I press P, it will stop showing the nerve mesh. I press P again, it is now showing you the nerve mesh. Now that that nerve mesh is set up, we are simply going to go to build and we want to look for build paths. What that does is it's going to rebuild the navigation, just a simple double check. And what you can do is, let's say we want to get this nerve mesh bounds, right, and want to move it a bit more to the left. It's going to create a nerve mesh. Notice this recast nerve mesh default. You can delete that, go over into build and rebuild paths, and it will recreate the nerve mesh for you. Now, I know I've said nerve mesh a lot, but essentially, that's just the workable area which the AI can use. Now that we have the walkable area the AI can use set up, let's now go and make sure that it understands to move towards the player character. Okay. Now I'm going to demonstrate to you with clarity what we are trying to achieve. So you move towards the enemy and notice it chases you. Then when I jump over, as long as I get in visible range, it will continue to attempt to chase the player to the player's location. Okay, come back. Okay, come back. Hey, come back, boom. Okay? Of course, it's trying to get to the player's exact location. Now, this is the simple blueprint code. So the first thing you're going to do is go back to OSPn the player detection. And then after the print string, you're going to cast to hero. Basically, you drag this pinout and you want to cast to whatever the name of the player blueprint. Once that's done, from there, you're going to as hero, you want to get the actor location. That's going to bring up this node and then let's quickly split it up so that we have access to the X, Y, and Z value. Of course, we do not need the Z value. It is the X and Y value that are most important. Then after that, we'll use a simple move to location node. You can access that by simply typing simple move to location. And with that, you'll drag out from Controller and you want to get AI controller, you'll be able to get the get AI controller, and from the AI Controller, make sure you give up a reference to self. This basically tells the AI to take up basically, it says, Hey, AI once you detect the player. Print out the string player is visible, cast to the hero, which should be the thing that we are seeing, that's the pawn. As the pawn, get its current location and then simply move to its location by accessing the AI controller within yourself. And that's how you fundamentally get some let me zoom back out. That's how you get a simple AI move to where the AI just follows the player around, and it keeps attempting to follow the player as long as the player is in range. Now that we have that, we can move on and let's set up some general basic limitations so that the AI doesn't try to move fully into the player because it's trying to get to its exact location, which is not what we want, want it to move to a certain range. Okay. And then we shall move on to giving the AI an attack which damages the player. 62. 60 Adjusting AI Movement Towards the player: Now, if you go back to the folders once again and inside of the folders, there should be under the player, you'll notice we created a specific folder for the damage at boxes for the player. We are going to do a very similar thing for the melee enemy. Inside of that, we're going to create a new folder, and that folder is going to be damage at boxes. Okay. Let me just double check it box, not at boxes. Okay, damage hat box. Okay. I want to keep the naming the same so that everything is similar between the two. Okay, now that we are done with having that available, let's now make some adjustments so that the melee enemy instead of reaching up to the player's exact location, what it should do is it should get to the players. Basically, it shouldn't try to go inside of the player, okay? It's trying to go inside the player. We don't want that. We want it to stop just outside the player. So we want it to always stop a little bit of space before the player. Now, the way that we are going to do that is by using a different node, and that node is called get distance two. So let's look for it. Get distance two. There we are. It gives us the distance to a player character, okay? So we shall use this node. It's the get distance to node. So let's first move all of these nodes that are for moving the actor, move it ahead a bit. So what we want to do is after the simple move tool, we want to have a basic distance check to the player character. And after that distance check, we want to stop all active movement. So the way that we are going to do that is, first of all, let's quickly space these out a bit more because we need to do a couple of checks. Okay. So we have get distance too, and the other actor is going to be that hero that it is detecting. Okay? That's going to be the other actor. And also, let me move this even further to the left because it's going to we need a bit more space, okay? So we are getting the distance to the hero and then it's going to try to return a value. And then what we want to do is from the return value, we'll drag this out. We want to look for less than equal to. So we want to look for less or equal to. Okay. And after that less or equal to, let's set up an amount. Let's say the amount is 150 units. And after that, we are going to set up a simple branch and after that branch, if that branch is, let's see. So basically, if the distance is less than or equal to 150 units, what we want is so that means that the player is within that distance, right? It's within 150 units. We want to basically stop doing any movement which means that if the distance is not if the distance is not less than 150 units, which is going to be false, we'll drag that out and we'll move it to the simple move too. So it will move if the distance is less than or rather, if it's not less than or equal to 150 units, however, if it is true, we'll drag this out and want to print a simple string, and we want the color of the string to be red. Click, okay? And we'll call it in attack range because that's basically the attack range. We've set it up so that 150 is going to be like anytime the player is within 150 units, it's now going to be in attack range, so it will be ready to start attacking the player. Now, with all of this set up correctly, let's drag the cast to hero to here. So let's go through the code. On player detection cast to hero, it's going to get the distance to the hero and check if it's less than equal to 150. If the distance is not less than equal to 150, simply try to move to the character's location. If it is less than equal to 150, just print out that hey you're in attack range. Okay, so with just that, let's quickly do a compile and hit play and do a quick check. U, says in attack range. U. But distance of 150 seems to be too small. Let's increase that to 500. Okay. Now at a distance of 500 that we are using to check. Hmm. Now we have a minor problem. So when I move, it attempt, okay? No, the check is not working correctly. Let's see. Okay, now it's stopping at a good correct range. Now it's stopping at the correct range. Now it's stopping at the correct range. Now it's not working correctly. Now it's not working correctly. Now it is not working correctly. This is going to need some adjustments. Try that again. No, it is being unreliable. Now let's do some basic troubleshooting. How are we doing the troubleshooting? Come over here and let's hit Play. I want to see what's going on. Hey, that's going, correct? Okay. So the one problem is that the simple move too is still working. It seems the code is working correctly because let me try and demonstrate this. When I come in to the correct range, Hold on. Wait a second. It seems to be moving and it's actually doing the correct thing of switching the flow by turning off the simple move too. But what's missing is this move to runs once and it's still running. What we want to do is right after it detects itself being within the attack range, we want to stop let's see. Here we are. We want to stop active movement. Okay? So let's immediately click on that. So what it has done is rather, it's opened up the character movement component and it's stopping active movement. Now with that setup, let's quickly test this out again. So Perfect. I move a bit. Yes, it is now working correctly. Now, let's reduce that from 500 units to 150 units. Do a quick compile. Come back here. Okay, so it's now stopping correctly. A? Nope, but it's now not working correctly. Okay, hold on. Let me increase the units so that I'll have a clearer picture. Let me increase to 300 units. Okay? Okay, it's stopping. It's stopping there. It's stopping there. It's stopping there. Stops there. Okay. So it is currently not working reliably. There, it's stopping at the correct distance. Here, it stops there. Okay. So stopping the movement is helping solve it in some scenarios, but it's not helping it in others. So what we are going to need to do is make another change. So now that we are here, we've set it up to stop active movement. But before we do that, what we also need to do is, let's first reorganize this a bit, make sure it's really cleaned up. Let me put this get distance and branch together here so that I can clearly see what is going on. This will be here, good. I like this organization. And then if it is true, it branches up to stop active movement. Mm hm. Okay. But if it is stopping the movement, why is it stopping at different distances? That comes down to velocity. That comes down to velocity. So how do we alter velocity? That's actually pretty simple. We're using stop active movement, drag this out. Let's see. Here we are I've added in a stop movement immediately to prevent that from moving forward any further after we've done that. So I'm using both stop movement immediately and stop active movement. Let's test this out and see if this is going to give the correct result. Okay. Okay. No. No. Ah. I see. Okay. This is a good enough start, but there are a couple of other adjustments we're going to need to make to have the AI follow the character and stop at a certain location we working correctly. And I think an important part of that is going to be adjusting the psensing component. Let's do that in the next video. 63. 61 Adjusting Sensing Component and some theory crafting around timing: So now that we are in a place where we can move towards our melee enemy. And sometimes it stops at the right position. Sometimes it stops too late, and, you know, but its movement is now working. I need to come out of just the code and nodes into a bit of a higher level way of thinking. Every single game in the entire world runs off a timer. This timer is called the tech. Now, let me bring this out. Let me print a string. And I want it to print out the Delta seconds every time it takes. So let's see what this looks like. Where is the level of this side? No, I want it to left. Okay. So notice it's ticking. Now, right now, you're seeing 0.008 as the take timer. Now, what that means, let's open up a calculator, right? Now, if we get one and we divide it by 0.0 083, we get 120. Okay. That means that each take is being fired off around every 120 frames, and we can verify that, right? Coming over here coming out, if we ask it to show FPS, right? Notice what the FPS is about 120 frames. Everything we do is timer based. Now let me press play. So you'll notice it's going to show the time between every frames, which is now 0.008 3 seconds. So the variation in where the opponent stops comes down to timing. Now, let me go back and delete this string that's showing up on Te go away. Now I've removed that. If we go and we check on the player detection, go into the details panel. Let me open this up. And we'll see something here. Hold on, let's see, component take, that's good. Okay. So I've clicked on the player detection on sensing component. Now, let's come here. Notice that right now its tick interval is set to 0.0. What that means is that it's going to be set to the same t interval as the frame rate. It's not actually zero, but it's set to that. And now, what we want is we can adjust this and we can increase it or decrease it. That's not the most important thing. Well, let's see. Here we are sensing interval. Now, sensing interval basically means the amount of time it takes between when the game checks that component. So now it's set to 0.5. So what we can do is we can set the sensing interval to five. That's five whole seconds. That's a lot, okay? So compile this. So that means essentially, it's going to keep doing that now, one, two, three, four, five. Notice it's only doing that check every 5 seconds. One, two, three, four, five, now it moves. Alternatively, we can make an adjustment to that sensing interval to make it sense much faster. We'll make it 0.1. Remember, it started at 0.5, okay? Now let's come in here. So notice that now at 0.1, it is following and adjusting at the correct distance. The reason why it's doing that is because now all of a sudden, it is double checking at every 0.1 seconds that enemy is running the math and double checking the distance to the player. So let me open up the event graph once again. I'm zooming out a bit, but you can, okay, let me zoom in on printing the string, casting and branching out. So let's quickly hit Play. I want you to see how fast it's doing it, right? It's completely changed. Pass, it's putting things up on screen. Now, the reason why I wanted to share that is because we're going to be doing a lot of work using different point sensing systems. To really make good AI, we're going to need to do a lot of work with them to detect distance and to make different decisions based off what the character's distance is. If the character is far off through a ranged attack, if they are near, you can set the AI to run away. That's just a basic overall concept. And now that we have increase the sensing interval to 0.1 seconds. Now the code is working exactly as we intend from a human perspective. Now, now that we have this setup and we have it set up to basically attack in range or rather when is in attack range. Next, let's move on from the code and add in some animation to our melee enemy, and then we'll get into adding in an attack and talk about how to make decisions around attack systems. 64. 62 Adding A Visible Sprite To The Melee Enemy: Now, the next thing we want to do is really change up our melee enemy so that we can actually see an enemy on screen. Let me move it closer to the player so that we'll be able to quickly see the changes. We want this to actually be an enemy, not just a box with a health bar. So to do so, we'll go into the melee Enemy blueprint. We will select the cube, and we will go into its details, and we want to look for visible rendering and let's make it invisible. So now we shouldn't be seeing any, we're just seeing a health bar. That's cool. But we're going to make another change. We're going to select the widget, go into details. And also, we're just going to make it invisible. So that you know, now we just have the empty enemy. With the empty enemy there, let's go in, and we now want to start adding in some sprites in preparation for the sprites. We will add a component, and it is going to be a flip book. Okay? Let's just add in a paper flipbook as a component, and this is going to be where we're putting in all of our sprites. Now, added in with this video is also some sprite assets which we'll be using to create the enemy. You can download them and then move forward. Now, adding in the sprites is going to be quite simple. First, we'll select all the images that we have imported and make sure that those have paper two D texture settings applied. Next thing that we want is we'll select skeleton io, and we want to extract sprites from it. After hitting extract sprites, notice that NRL has already automatically segmented out the different sprites and we simply hit extract. And there we go. So now we have all these skeleton, idle sprites unpacked. So we'll select them and then go over to create Flip Book, which is over there and create a flipbook. And it is called skeleton Idol One. We'll simply switch it to me NMI, underscore idle. Okay, now let's have a look at melee enemy idle. So that's the animation. Basically, the skeleton is standing in one place. It's a very good animation, and this is what we'll use for keeping the enemy idle. Now that we have that in, we'll simply close this. We'll select the paper flip book that we have set up inside of our melee enemy. And we are going to change the sauce flip book over to let's go down. We want melee enemy idle. Okay. Now that we've set up the melee enemy idle over there, let's compile. And when we hit clay, look, there's that tiny little melee enemy over there. Very cute. Now that's working. We've shown that it's showing up properly. Let's adjust the scaling to fit and make more logical sense. I'm going to lock the scaling, scale it on the Y. That's cool. Let me adjust its positioning to be a bit higher. Move it forward a bit, and then down. So its current scaling is 4.4. Let me make that 4.5. That's the scaling. Compile. Let me see how it looks. That's good. Next, go back, select the flip book, look for shadow, and we want to set it up to cast shadows because right now it's not casting any shadows. Going to select cast shadow, compile. And now our little two D enemy is there casting a nice little shadow. How cool. And look, it's moving correctly, left and right, moving left, moving right. This is excellent. Now that we have our little skeleton there doing little skeleton things, I think let's make it a bit larger, you know, a bit more intimidating. Let's look at it scale. Let me increase the scale to six. Increase its vertical ld. I need to look at the ground, make sure it's just touching the ground. Let me increase the scale to seven. That's good. Make sure it's just about touching the bottom. Let me bring it up just a touch. Compile. Let's see what we have here. This is looking much better. Look at that skeleton. Okay? The only adjustment I'll make is drop it down just a smidgen. Let's see right now, 30. 20? No, I want its Z location to be something like 28. No, drop it down 27. That should fit about right. Adjust until you're done with liking it, okay? Adjust to your liking. Okay. Adjust to your liking. This is good, and I like it. Now that we are done with that, let's make one last adjustment. Um, no, let's leave it at that. So now we have a basic skeleton enemy that is able to follow the player around. Next, we're going to work on attaching it, setting it up in paper Zed and giving it an actual running animation so that it will pursue the player. Let's go. 65. 63 Adding in Walking Animations in PaperZD: Okay, now that we have the baseline art, let's spice it up and add in that more dynamic functionality. So the first thing we're going to do, it's very similar setup to what was done with the player. We want to find the paper Z D animation component. And with that animation component setup, just call it paper Z animation. And then we'll decide on, okay, animation instance, we'll deal with this later, which render component well. We want to use the paper flip book as our rendering component, and now it's simply looking for an animation instance class. So we're going to create that. So inside of the melee enemy folder, go into animation, and we're going to create, let's see, we want an animation instance. Let's see what is papers a. Here you are papers a day. We want to start off by creating a animation sauce, and we'll call it melee em animation sauce. Okay. And after that, we've saved that. Next, we want to create a animation blueprint. Okay. And it's here asking, Okay, what's going to be the parent animation sauce? We want melee NEM animation sauce to be its parent. And we will call it melee enemy Animation BP. We'll keep the naming clean. Now that we have set up those two, we'll start by going into the animation source. We want to add a new animation sequence. We will call this sequence idle. Okay. As you can see, we are calling it idle. Now selecting the Idle animation. We want first of all, I don't know why that opened up there. We want a full window. Next, which animation data we want male my idle. So won't use the melee enemy id, and this is the animation. It is playing clean. It's playing clean. This is good. Now that we have that done, we'll go back, make sure everything is saved. So this is what is in the animation sauce. Then we shall go to the melee Enemy animation Blueprint. We have access to the melee enemy as a variable. We're going to make sure that from inside the event graph of the M Enemy animation Blueprint, want to cast to Mel enemy. And then as far as object, we want to get the owning actor. And the reason we're getting the owning actor is because you have multiple melee enemies and each one animation code should run separately, and then we simply want to promote to variable and the variable is melee enemy. That's all we need to get set up. Okay. Now with all of that setup, let's move on to the animation graph. So inside of the animation graph, the first thing that we want to do is to create a brand new state machine. So let's look for state machine, add new, and we're simply going to call this mele Enemy going to keep it really simple. That's going to be our new state. Bring this over here, we'll go into it, and we'll go straight from out, drag that out. We want to add a new animation state, and we shall simply call this idle. And double click on Idle. And we really want to simply look for play idle, which is the animation, the only one that we have. So far, connect that in, come out, Control and, of course, to save and then compile. Now, though of this compiled and ready, we essentially have our paper Z fully set up. We'll go back to the animation graph. So right now, immediately it starts, it goes directly to idle. Next, let's move on and add in the movement animation or the running animation. Now, adding the running animation is basic. We'll simply first start, we're going to go back, go back into the art. Oh, not of the character. We want the melee enemy art. And inside of the art, notice there is m. Let's see. We have W here. There is skeleton walk. Okay. So we shall simply select the skeleton work. We want to extract sprites. They're automatically cut. And then the walking sprite will simply select them and create flipbook and we'll call the flipbook melee underscore walk. Okay. So this is the melee enemy work animation. It's quite a nice little work, that the enemy is doing. Now that we have that work animation, we are simply going to go into the melee enemy animation source. We will add a new animation sequence. We will call it work. Double click on it, and same thing, we want to look for work in the animation sequence here. So now we have that simple working animation added in. With that added in, we'll go back to the Mele Animation Blueprint. We'll drag this out and we'll create a new animation state. We shall name the state W. Inside of the work state, we want to play work. Or the working animation. Next, we want to connect the link from work back to idle. And once we go in, we'll simply get the ASM enemy. Then we want to get velocity. Okay, we want to get velocity. Here it is this component of get velocity, split it up and we want let's do a quick double check once again. It's X velocity that we're looking for, and we want to see something. So we want to see, is it equal to, and we mean not equal to. So we are using the not equal to function, which is this function. And to go from idle to work, which is the rule that we are setting up right now, once the velocity on the X axis is greater than zero, it can begin to work, but then going from walking back to exactly equal to. In other words, exactly equal to zero. It should transition into a working. This was my bad. Here, go into the animation instance class and select mele Enemy Animation blueprint. Save, compile, and now let's see. Okay, you can see, there's that walk and swagger. Look at it chasing the enemy. Once it reaches, it stops. So now we have our enemy able to see the player, work towards it, and stop. Nice. So we have that set up correctly. We have our me enemy baseline working animation set up correctly. And now we can get into adding in an attack to the melee enemy. Let's move forward. 66. 64 Adding Melee Enemy Attack Sprite: Now that we have our enemy character that can swag and move towards the enemy player once the player becomes visible. The next thing that we really want to do is we want to do a basic how do we call it attack so that the enemy can do damage to the player. And as we build in the attack, we're going to make other adjustments to the movement system to make it much better at recognizing the player's position and adjusting to move towards the player. So what we are going to do is come out here. We're going to start by selecting the skeleton attack, and after making sure that it has the paper two D settings, we're going to extract sprites. And it seems that this time, Unreal Engine is struggling to suss out what the dimensions of the sprites are. So currently, the sprite extraction is set to auto. Going to change that because auto is not enough. We're going to set it up to grid. Now as grid, we need to determine the cell width and cell height. Now, this is an easy way to do it. Now this is going to work for this specific image. For starters, let me zoom in a bit. We know that the attack has one, two, three, four. Okay, five, six, seven, eight, nine, ten, 11, 12, 13, 14, 15, 16, 17, 18 frames, okay? So there are 18 frames here. So in order to suss these out at 18, we know that right now, each cell width is set to 774. Now, we'll do some basic math and calculation. Of course, when you make the sprites yourself, you don't need to do these calculations. But if you're using assets, you will sometimes need to do it. So we have 774/18, which is 43. So let's change the width to 43. And now we have cleanly cut sprites. Okay. Just with that. Now with that, we'll come over to the extract and extract. And without wasting any time, we'll create a flipbook, and we are going to call this mele EM let's see melee enemy underscore attack. Okay, that should be perfect. Now, with that setup, okay, we have our melee enemy attack. Let's now go back into the melee enemy folder. Want to go into animation, and let's open up the animation sauce and the animation Blueprint once again. Okay, Animation sauce, open the animation Blueprint. Now, inside the animation source, we want to add a new animation, and we'll simply call it attack. We'll keep it simple. Now, attack, we shall chew the correct animation data, and we'll look for me enemy attack. There it is. That's the basic Me enemy attack animation. So idle. Walk attack. That's pretty cool. Okay, let me take this phone call. And now we have added in that attack animation. The next thing we are going to do is we are going to open up back to me enemy, open up the melee Enemy blueprint class. Now, we are going to come back, reorganize the logic and think about when we want the enemy to attack the player and make sure that the nodes here let the player be attacked in the right spacing, and we are also going to adjust the movement of the enemy so that the enemy moves much more slowly so that the player can run away. Let's do that. 67. 65 Melee Enemy AI Overview And Code Comments: All right. As we're going deeper into the AI, you've set up the movement, it's able to follow the play around. Let's go back to thinking about things from the first principles. DCAA, design code at Audio. Right now, we started off with some code just to give you a feel of creating and setting up the AI. Functionally, we are going to be using detection systems, which is the pan sensing and movement systems. Those two are really what governs how an AI feels. So let's go back to thinking about design, okay? So this is a very simplified overview of what we're going to be doing with the AI. This is a really simple melee NM AI. The first thing it does is it patrols an area. Okay. When the player character enters an area, the AI seem to be patrolling an area. Next, it moves towards the detected player and performs an attack. And the last thing it needs to do is, hey, when its health drops below zero, it dies immediately, okay? It just dies, which is very good. So this is what we are going to do to set up for the melee enemy. It needs to patrol an area. It needs to move towards a detected player and attack them. And then once its health drops to zero, it dies away. Let's move on with these basic principles in mind. Now, we are back into real engine, and we are inside of the blueprint of our simple melee enemy. Now, let's go in and have a quick look at all of the different nodes. So the first thing is, we have a basic pawn, which is able to detect the player. Let's quickly. This is player detection. So within that radius around the enemy, it detects the player. That's good. Now, let's quickly put in a basic comment. Oh, my goodness. No, no, no, press C. Just pressing C for the comments. So this is a simple comment, and we'll call this detect the player. So all it does here within that code is to detect the player. That's all it does. It's not doing anything else. As usual, I love black backgrounds with white text. I find them very easy to read and organize nodes into. So this right here is the player detection. Now there is currently a string which detects when the player is visible. Okay? That's a string that fires off after that's detected. Let me first line these up, straighten all connections here, good. And then it casts and checks if it's the hero that is good. And then come over here. Hey, bring this over here. Start with this. It basically detects the player and it casts and like, Hey, okay, this is the player. That's cool. This is the baseline of the AI. It's able to detect the player, and then up to a certain distance, it moves towards the player. Let's reorganize the movement. Bring this all down here, bring this down over here. And this branch, I want to leave it outside of that because I want to put that under a different comment, make sure these are all properly aligned. Okay. Come over here. This is the simple move to location that we used in order to move the AI, move the actor location of the player, and then the controller move this over here. So that we can line up the controller on the left side, since it is the AI controller that will be used in order to move itself, okay? So fundamentally, we detect the player. And once we know that it is the player that is the hero blueprint, that is what we are going to use to carry out all these other actions. Okay, good. Next, it does a basic condition check to see if the distance to the player is 300 units. If the distance is not, it will move towards the player. If the distance is, it will instead stop all movement, and it needs to actually carry out the attack or rather right now we detect that it is in attack range. We don't need that text anymore. Let's bring this over here. Now, we need to make a comment here. So we'll get this copy and paste it over here, drag it in. We shall call this attack the player when in range. That's all this does. It will attack the player when the player is in range. So we haven't yet added in the code for the attack, but we are going to get into that. So this is set up to attack the player when in range, and let's copy and paste that comment for organization's sake. And this is going to be move to attack range. Of detected player. Ah, no, no, no need for capital L. Make that a small L. Good. So this will move to the attack range of the detected player. Let's drag this right over here. Move it up a bit. Let's move this up. Move this a bit more to the right. This is good. So essentially, we are detecting the player when they are in detectable range. After that is done, we do a basic check of the attack range. If the player is not yet in attacking range, it moves towards the player to try to get in range. However, if the player is in attack range, we start by stopping all active movement, and then we are going to actually attack the player. Now, now that this is really set up in general, let's go in and actually add in the attack that the AI is going to perform towards the 68. 66 Adding Damage Hitbox For Melee Enemy Attack: All right. So now that we have our code reasonably organized, let's go in and start adding in the attack for the AI. Now, the first thing we want to do is, we know that we are going to be spawning in our head box. So when we come back and look at the animation from checking the animation source, and keep in mind this varies a lot based of what kind of animation you want. Now, you'll notice that there is an arc of damage that it does. Look at that arc. Let's go down frame by frame. Oh, snap, open this up a bit. Let's go back. Look at that nice sweeping arc of damage. Look at that. So around frame seven, we have that big sweeping arc of damage. That's when we want to do damage to the player. And you can see the nice big size of that arch eight bucks, okay? Now, now that we have that scene, right, let's go back to our melee enemy, and we need to decide on the location of where this at box is going to spawn. So we'll quickly go and select the paper flip book, okay. And then inside of that, we want to add a simple collision, okay? And we'll use a simple box collision. Now, this box is here, it's too big. Let's make it smaller. To make it smaller, we'll reduce its scale to something like 0.1, beautiful, and then we're going to move we're going to move its position right ahead. Now that we have that, I think let me look at that animation once again. Oh, look at that. It's about two lengths in front, but we want to have a huge hat box area for that. So I think I'll move it to around here. Let's go back to the enemy. So around here, okay? This is a good position for it. And now that we've let's see, that's where it is. And then for the box, let's call this Ax swing. Okay, we'll call it x swing, right? Location. Okay. We'll call it the x swing location. Now that we have that location setup, the next thing that we're going to do is, let's add in a nice collision for it. A nice, beautiful, big box that's going to be the big collision that we have. So in order to do that, let's quickly control spacebar. So under our hero character, notice we had a folder for damaged hit box. Now we're going to go into the melee enemy. And the melee enemy also has a damaged at box folder. So inside of that folder, we want to create a new blueprint class. Going to be a basic blueprint actor, and we want to call this x swing at box. Okay. Now we'll double click on the x swing hat box. And here it is. We have a little x swing. So this is our basic X swing. Now we need to add in an actual proper at box. So we're going to add we're going to add a sphere because the X swing at box is going to be a sphere, and we're going to reduce its size to about 0.5 on the scale. And this is about the size. Everything else about it is not that important, okay? So now that we've set up the X swing at box, let's compile that and we are going back to our melee enemy, okay? And we're going back to the event graph. And what we are going to do a truck just passed by. Anyway, what we are going to do is we are going to spun it in right over here. So what we want to do is we'll come in and we'll say, Hey, spun spun actor SP AWN. Okay, spun actor from class, and we want to select the class as X swing at box. Okay, x swing. Box. And then as far as the c to get the location, all we want to do is we'll get the axe swing location, drag it out over here, and then want to get wild location of that. Oh, go away, go away. Drag this back. Get world location. Okay, there we want to get its location, and that's going to be its transform. Good, good, good, good, good. Grag this over here. And if I remember correctly, yes, it's going to sweet turn it into a vector. So here we are. So that is essentially all that we want it to do, okay? Now, all we have done is set it up so that move to attack range of detected player. Once it's in range, it's going to immediately spawn the x swing at box. Now, to make sure and test that this is working correctly. Yeah, there it is. It's spawn in that heat box. It's spawn it in immediately. But what we're going to do now is we're going to go to the x swing heat box. We're going to increase its scale to one. Okay. Hmm. Reasonably sized reasonably sized. I think that's a reasonable size for the hit box. Now, just to do a quick double check, this is the animation. Now, let me go back to the melee Enemy blueprint. No, we'll come back to that there. So about this is the hit box right now. So let's go back into the melee enemy. Let's reduce the range that it is going to stop at. Right now it's at 300 units. Let's reduce that just down to 150. Go back in, do another quick test. Okay. So this is where the hit box stops. Now, we'll go back to the x swing hit box. We are going to change the properties of this sphere and we're going to go to collision. And right now it's set to block all dynamic. We're going to set that up as overlap, all dynamic. Do a quick compile. Let's see what that looks like now. Okay, so it's overlapping. So once it gets into 150 units of the player, it does that. This is good. This is good. That's good enough damage. Now, rather, that's a good enough position for it to start the attack. Now that we have that, let's also add in the code to reduce the player's. Now in the spirit of speeding up our development, I have gone back to the player's sword attack, and then I'm basically going to copy over all of this code, copy it over, go to the X swing, and then just paste it here. Now, of course, this code will not work from inside here, but it's going to show us how to do everything. So remember, all it's doing is on component begin overlap. Okay? Pass to the thing you want it to do damage, apply the damage and then destroy the actor or on event t which is one frame, destroy the actor. Now, we are making some changes. For starters, the damage we can live the same for now, we'll remove the cast to attack damage that's not needed, and we'll remove the cube overlap. All we need is applying damage, destroying the actor, and on event te destroy the actor. That's all we need. Now with just that we'll head over to the sphere. We'll add the event and we'll call it on component begin overlap. This event has now been added in. We've added in the overlap component. Now, from here, what we want to check and see, Hey, by any chance, are we hitting the hero. So start with the basic cast to hero. In other words, if we are hitting the player character, that is what we want to see if we are overlapping. So if that is the other actor, that's good. As hero, you're going to act as the damaged actor. And here we go. So this essentially should be everything we need for it to do damage correctly. So on component begin overlap, it's the sphere. It's that x swing heat box, we're casting to the hero, applying ten points of damage, and that's the damage actor. Actually, let's increase this damage. Ten points is kind of stingy. Let's increase the damage to 25, okay? Just for you idea x swing. You're special. Now, we're going to compile. With that compiled, let's go back and see if it's functioning correctly. Ah, there we are. Not bad. Now, of course, it did it multiple times, which is not what we want. But you can see it keeps spawning in that heat box and it's killing our player. That is good. That means that our axe swing is working correctly, rather the swing at box is working correctly. Next, we are now going to make sure that instead of it spawning immediately, the enemy is going to go through the whole animation cycle of its attack and it will spawn in that single axe swing heat box. During the attack, we are going to connect the spawning of the attack hat box to the animation. Let's do that in the next video. 69. 67 Linking Attack Animation with Code For Melee Enemy: So now that we have added in the basic damage hit box for the melee enemy, let's now make sure and set it up so that when the melee enemy is attacking, we play that nice attack animation. Where is that? Yes, this animation. Okay? That nice sweeping attack animation. So inside of the melee NEM blueprint, we want to create a brand new variable, okay? Now, inside of the variables, let's add a variable called x swing attack. And then we'll add another variable. Okay. And we'll call that variable is attacking. Now, these two Booleans are going to do something very, very basic. Now, the x swing attack we are going to set it up in order to start the x swing animation and then E attacking is going to tell the AI that currently it's in an attack animation or in an attack state, and we'll be using that later on to adjust some of the behavior of the AI. Once you have added in those two Bolans, this is all going to make a lot of sense once we get into the code. Next, we have our upswing at box. So what we want is to set it up so that this is for stopping all active movement. Let's add this in right after stopping all active movement. But before spawning in the sword attack, we will get the axe swing attack. Drag this out over here. We want to set x swing attack, and we want to set it on. So we are turning on the Axe swing attack, okay. And when the x swing attack is on, what we want is we want to get is attacking Okay. And we want to set is attacking. Okay? So here we are. Want to set is attacking. But where we want this, bring this over here. Let's see, set is attacking. Let's drag this out over here. So we will set is attacking right over here. So immediately, we said, Hey, we are attacking the AI is attacking, and it should use the x swing attack. That's the baseline. Now, to keep this from replaying multiple times, wanted to play once, we are going to this branch Okay. And we are going to create another branch right over here. Keep in mind, we are using the branches here just for simplicity, okay? Now, what we will set it up to is right over here. So right after detecting player if the melee enemy is in the right attack range, we're going to connect it up over here. And then if this is false, it will do this. Okay? If it is false, it is going to go on and do attacking the player when in range. Okay? Let me actually move this forward a bit because we need to extend it out a lot, extend it out. We keep adding more and more code. So fundamentally, if the player is attacking, if the player is not attacking, it will carry all of this out, and it will set is attacking to yes, and it will do the ax swing attack, and it will spawn in the hit box, okay? However, if it is false, it should do nothing. Now, we will get the attacking. In other words, we will get the attacking, drag it out up to here, and we will get it, and we will connect it here. So it should only play once. Now, let's have a quick overview before we do some basic testing. It will check the player if the player is in the right range to attack. If it is definitely not attacking already, it will now carry out all of that code, but it will set itself up to be attacking and it will set the C swing attack to positive, and it will spawn in that heat box. Now, just with everything in its current state, let's quickly go into the developer level, and it did. Notice the player's lost health. So let's do this. Boom, the player has lost 25% of health. So it's doing that and it has done it once. Before it was creating multiple hit boxes, now it's doing it once. That's good enough to start. Next, let's add in the animation. So we'll go to the melee animation blueprint. We'll go to the animation graph, and we will go inside of the melee enemy state. So right now it is set to idle and set to work. Now, all we need to do is create a new animation state. And we will call that animation instead. Let's call it x swing. Let's just call it x swing attack. Okay? We'll just call it X swing attack. Then we shall drag from idle to the axe swing attack, and we will drag from working to actually. We don't even need to drag from work. The reason why delete that we'll just connect from idle. And the reason why we only need to connect from idle is because the AI always comes to a complete stop before it starts the axe swing. Now, when we look at the code, Notice that it stops all movement first, and then it starts the is attacking. Okay? Which means that at that point, its movement speed should be zero. So we don't need to worry about doing it from work because players work. But em is generally, you stop them dead, even if it's for a split second and then it plays out the attack animations. Now, let's double click on x swing, and we simply want to play attack from here. Okay. And you'll see that this animation is called attack. Now, inside of the blueprint now that it's set to play the attack, what we need is the condition moving it from idle to attack, and the condition will get as melee enemy. Then we want to check x swing attack. We are getting x swing attack, and we want to see, hey, is this exactly equal to Okay. Is this exactly equal to yes then play the x swing attack animation? That's all it's going to do. We currently yet have a way to set it back from x swinging to idle, but we just want to test. Now it is doing the x swing animation. Look at that. Look how it's chopping down the enemy player. That's a good little evo skeleton. Good little eoskeleton. Well done. Now, now that it's set up to do that, we now need to simply connect the spawning in of that damage to a frame of animation, which is pretty simple. So we'll go into melenemy and we are going to get you see spawning the actor of the hit box, and we are going to create a custom event. Okay. So we are adding in a custom event. We shall call this event of we shall simply call it Axe swing that's all we're going to call it. Now that we have that event, we are going to drag over all of this code of spawning this actor at box, and we will connect it from here, and then we'll come back over here and we'll break that link, okay? So the only thing that's going to span in the actual heat box is this x swing custom event. Okay. Actually, let's change it because X swing is not enough. Let's call it X swing hit box. Okay? That's what we're going to call it. And then, of course, like Good Little Citizens, we are going to add in a comment box, and we're going to call it we're going to type the comment, spawn in X swing at box so that we will be able to easily know what's going on. So with that event here, if we go back to the level, Notice that now it's not doing damage because the hit box has been removed. Now, let's go back into the animation blueprint. And what we will do is we are going to head over, let's see. No, we need to go into the animation source. Here we are. We'll go into the attack animation and let's quickly play the attack animation. Nice. Now, we are going to go over, right? Here, boom, right there when he does the chop. At the place where he does the chop, we are going to add a notify. We're going to add a new notify and we're going to call the notify name XSwingHtbx. That's the name of the notify. Now that that notify is set up, we'll go back to the Me Enemy animation Blueprint. We'll go over to the notify. There it is XSwingHtbx which is good, and then we will drag in the melee enemy. Get as melee enemy, and then we'll drag that out, and then we want to use the x swing hat box. That's why naming everything in a way which makes sense is important. So you don't need to overthink what you're doing. It's just easy. So we know this is the x swing it box, and here it is. So with just that setup, we'll compile and now let's play. Boom, boom, it's doing damage. Boom, damage again. Boom, uh, the player is dead. Nice. And that is with us. So we have Sepuldon. Let's do this exit again. I kill the player, kill the player. Good. So the player is dead. Now, the reason why. The reason why this works so effectively and I recommend all these methods is because we have separated the position of the hit box animation. We have separated the animation from the damage. Everything is separated so we can adjust it separately. Maybe you want to adjust the hit box, you can adjust that. You can adjust the animation and change where the hit box spans. This is just good game design in general, I highly recommend it. Anyway, so now that we have it set up so that the enemy can actually go towards where the player is and start dealing damage. The next thing that we want is to make a couple of adjustments. Now, you will notice when I oh snap, it's really trying to come and just keep attacking Notice when I'm running away, it's still playing that animation. Okay? We don't want it to be doing that. We want to separate movement from when it does the attack. We want to add a little bit of delay when the enemy decides to do different actions. That is the best way to have a good AI in your game. Let's do that in the next video, some AI adjustments. 70. 68 Adding Attack State Reset Function: All right. So now that we have our AI able to understand when it is attacking, now we're just making some timing adjustments to it, okay? So it's not just like running around doing whatever it wants. Okay. So first of all, melee enemy, upswing location, collision, overlap all dynamic, okay, I don't know what we're running into. But there's something we're running into, yes, the paper flipbook it set to block all I'm setting it to overlap all that should solve the problem. Now I can, I don't know what's causing that. Mm. Okay. I don't like that I don't like what the cameras doing. Alternatively, that might be a hero character thing. So I'm going to go to the hero camera, the camera, and then double check its collision. Let's see. Okay, double checked. It's not the camera. It's the spring arm. That's the spring. I'm coming out. Right now it's doing a collision test. I've disabled that during the collision test. I want to make sure this has stopped. Okay, much better. Much better. I prefer this. Okay, so we can just run through people. Way go away, go away, go away, go away, good. That's fine. Anyway, that was just a quick thing. Now, fundamentally, we want the movement and actions of the AI to make for lack of a better word, a bit more sense, okay? So this is what we're going to do, okay? When the AI moves and starts attacking the player, we are going to do a basic double check of the distance to the player from the pawn. And then once it exceeds a certain distance, we assume that the player is running away or has come out of the distance where it can be attacked. And then at that point, we are going to disable the attack animation. Okay, that's the general overview. So we'll go into the melee enemy. Will come in over here. And then right here around the moving to attack range, right after the simple move to location, as it's doing its move to location thing, then the next thing that it's going to do, actually, the first thing that it's going to do, you arg this out over here. Okay, so we're going to do a simple check. Going to do a simple branch check. And within this branch, we are going to ask if it was attacking. Okay? We'll get is attacking. In other words, right now, the player has moved out of attack range, but the AI is still attacking. Okay. So since it was still attacking, the first thing we wanted to do is we want to set x swing attack. No, then, why is it showing me all that? Yeah, here we are set x swing attack off. Okay. Now that we've set x swing attack two off, Hold on, let's drag this out a bit more, give him some more space. Right after setting the X swing attack off, it's going to do the simple move to location. However, if it was not attacking, then all it's going to need to do is move to the location. It's some basic simple code logic. Okay? Very basic. So let's come back to the melee animation blueprint, the animation graph, the melee enemy state. So we'll come over here and we are going to get the x swing attack. Okay, and we'll first leave it as is. Come over here, mainly anime animation, blah, blah, blah, blah, blah. Mainly animation, we'll get the x swing attack. And in order to go from idle to the axe swing, all it has to be is x swing attack is equal to true. However, to go from x swing attack to idle, what we want is we'll get the melee enemy. We want to get x swing attack. Okay, we are getting the x swing attack. And also, we are going to get the A attacking Okay. And then what we want to do is to double check two things. For starters, we want to say equal to. Want to double check if swing attack rather. I want see let's see. The logic has to be tight. The logic has to be tight. If Aswing attack is false, it can enter that transition. Let's do a quick check. Okay, it has now stopped. Okay. But it's creating another problem. It's not going back into the animation. So notice here, it's attacking. Okay. Restart, it's attacking. However, if it's attacking and we get out of the attack range, when it comes back into attack range, boom, it is no longer able to attack. Okay. I should seriously let me turn off these discde notification. Okay, so this is how it's working right now, and then when you run away, the animations are working correctly. Now, in order to get this working, this is exactly what you need to do. F starters inside of the melee enemy, you're going to organize it so that right after let me go zoom in properly. Right after doing the distance check, we branch and check and see if it attacking condition is pulse, it will continue to do the movement. This is to guarantee that it only starts moving after the attack animation has played out in four. Next, make sure, of course, there is the normal is attacking branch. Now notice at the end of the attack animation code start, right, I attacking is set to yes, and the CSwing attack is set to yes. Now on top of that, you're going to add in a simple reset attack state. We shall start with a custom event called attack stat reset. And inside of that, it resets is attacking stat, and the cswing attack is also set back to being off. And that's just inside of the melee enemy blueprint. And then inside of the animation source, okay? Go to the attack animation and at the end, add in a notify known as attack State reset. Once that notify, that notify, of course, is set up at the very end of the animation, at the very end. After setting up that notify, go into the animation blueprint for the melee enemy. And under the notifier of attack state reset, add in receive notify attack state reset, so it will call in that attack state reset function. And once you have all of that set, now when the enemy comes towards the player, it's able to do the attack, but the player is able to run away. Okay. Now, in the next video, we're going to make a simple change because now the player can just move forward and they are no longer able to as you can see, the player is no longer able to take any damage from right here, and the enemy only turns around after the player moves a certain distance. We want to adjust it so that the enemy character is always facing the player's direction. Okay? Boom, no, let's do that. Okay, that's good. Let's do that. Little adjustment in the next 71. 69 Stop player from being able to run through AI: Alright, so we want to prevent the player from just chesing everything by running through our enemies. So a simple way to do that is the capsule collision is currently set to the collision preset of pawn. We can basically set it up to something as simple as block all dynamic compile, so it's not disrupting the level layout. Make sure this actually needs to be on the ground. I don't like its position when it's outside or there. So now the player can't just bulldoze through the enemy, the player has to actually jump over. But now with just that change, let's select the character. Okay, that's our hero. Select his character movement, select jump. Currently, jump Z velocity is set to 840. We're going to increase that to 900. Okay. Let's do a quick check. Yeah, that's stupid. 909,000 centimeters/second is not what we wanted. Let's see. Let's set that to 9 meters/second. Sometimes Unreal Engine, sometimes Unreal Engine will change the numbers in a way that doesn't make sense to me. There have been better flows, just one variable. But anyway, so now we are able to jump over the enemy, but we can't cheese and just push through bulldoze through the enemy. Okay? That was getting kind of wild. So now that is fixed, we can move 72. 70 Nerfing the Melee Enemy AI: All right. So in the current state, we have a simple melee enemy which will attack the player. Okay, it's coming up and attacking the player. Which is pretty reasonable. Okay. That's cool. However, notice that anytime that it attacks, it immediately starts chasing the player down again. We want to build in things into the AI after it has done something, let it slow down for a bit and delay its next action to give the player some more time to react. So let's go into the melee enemy, and we are now going to separate a lot more of its abilities. For starters, Clear is visible. That string, we are going to get rid of it. We do not need it currently. And the next thing we're going to do is inside of the level. We're going to nerfs visibility range, so this is going to be much clearer. So I'm selecting its player detection. And I'm going to Nerf its detection range. Currently, it's set to site radius of 1,000. I'm going to nerf the detection range, its sight radius down to 600. Okay. Just to make a lot of what else is happening, a bit visible. Okay? So now, the player needs to be within 600 units. The next NaF that's going to be given to it is we're going to get its movement speed, go to character movement. And then look for speed. So its max work speed is currently 600. We're going to drop it down to 450. Okay. So four 50 centimeters/second, which means it is now significantly slower than the player. So it detects the player, but the player can easily jump over it and run away. Notice the player is about to run away. Now it's coming towards the player, but we've slowed it down. These are basic simplification nerfs, okay, because you never want this you never want, you know, your enemy to be excessively difficult for the player. So there notice it needs to get in range, then it attacks, needs to get in range, then it attacks, but the player can run away. The player can run away before its attack animation has played out. Okay? So those are just some basic nerves. So the movement speed nerve and the animation is already slow enough that the player could really reasonably counter it by running away. Okay? This is just to give the players a bit of a buff. And now now that that's done, let's go in and make it so that anytime the player attacks the enemy, the enemy immediately is going to get stunned so that the player is able to just do its triple sword attack and sun the enemy to death. Let's go into that. 73. 71 Death Animation for AI and some logic theorycrafting: So now that we have a couple of baseline things running, what we really want now is for starters, when the player does damage to the enemy, we don't want them to keep attacking. It's basically a little enough. We want them to enter a little bit of hit stern so the player can actually get their combo off. Now we know that to do that, we need to add in some heat stater animation to our little sklebons over there. So let's go into our melee enemy into the art, and we want to look for skeleton dead. Okay, and skeleton hit. Now, if we look at skeleton heat, it's basically preset with, like, Oh, it's taken a little bit of heat damage, and then it goes back to idle. It's a basic it animation. Okay. So let's come back here. So there skeleton hit and then skeleton dead is the skeleton falling over. Okay, you can see it there. Skeleton basically falling over. Now, just for the sake of having some good logic, we are going to only use the skeleton dead for this animation. Okay? So we will select the skeleton dead and set it up sprite actions. We want to extract all of the sprites. Now you can see all the sprites are here when we zoom in. There are multiple sprites. But let's get it out of auto and put it back into grid. Now they are one, two, three, four, five, six, seven, eight, nine, ten, 11, 12, 13, 14, 15 different animations. So we need to divide the cell width by 15. So let's open up our calculator real quick. So 495/15 is 33. So we shall make the cell width 33 pixels, extract those sprites. And then we are going to create a flip book, and we will call it. We will call it dead. We'll just call it dead, okay? So this is the current dead animation. You can see it there, 15 films per second, okay? That's the animation. Okay? That's cool. So let me pause and go through frame by frame. So you can see it starts by becoming white, okay? It becomes white. Then it kind of falls back a bit and then it collapses. So this is where the logic comes in. We will set it up so that around frame six, before it starts falling apart, we are going to do a basic check of the health. If the health is good, it will go right back up back to idle, okay? However, if the health is zero or rather it's zero or less than zero, it will fall apart, and that will be the end of our nice little melee enemy skeleton. Okay? So we now have this animation. Let's first play it. So it's set to move at 15 frames per second. But I think we need to slow it down a bit or slow it down to about 20 frames per second. Ah, that's speeding it up. Apologies. Let's slow it down to about ten frames per second. So it's taking a hit. It's taking a hit. It's taking a hit. Okay. Let's set it back to 15. We shall return later based off how things look and feel. Now that we've set up that animation, let's go back into our animation source, and we want to add a new animation sequence, and we shall call the animation sequence, Dad. We'll keep it, you know, clean up the names, keep the names clean. As far as animation data, we are looking for dead on flipbook. So this is the undead animation. Look at that. Pretty cool. Now that were done setting up the animation here, let's go back. Let's go back and have a quick look. Let's go back to our melee enemy. Okay, we'll come back to thinking here, Animation graph. Let's go into the animation blueprint for the melee enemy. Select the melee enemy, and we now want to have a new animation state. And this animation state is going to be called Dad. Zoom out. Zoom out, go back, change the name. It's called dead. And we're going to drag it out here. So from idle to x swing attack, we can go immediately to dead, okay? And dead, we're going to have the animation type play dead, so it will start playing out the dead animation. Okay, that's really what it's going to do. Let's quickly compile. Now it's not linked to anything. The next thing we're going to do is we're going to link it and set it up so that it plays anytime that the enemy takes 74. 72 Making AI Health Bar Visible And Some Adjustments before moving forward: All right. Now, by the power of generalized time travel, right now, the player can attack the attack dummy and its health will eventually reach zero. Okay? It's not yet set up to die yet, but we are able to attack the attack rather to attack the enemy and get its health down. A couple of things have been changed. Number one, for your sword attack of the player, change its base damage from about 25, increase it to 40, so that it's doing more damage. And then for the axe swing it box, drop the damage down to one. This is just so we can do some testing without it murdering the player super quick. That's pretty much it that needs to be done for that. Next, head over to the melee enemy and create a new comment. This comment is going to be called heads stater on taking damage, but we want to make sure we set it up so that the enemy actually takes visible damage because want their health bad to be shown. For the health bad to show, the first thing we do is go back to the widget, go back to the widget and set it to be visible. Set it to be visible true. Once that is done, the next thing is to now organize and set up these blueprints. Within that comment, we start with an event any damage, and then a variable hits stan and we'll do a basic print string of hey damage is being done. And then we are going to create another print string, which is going to type out the damage rather to type out the health of the enemy. Now, if we go back, right now, notice you're seeing dammi Health here. In order to have that revealed, head over within the My Blueprint and there is a setting and then show inherited variables because the variable DamiHalth is being inherited from the parent class. Now, we use the Dami health a lot here. For starters, we'll get the dammi health, and we will subtract the damage amount from the event any damage. So we subtract it by simply have set dammi health. There is a subtraction going on. That's our new dammi health. Once we are done with that, we come over and get the widget from the melee enemy and drag it out. And then we get the widget from inside it, which is, of course, dammi health bar. And once we've cast it to the dammi Health bar over here, as dammi health bar, we are going to of course, target the dammi Health progress bar, and we will set it as the percent of 100 by doing the set percent from the dammi Health progress bar, and we will be using the DamiHalth divided by 100, and that will be the health that we have. And with all of that setup, you will have the player able to do damage to the enemy and we can see the health bar going down. With all of that set up, let's now move on to adding in the Hit Stern logic. 75. 73 Melee Enemy Hitstun and Death all in one: Now, to add in the heads stater in the game, when we are inside the melee enemy Blueprint, notice that on any damage, we set up this variable called heads stan, and we've set it up to be true. Now, now that we have that setup, we are going to go into the Me Enemy animation Blueprint, and we are going to set it up so that from the Axe swing attack, it can go to the dead animation, and all we need is ASMleEenmy. We want to check headstan Get is in hits. We want to check it under equal. Okay. We've done this multiple times. This should be easy for you now. And as long as hits is equal to positive, it can go from attacking right back into, you know, playing the dead animation. So let's do that. So I'm attacking you. So it's now doing the dead animation. Notice, once it gets hit once, it's attacking, it's attacking. But once it gets hit once, it plays the dead animation. Okay? That's cool. Now that's perfectly fine. However, let's go back to the animation blueprint. We also want it to be able to go from the dead animation right back to idle. But we're going to set it up like this. Now the reason why it goes from x swinging Okay, right back to dead. And the reason why it should also be able to go from idle to dead, we'll set that up later is because immediately it's within cleartack range, it starts to do the x swing. But we hit it, it starts playing the dead animation, and that animation is that animation of it collapsing. But we don't want it to always play the dead animation if it is not yet actually dead. So we'll come here. Let's see one, two, three, right before it starts collapsing. At around the end of the fifth frame, we are going to create a new notify. So we will add a notify. We will add a new notify, and we'll call it meleeM heads stater. Okay, we're just calling it melee enemy headstand. And that's all we're going to call it. That's the notifier. Now that we are doing that me Enemy heads stater, okay? It's checked over there. Now let's go into the state and notice me Enemy headstand notifies here inside of the blueprint. And what we want to do is want to drag in as enemy. Now the next thing we want to do is we want to create a function. And what that function is going to be is it's going to be the melee enemy dst function. Okay? Now, back into the melee Enemy blueprint, I'm adding a comment box, and then we're going to call this hitter help check. You can call it. Honestly, you can change this up in multiple ways. Let's see, I call this Melanem headstart no problem. Let's call it me heads health check. So anytime the player is heads, it's going to carry out this rather the EM is head stan, it carries out this check. Then we are going to create a new event, and it is going to be a custom event, okay? Now, just to make sure the names are the exact same, it's called mele ENM hit Stern. We're going to call it. We're going to name it the name over here. Mele N hit Stern so now we have that melee enemy hitter check rather function over here, this custom event. Now, what do we want to do in this custom event, right? So what we want to do is what we really want to do is we want to drag in the dammi health. Okay? So we want to get the dammi health and want to do a basic check, okay? So what we want to see is we want to see less than or equal to. And is it less than or equal to zero, okay? And then we're going to do a basic branch. A very basic branch. Now, if the health of the dummy is less than or equal to zero, what we want to do is we want to set it so that we change the Hetster variable property. Okay? So if the enemy health is less than zero, or equal to zero, that means the melee enemy is actually dead. So what we'll do is if it's true, it's simple, we'll leave it as is we'll just leave it as is. Okay? However, if it is false, what we are going to do is we want to set headstand. Okay? Oh, I'm not typing. Set headstand set in headstand to be off. Now, the reason we are doing that is because we want to set the heads stater to be off because we want the enemy to come out of the heads stater animation. Now, it will not currently work because notice right now it's not yet ready to work. I hit them once they're still in headstand. Now, to get it to work, first of all, we need to set up the event here. We want to mall enemy headstan, set it up inside of the animation blueprint in the notify. Perfect. Now it's set up in the Notify. It still shouldn't work, but want to make sure that even with the event, it's set up correctly. Okay. Now, next, we want to go back into the animation blueprint into the animation graph, and we want to be able to go while it can go from XSwing to dead, the dead animation, want to also go from idle to the dead animation. I'm just going to copy the exact same code from the AXSing because it is the exact same logic anytime it is in headstand, and then we will double click on the dead animation and on the play dead, we are going to set it so that it does not loop. In other words, it is an animation that plays only once. Okay? So now it no longer loops. Now that it is no longer looping, let us now I can go from dead back to idle in one instance of where if hitter is equal to off, it will go straight back to idle. And if hitter is equal to off, it can go straight back. Let's go over here to attacking if it is off. Okay. So it has both routes available to it. So let's play now. Notice that now, we have it stand let me do that again. So now it can attack. If I hit it, it gets hit start, but it goes back to attacking and then it's able to go after the player again. Heads, and then it stand. But this time it plays out the animation. I hope that makes sense. I've done my best to describe the full logic. Please, if nothing is making sense, go back and rewatch the video. I want this to be working correctly, but more than that, I also want this to be making a lot of sense. Now, so the enemy is now killable. So one, it's head stand, one, two, three, it's now head stand, and now it is dead. We have set it up correctly to actually die properly. Now, with that in mind, we don't want these cops to kind of sit around forever. Okay? So what we are going to do is set it up inside of the melee enemy so that if this condition of dammi health is equal to or less than zero is true, what we also want to do is there's going to be a delay of I think 0.2 seconds is perfectly fine, but I think that's a bit too short. But then we will simply destroy the actor, and that will be the self. So, let's quickly compile this. Compile good. No, no, no, compile. Let's first save all and make sure all the changes are properly saved. This is compiled. So it hit again, dead. And then, boom, it's disappeared from the world. And that is a very simple overall way to set it up so that the enemy can enter headstan on taking damage. Okay, but go back to attacking, but it can still enter Head Stan, and now it is dead. Now with that setup, that very good system for Headstart, we can now simply move forward and make more adjustments. There are a couple of different directions you can go. For starters, we now can do the exact same thing for the player character and set it up in Headster. We can do the exact same thing for other enemies, since the logic should now make sense to you. With this setup, let's move on to adding in more code into our game. And next up, we are going to make some cleanups and adjustments, do a quick double check of everything with the enemy, adjust some of the numbers, and then move on to another type of enemy for your. 76. 74 Setting Up The Ranged Enemy: Now, to quickly get started with having a nice ranged enemy in our game because we have the melee enemy here. But right now we don't need you right now, so we can just you know, we can leave it in the world to revisit it later, but for now, let's just delete it. We do not need it right now. But what we're going to do is we're going to go in and create a brand new folder, call the folder ranged enemy and create two folders inside, one called animation, the other called art. Now, inside of the art, you are going to have some basic sprites that are provided to you inside this project, so you are able to use them to learn. You can also use your own animation if you're a very good artist, and we can get started on creating the ranged enemy. Once you have those two folders set up, the next thing that we're going to do is we'll go into the characters. We'll go back into the attack dammi and the next thing we want to do is we want to create a child blueprint, okay? And we are going to call the blueprint ranged enemy. Okay? We'll get that little child. We will cut it. And essentially want to move it. Let's see, let us use move, want to use move. We'll come over here, we'll get it, and we will drag it into ranged enemy and want to move there, want to move it. So now our ranged enemy is over here. Now, when I double click on the ranged enemy, let me now bring it in over here. Here we have our nice little ranged enemy basically ready to go. The next thing that we are going to do, of course, is we will select the cube we will look for collision. We will set it to no collision. And then as far as visibility, we will make it invisible because we really don't need that Ube at all. But here we are. There is a basic and simple health bar, and the event graph right now is completely empty. This is perfectly good for us to start. Now, now that we have that, let's move on and add in the baseline animation so we can actually have something to look at when we are looking at our arranged 77. 75 Simple Idle Animation for the ranged enemy: So adding in the basic idle animation in the ranged enemy is going to be very similar to how we did it with the melee enemy. Now, just to make sure that we are doing everything the right way, I will open up the melee enemy blueprint, okay? Now, in a very similar vein, the very first thing we're going to do is add in a paper flipbook item, okay? So we simply add and we want paper flipbook. So the paper flip book is now added in. Now that that is added in, okay. Exact same way as inside the melee enemy, okay? So now that we have the paper flipbook added in, the next thing we're going to do is we're going to add an animation to it. So we shall go into art. No, not in the mele enemy. Let's go into arranged enemy, art, and we have a couple of different animations, but we want the idle animation. So double clicking. You can note that there are one, two, three, or, five, six sprites. Okay. So essentially, we want to make sure that we extract those sprites. Now, what we will do is we will first of all, apply paper two D texture settings. Actually, let's just apply those to everything. Okay. Now, from the idle, I will go to Sprite Actions and I will select extract Sprite. Let me go through that again. First of all, let me quickly save all. Okay. So from idle, just right clicking and then go to Sprite Actions and extract Sprite as has been done multiple times. Now notice that real Engine wants to come in and manually extract the sprite. We'll not do that. Let's set it up as a grid. Now we know they are one, two, three, four, five, six, sprites. Okay. So what we will do is we shall simply calculate it's 750/6, which makes them 125. So we shall make the cell width 125. So on cell width, we'll set it to 125 by 125. You see that. That's pretty cool, right? Okay. So now that we have that, let's extract. Now with all of our sprites extracted, we shall simply create a flip book and we will call it ranged M underscore idle. That's basically all we're going to call it. Let's now look at the idle animation. It's a pretty cool, nice and simple idle animation. With this idle animation setup, let's go back into the ranged enemy blueprint. Our paper flipbook is here and we'll simply change the source flipbook to ranged enemy Idle animation. There it is. So there it is. Now, if we go back into the world, right, right next to our player, we shall simply add in a ranged enemy. Make sure that it is set to zero. Okay. And Well, we have our little ranged enemy ghost lady right over there. She's not doing anything, but she exists in the world right now. Now let's make some adjustments. So back to ranged enemy. And then what we shall do is, let's see with the mele enemy, we made the scale seven. With the ranged enemy, let's make the scale four to start with. That's very big, very big. At a scale of four, it's actually not even in the world anymore. So what we will do is we'll first start by lifting up the positioning of that paper flip book, stop that. Now that we've lifted it up, compile. Now it's still quite too big. Let's drop it down to two. And then drop down the position of the floaty ghost lady. And let's see now. Okay, that's not bad. At two, it's looking kind of reasonable, but it still feels a little bit too small. So let's see 2.52 0.5, it looks about right. It looks about right. And now notice if we stand inside, it flakers. What we can do is we'll simply select the ranged enemy. And on the axis of let's see, on the Y axis, we can just move it where ten units. So we'll move it to let's say negative ten. So now it is in the background. So they're not on the exact pixel plane, and you can basically adjust it because at negative ten, they're no longer flickering. Technically, it should no longer flicker even at negative one because these sprites are one pixel thick. Okay? So that's how you get rid of any pixel overlap. That's a pretty simplified way to do it. Okay. But now we have our arranged NEM with a basic idle animation. Now, we're going to add in a simple projectile which the ranged enemy fires off at the player. Let's do that in the next video, and then we'll go in further in getting in more animations and life into that ranged enemy. Let's go 78. 76 Spawn a projectile that goes to player location on launch: Okay, so now our ranged enemy exists, and you can hit it and it takes damage, but it can't just take damage. It needs to do damage to the player. So, to make sure it does damage to the player, let's create an object that can track to the player's location and do damage to the player. Now inside of the ranged enemy folder, similar to how we've done it everywhere else, let's create a folder called damage it box, and inside, we are going to add in a blueprint. Head over to the ranged enemy. That's the ranged enemy right now. We'll create a new folder and want to call it damage it box. Inside of this folder, Okay, inside of that folder, we are going to create a new blueprint class, and we just want to create a blueprint actor. And we are going to call this enemy projectile. That's all we are going to call it. And then let's quickly save. So inside of the enemy projectile, all we are going to do is we're going to add in let's add in a quick sphere, okay? That's all we want, this basic sphere. So let's quickly compile. So now, by itself, let's quickly drop the enemy projectile into the world. Probably bring it in somewhere. So there it is. There is this big blob over here, okay? That's the enemy projectile. So what we want is that blob needs to move towards the player, okay? So to get that sphere to move towards the player, let's go into the enemy projectile and let's go into its let's quickly go into its event graph. But before we do, select the sphere. I select collision and then select overlap all dynamics so that, you know, essentially with the sphere, won't be able to jump into it and have it move around the player without blocking the space. Okay, with that setup, go back into the sphere, go into its event graph, and let's now start working on having it move towards the player's location. Okay. Now, to give it the right amount of movement, we're first going to add a certain property to it, and that is going to be projectile movement. So now we have added in the projectile movement to the sphere. We can begin to play with its movement in a nice built into real engine way. Now things are going to get a little bit mathematical, but I trust that with your knowledge of unreal engine, since you've made it this far into the tutorial, it's going to make sense. So the first thing that we are going to do is we are going to need to figure out the location of the player, figure out the location of the ball itself, okay, the sphere, and try to move the sphere towards the player's location. Okay? That's essentially what we want to do to get it moving towards the player. So that's the great overall theory. Okay. So the first thing we'll do is we'll start off by bringing in projectile movement, and want it to be here and make sure that it is set to activate. Okay. And we are putting this on the event begin play node. Now, the event begin play node is fundamentally the first node that is called whenever the game has this object spawned in. So I want to do all of this on the event begin play. Now that's all straighten straighten the connection. Now that that is done, it is activated. We've activated the projectile movement. The next thing we want to do is to set its velocity. Want to set velocity. Let's see in space, and that's it. I want to set the velocity in local space and notice that it is a projectile movement component. Let me get this and put it over here. Now I'm thinking, currently the velocity is set to zero, zero. That's what we're seeing. Let's set it to one on the X axis to begin with, compile and see what that looks like. Notice it's going downwards. Cool. Okay, so come back here and we'll set it to one, one, one for simplicity's sake. Okay. And so it's trying to move, and it's still dropping through the world. Okay. We'll need to make some bigger adjustments. Now, what we want this velocity to be, we're not going to wing it and eyeball it on the velocity. We actually want it to have a specific value, which is the value of the distance in between the player and the object itself. What we're going to do is we're going to get the player character. We're going to get it and after we've gotten it, let's get the location. Okay, so we now have the player's location. We have it. And then we want to get the location of the self, okay? So this is notice the target itself. That means that this location here is the location of the projectile itself. Now what we want to do is we want to subtract these two locations from each other. Okay. So this right here is essentially the difference in between these two different actors. And with just that, the next thing we're going to do is we're going to do a simple multiply. Notice that the multiplier has three coordinates. That's for X, Y, and Z, and we'll connect the end of that multiplier into the velocity. So supposing we set the multiplying factor to one, one and one, it's going to move at a velocity of one unit per second towards the player. Let's look at what that actually looks like in game. So inside the game, press play. It's now moving towards the player's actual location. So it's functioning as intended. However, notice that it's going too far down, that's a gravity thing. So to fix that, we will go back into the projectile. We shall select the projectile movement. And after selecting projectile movement, the next thing we want to do is search inside of projectile movement, gravity. Um, we want this to be set to zero because this is a gravity less projectile. If we need to start factoring in gravity, we're going to have a problem, okay. Things get very complicated and very out of hand. So without gravity, let's have a look. Boom, it's moving towards the player. Now that it's moving towards the player, let us simply cause it to self distract on contact with the player, okay? Now, the simplest way to make it stop on rather on contact is to simply cause it to, you know, stop. Anytime it hits anything, it gets destroyed. So we shall create a destroy actor. Okay. So there is this destroy actor component. We shall put it in over here. Of course, the target is the self with the destroy actor. And then we leave this here and add we'll look for the event on projectile stop. Okay. Let's see, see. So to call this, I'm going to actually need to head over to Projectile Movement. There is this event called On Projectile Stop. Let's quickly get that. So now we have that event available to us to use, and let's quickly add it in right before the destroy actor. Okay. Let me break this link. I don't think this is needed. Let's just quickly test. So on projectile stop, that means on any movement, stop of the projectile. On any movement, stop of the projectile, it's going to be destroyed. Stop. Let's start. Boom. Okay? So the movement isn't stopping yet because it is not actually overlapping with the player causing it to stop. So now we need to simply add in a quick overlap. So now that we are here, Let us come in and say, Okay, so we have this sphere. The sphere is good. Let's add something else. Let's add in collision. Let's add in a sphere collision. Let's get the actual sphere itself. Actually, I want this in the default root. So this is the sphere. Let's reduce the size of this sphere. Okay, so the collision is just around the sphere. So this is sphere one, no problem. So with sphere one, we want to add in an event on component begin overlap. That is the event that we want to add in. And what we want to do is on component begin overlap. We shall immediately cast to player rather right now we are calling it hero. So we'll call it cast to hero. And that is going to be the other actor, that is the object that it has hit. And right after it has done that, it will destroy the actor. Now that we have that, let's quickly compile. And immediately it hits the actor. I immediately gets destroyed. That is cool, and then to give it some damage, to give it some damage, notice how it immediately gets destroyed once it is on the player character, good. Now, to give it some damage, all we have to do is we will drag this out. And we want to say, Hey, apply some damage, dam some damage, whatever. And we want the damaged actor to be the hero. And let's say that each projectile does 30 damage. Okay. Let's do them out, quickly compile, and then hit play. Look at that. The player just took 30 damage direct to their health bar because they were hit by the projectile. So now we have a basic enemy and we have a nice projectile which can actually do damage to the player character. In the next video, let's combine those two together so that we can have a dangerous ranged enemy. 79. 77 Setting Up Animation Blueprint For Ranged Enemy: And now that we have the basic projectile, let's quickly remove it from the world because it's not just going to be there in the world to do stuff by itself. No, it has to be created by our ranged enemy. Now that we have that, let's get in and add some proper throwing the ball animations to our ranged enemy. Now, to do so, the first thing we're going to do is we're going to go into the ranged enemy animation. And then what we want to do is add in a paper Z D animation sauce, and we'll call this ranged enemy animation source. And we're going to now add in an animation blueprint. Then of course we are asked what we want to use as the source, want to use the ranged enemy animation. As the source. We name this orange animation, B P. That's what we shall name it for the sake of organization. Now, we shall open up the ranged enemy animation source and we'll add in a new sequence, the first one. Of course, we shall call it idle. That's the name of the first one because we start with an idle animation. Then we simply want to find the ranged enemy idle. That's the animation. There is nice little idle animation available for use. Then to do the proper setup, we want to open up the ranged enemy animation blueprint. That opens this up. And now that we have cast it to the ranged enemy, what we want to do is want to get the owning actor. Okay, very similar to what we did with the melee. And then we want to promote the as ranged enemy with variable because that is what we are going to use in animation. So this is everything. Event on initiate cast ranged enemy, and then as ranged enemy is going to be the variable. Okay. Now, now that that's set up, we have access to the animation graph, and we want to create a new animation state. So we'll add a new state machine, and we'll just call this range EEM. We'll keep it simple, and we'll set that up as the output. And then to make sure that this is working effectively, we shall go back to the ranged enemy Blueprint itself. We shall add the paper Z D component to it, for handling the animations. We shall add in the ranged enemy Blueprint as the animation instance class. And then for the render component, we shall select the paper flipbook as our render component. At any time paper is doing the animations, it will manage it through that we've done this three times, twice before. I hope all of this is making logical sense to you. Because now notice that it is simply stuck in place, but then we shall go back to the ranged enemy animation blueprint. We'll select out, drag it out animation state. Set the state as idle. Oh, cap to I as idle, and then select the idle state, and then we want it to play the idle animation. Compile, go back. And then now when we go into the level, it is playing the idle animation correctly. This is exactly where we want to be, and I hope that because you've been learning so well from the other videos, all of this is connecting and making logical sense to you. You should actually be able to do this mostly by yourself. But now that we have this done, let's move on to actually adding in the projectile drawing animation. Now, if you go back into characters arranged NEM and back into the art, notice that there is this attack rowing animation. Okay. Now with this, what we want to do is we want to get that attack animation. Do the same thing, apply paper to these settings, and then extract sprites. It's still going to do the same thing of trying to extract them for you automatically, but real Engine is not smart enough to do that yet. So set it up as a grid and then divide 750 by one, two, three, four, five, six, which comes out to one, two, five, and those will give us the clean strip sprites. We extract them. They come out as attack zero to five, and then we create a flipbook, and we want to call it ranged EM underscore attack. Okay. And with that, notice the animation. That's the ranged enemy attack. But let's slow it down. I think this is way too fast, okay? So what I want it to be is instead of 15 frames, let's make it five frames. Much better. That is much more reasonable as an attack animation. So you can see the witch bringing up her hand and then throwing it. So that is very, very good. Now that we have that animation here, now we go back to the ranged NEM source. We add a new animation sequence, and we shall simply call it attack. Keep it simple. The animation data is going to be coming from the ranged NEM attack animation. There it is. Okay, that is essentially it. And then with the ranged NEM attack animation in play, let's quickly save all. Now we can go back to the ranged NEM basically this, right? So it has idle. We now basically need to set it up for attack. So we shall create a new animation state, and we shall simply set it up as play attack so that it plays out the attack animation when it's transitioned into. And we are going to set it up. We'll do this later, but let's change the name. Whoa, of that state, shouldn't just be state. It should be attack. So now we have a way to go from idle to attack, it's able to play the attack animation, but there's no code for transitioning it yet, and that's okay. But now let's simply go back into the ranged enemy blueprint once again and we'll go into the event graph. Now, in order for it to do the attack in a very similar way to how we set up the melee enemy, we are going to add we are going to add some point sensing. Okay. And we are going to call it same thing as before, player detection. So once the player is detected, it will work and same thing, sight radius will drop that down to let's say 500. Hearing will be zero. We do not want it to be hearing. Sensing interval is set to 0.5, which is fantastic. That's reasonable. I'll drop it down to 0.1 just so that the sensing interval is better. The vision range will be set to 179 degrees so that it has a lot of visual range. And with that, we shall simply go into the event graph. We shall drag in no, we don't need to drag it in. We shall go into clear detection at the event of on C pawn that's player detection. So every time it sees the pawn, all we wanted to do is print string and want to say, Hey, player detected. Okay, that will be a good start to see if it's working correctly. So press play. Clay is not detected. Clear is being detected. So we know that it is working correctly within the range denamy. We do not need that anymore. So now that we have this, what we are going to do is we are simply going to spawn in that projectile. So now that we have it. Now, in the similar vein to before, we will go into the paper flip book, and what we want to do is we want to add a basic box collider, and we want to call that projectile spawn. Okay. So the reason why is because that is where the projectile is going to spawn, so we can drag it in. And let's put it somewhere here, okay? Nice. We'll put it somewhere here. Now that we have that projectile spawn locked in, we'll go into the event graph. So every single time that the player is detected, it will spawn that projectile. So we will use the basic node for spawning. So we'll call it spawn actor, okay, actor from task. And the class is going to be enemy projectile. Okay. That's just the basic class that we are going to be using. And then for span transform, we shall get the projectile span. We shall get its wild location. Oh, physics. I don't know why that physics was selected by me. That is my bad. What we want is to get wild location. And then that wild location is what it will span transform to. Drag this down here, drag this here. So now this is making sense. So essentially, it's going to sense and every time it senses, it is going to spawn in that projectile. Let's compile, double check that this works. So notice it keeps spawning in those projectiles and notice the projectiles spawn moving towards where the play was originally. So we now have that spawning of projectiles ready to go. Now, in the next video, let's add in the throwing animation, and we set up the frame at which the projectile is going to actually spawn in. 80. 78 Linking Throw Animation with Projectile Spawn: Now with all of that set up, we have our arranged enemy spawning in those projectiles. Now, let's quickly go back to the ranged NEM blueprint. And remember, every single time it detects the player, it's going to spawn in the projectile. But instead of it spawning in the projectile every time it detects the player, we're going to make a very basic adjustment. So let's start by adding in a quick comment. So I've added in the comment of just, you know, detect player. Of course, as always, black background white text, increase the size of this comment and make sure that the nodes are well positioned. So we know that inside of here, all it's doing is detecting the player. And now, this is spawning in the projectile. So what we are going to do is we are going to break that link and drag this out over here to separate those two actions, and then after detecting the player, let's create a new command and then call the spun in projectile. All right. So let me quickly drag this into here. And we are going to create a custom function. Okay. Now, rather a custom event, and we will call this fire. No, let's call it shoot fireball. Okay. Actually not fireball because it's not a fireball. It's a magic ball. So simply call it shoot magic ball. So shoot magic Ball is the name of that function. And anytime shoot magic ball is called, it will pan in the projectile, okay? Now, with this set up and out of the way, let's come out to detect player. Now, we want to set it up to do one of two things. Firstly, if it detects the player is very close, we want the ranged enemy to attempt to run away. And it only should do this once. However, if the player is in shooting range, then it is going to attempt to shoot a projectile at the player. Now, fundamentally, let's start by just setting it up so that once the player is seen, it fires a fireball at the player. And the way we will do that is we are going to simply create a new variable. And we will add that variable in. It is going to be a basic Boolean. And we're going to call it I footing magic ball. Okay. Now with that variable setup, we'll drag this out and we'll set it as set is shooting magic ball. And we will set that up as yes. It starts out as no, but right when the player is seen, we will set it up to shoot the magic ball. Now that we have his shooting magic ball here set to go, let's open up the animation blueprint of the enemy. So now, inside of the animation blueprint, to go from idle to attack, all we have to do is go into the transition, and then as the ranged enemy, sorry, drag that in. Get as the ranged enemy. We look for is shooting magic ball. And then we want to say, Hey, equal to y, then you can enter that transition. It's very logical and it should very easily make sense. So let's go back to the main level. So notice, it is now immediately the player walks in. It starts playing that animation showing that it's throwing the magic ball. Now, what we will do is now we will go back into the animation source and we'll select the attack animation. We want to look for a point when the ball is thrown around here. Boom, and we will create a new notify. We'll create a new notify and we are going to call the notify throw magic ball that's what we will call it Zoom back out. So at around oh, sorry. At around this moment, we throw the magic ball. Now that we have that setup in the animation source, we'll go back to the blueprint, and we'll go and look for the receive notify throw Magic Ball. And then what we want to do is as ranged enemy. We want the event of throw I've called it shoot magic Ball here. So we'll call that event of shoot magic ball. It's always better to name them in a way that's logical. So here we are. So every time that notify is called, it should shoot the magic ball. So, let's go into this. Let's see. So go back into game. Now, every time the enemy is able to see the player, it shoots the magic ball. Okay. Boom. That's very good. So that's a basic. Now we have the animation setup for throwing the magic ball, okay? So let's move on. Now, next, let's fix the direction change and then add in a much more lively animation because right now the magic ball is basically just that floating to the player. Let's make an adjustment to how it looks. 81. 79 Adjusting Sprite Direction to player location: So now that we have the ranged enemy able to throw a magic ball at the player, and it is set up and being done based off the animation, let's make sure that the first thing the ranged enemy does when the player is in detection range is it faces towards the player. Now we shall go into the ranged enemies sprite, and you'll notice that these sprites were drawn looking left instead of right. So what we shall simply do is we shall select the paper flip book, and we are going to adjust its rotation on the Z axis, and we shall simply rotate it by negative 180 degrees. It's really just that simple. So now, it is facing the player correctly. However, notice that when you go to the other side, it's no longer facing correctly. That's okay and simple to correct. Now, all this, I'm going to just show you the code after it is written. Notice now it is facing the correct direction. And let me take you through the blueprints and the thinking quickly. Now, to do so quickly, let me start by showing you how the flow of code is working. So I've set it up for the ranged enemy to be debugged. Now notice here, it's flowing through the top line. When I switch to this left side, it's flowing through the bottom line. Here, it's flowing through the top flow of pot in the nods. Here, it's flowing through the bottom. I adjusted, of course, the damage to B one damage on the enemy projectile, but this is just to show you. Now, let's get into the nodes themselves. The very first thing that we do is from Os pon go directly to casting to the hero. After casting to the hero as the hero, we get its capsule component. Essentially, almost any component will do, but the capsule is very useful. And then we get the wild location, and by using left click, we split the structure pins up so we can get the X value separately. Once we are done with that, we will get the flipbook component that we can get up here from inside the ranged enemy as usual any component will do, but we'll just use the flipbook for simplicity and then we will get it wild location. Once that is done, we move on and we want to subtract. Now, we want to subtract the wild location of the capsule from the paper flip book, that's going to give us a measure of distance between the two. And then we will check the difference in distance by using the greater than node, and is it greater than or equal to zero? That's the logic behind it. And then we set up a branch. Now, the branch is simple. The distance is greater than or equal to zero, which is true. That means that the player is on the right. So we shall set up the wild rotation to be negative 180 by calling self and get the paper flip book and set wild rotation. That's the node that you'll be using. Now after setting it to negative 180, it will be facing the player correctly. However, if it is false, that means the player is behind the enemy, so we'll set the new rotation to zero. I hope the logic is making sense to you and then after that, we connect everything back to his shooting magic ball. Let's see that in action once again now that you have seen the nodes. So I am c the player is on the right side. The sprite is facing right. The player is on the left side, the sprite is facing to the correct direction constantly, which is very good. Now that this is done, let's move on and make some more adjustments to our ranged NEM AI. 82. 80 Adding Sprite To The Magic Ball: All right. So now, the enemy actually throws an actual magic ball. We'll correct the direction in the next video, but you can see the enemy throwing a ball and let me take you through the very simple steps to set that up. To start off, you simply go into the enemy projectile and you can delete the initial sphere. Once that's done, add in a paper flip book, something that you have done multiple times before. I've also set this up to have its shadows casting, which I think is cool, and I've also added shadows to the ranged enemy besides that. Then inside of here, after you've added the paper flipbook, you'll notice that inside of the inside of the folder of the ranged enemy, there is a file called projectile. Now, inside projectile are one, two, three, four, five, six little sprites that are the projectile, and to extract the sprites, you apply paper two D texture settings to them and then go into extract sprites, and real will always try to extract automatically. But you want to set it up to grid, and cell width, instead of being 288, you just get 288 and you divide it by six, which should give you a cell width of 48. And notice now you can cleanly extract all of those six sprites. After extracting, simply get them and turn them into a flip book. And this is rolled on, no. Was the flip book, The book, and call the flipbook magic ball. Once that's done, you add that to the paper flipbook and Wala, you're fundamentally done adding in the actual fib of course, increase the, increase the scale to the right size that you want. And now that that fireball is set up, we are now going to go into the code for organizing its direction so that it's facing the direction, it is moving. Let's do that in the next video. Now, in case you're having trouble doing that simple setup, perhaps going back to some of the earlier videos will help you. This is somewhat of a knowledge check because this is an action that you should have done about five or six times already, and it should be in your blood. However, if you have fully understood how to do that, that means you're learning effectively from the tutorial, and I'm very happy about that. Let's move forward. 83. 81 Changine Direction Of The Magic Ball: Now that we have the sprite added to the magic ball, let's just adjust its direction. But before we do that, we're going to do a quick basic code cleanup, okay? So now, when it comes to the code for the enemy projectile, it has a lot going on. Let's just quickly organize it. So all of this code here is for Actor begin overlap. This is the code that manages the damage. We'll simply add a quick comment by pressing C. I like to set the phone size to 50. And then as always, black background white text. Now, we'll just going to add this here, expand it so that there's plenty of space. Excellent. Now, I'm going to drop these nodes down here right inside of the comment. So it is pretty clear what's going on. So this is beginning overlap of the sphere, casting to the hero and doing damage, and let's increase that damage from one back to 30 because it was only on one for basic testing. And on stop projectile movement, it destroys itself. This is good. It destroys itself. This is good. Now let's go over to the begin play node. Let's quickly get this comment. Put this Oh, my goodness, first of all, set the comment to just a comment so it's not moving our nodes around. And so reorganizing everything from begin play. All the way to the projectile movement. Let me speed this up. All right. So these nodes are now all organized in one place. No additional changes have been made. So what we are going to do is right after set velocity in local space, what we are going to do is we're going to set it up so that it points towards the direction of the player character once after it's done setting that. And this is what that looks like. There are two things that we want. The first thing is we want to get the actor location, okay? That's our current actor. And we just want to have its location available for us to reference. After getting the actor's location, the next thing we want to do is we want to get oh, sorry. We want to get its current velocity. These two are going to be important for choosing the direction the projectile is pointing to. Now, there is a new node we are going to reference, and that node is called the find look at rotation. Okay? This is the node we want. It is called the find Look at rotation. And what we want it to do is we want it to basically call out a rotation value for our projectile to look at. And in order for that to work, it needs a starting location and a target location. Now, the starting location is going to be the current actor location. However, the target, the target is going to be different. What we are going to do is we are going to add and we are going to add up the current velocity, and after adding up, we are going to add get the actor location. And the reason why is because the velocity is going to be pointing to the direction that the projectile is moving. And with those, we get the value of that and set that as the target. The target will be about one frame of movement ahead of the actor's starting location. Now, with that, we are going to find the rotation, and we are going to get the let's see, get paper flipbook, okay? So, oh, no, we don't even need that. What we need is just the flipbook, and then we are going to set rotation. Okay. So I want to set wild rotation, and that is going to be the node that we connect to. And then the Look rotation is going to be set as the new rotation. However, because of how unreal engine code works, if we run this by itself right now, it's not going to work effectively. And this is the reason why with everything as is, if we go into the developer level and press play, Oh, apologies. Let's first stop that simulation real quick. Okay, because it was trying to show us that, but we didn't want to see that. So if we press Play, notice there is no change. There is no change in how it's dealing with the direction, except, of course, yeah, there is no change. The reason why is because of how fast the calculation is done, we need this to happen after at least one frame. So to make this happen after at least one frame, what we are going to do is right after setting the velocity in local space, okay? Right after that node of set velocity in local space, we are going to set up a delay a delay, but there are different types of delay, and the delay we want is this one called delay until next Tech. So we shall simply delay until next tech. Then once that's done, it will go through the rest of the nodes to set the rotation of the paper flipbook. Now let's try it out. Okay. Now it's working correctly. Notice that the direction is being properly calculated. Now, you might ask, but hold on. It's looking kind of flippy. Why is it? Like, vertically, it seems the direction is right, but everything is wrong. That's actually really simple. We simply go back into the enemy projectile. We go back into the viewport and notice this is the paper flipbook. So what we are going to do is we will get the paper flipbook itself, and we want to turn it around. And now that we've headed back, you'll notice that the projectile is facing to the left. So because it's facing to the left, we're going to make one little adjustment. So instead of adding the get actor location and the get velocity, we're going to switch it up, and we're going to set it to subtract. So we want to subtract the actor location. Rather, we want to subtract the velocity from the actor location and set that up as the target. Now with that setup, this way, let's go back in and see if it's working as intended. So let's hit play yes, now it's working as intended. Notice the little magic ball is actually going in the correct direction. That's pretty cool. And now that we have that, notice that it is actually moving basically in the correct direction. Okay. Nice. Look at that. Okay, so now we have our magic fireball moving. In the correct direction. Look at that. Okay. That's done. Now let's move forward and make some additional adjustments to the AI of the ranged enemy. 84. 82 Setting Up Hit And Death Animation Combo: So to really round out and finalize that ranged enemy, let's adjust it so that when I'm hitting the ranged EM or any of the players really, it goes into a nice basic at stater animation, and then it dies. And then notice that we have those projectiles being spawned into the world, but they are kind of going on for infinity unless they hit the player. So we're going to put in a timer to prevent them from staying alive forever. Let's do those two things right now. First, we'll start with the enemy projectile and we'll set it up so that after cast failed, there will be a delay, and that delay is going to last for, let's say, 6 seconds, and then it will destroy the actor. So the projectile can only stay on screen for about 6 seconds before it gets completely removed from the world. Okay? That's done. Now let's go over right into the ranged enemy, and let's open up, go back into the fold of the ranged enemy, go back into art, and you'll notice that there is a sprite called hart double clicking on it shows that there's this little heart animation over here when it takes damage. That's cool. Then there is another one called death now notice that death and art have a lot of similarities. So we want to set up the code in a very similar way we did before. So there's a damage animation, but if the health drops below zero or equal to zero, it finishes playing out the death animation. Let's start by doing some basic sprite extraction. So I've selected Hart. And first of all, heart and death, let me quickly apply paper to de texture settings, and let's quickly save all. And then after that, start with art. And, sorry, right click Sprite Actions, extract Sprite. There are three sprites. Let's set it up as grid. So we shall do some basic calculation. Okay, so I really should just pin the calculator here. So we will get 375/3, which means that cell width is 125, and we extract those sprites. So there's heart zero, t one, and heart two. That's good. Then we'll select the death animations, okay, the death sprite actions, extract sprite. Let's set it up to grid. And now it is 875 or one, two, three or five, six, seven frames. Okay. So if we pull out our calculator and we get 875 and we divide it by seven, we get 125 again. So 125, we cut those sprites properly and extract. That's cool. Now, what we are going to do we'll select all of the death sprites, and then we're going to create a flipbook and we'll call it we'll call it, let's just call it death, okay. Let's call it ranged EM Underscore death. Okay. Now with that setup, so notice this is the death animation. What we are now going to do is let's first slow that down to about ten frames per second. Now, what we are going to do is we want to add another key frame. We'll drag it in. So let's see this is frame one. Frame two is empty, then frame Okay. So this is one and this is two. So inside of this empty frame over here, we are going to ins we are going to pick a new sprite, and we are going to look for, let's see, hurt, sprite one. That is that one, which has the white you know, white flash. So now that is how it takes damage. And then we shall add in another frame after and in that frame we're going to add in another animation. Let's pick a new sprite. So let's call pick heart zero. We'll use heart zero for that. So notice, it's just doing a quick flash anytime it takes damage, which is cool. Now, let's drop the frames per second from ten. Let's drop them down to nine. So let's play the animation out. Notice that. So it has that little flash when it takes damage, and that's the animation. Okay, let's stop right at that. So with that setup, we now have ranged enemy death animation ready to rock. So we shall simply go back to ranged enemy, go into animation. Let's open up the ranged enemy animation source. Add a new animation sequence. We are going to rename it death. Okay. And inside of death, we shall use the ranged enemy death as the animation. So we'll set that up as the animation. Now in the next lesson, let's add in the right notifies and the right events to have this playout correctly. 85. 83 Ranged Enemy Enters Hitstun on Taking Any Damage: Okay. So back into the animation sauce, okay? Notice that there are those frames when the enemy has taken a little bit of a hit. We do not want to go into the third frame of animation. So right at the end of the second animation, we'll add a notify. We'll call it a new notify, and we are going to call it ranged enemy heads stater. That's what we're going to call it. It's called ranged enemy headstand. Okay? Just ranged enemy heads stand. That's all it's going to be called. Okay. Now, once we have that setup, we now go into the ranged NEM blueprint and notice under notifies the ranged NM adster here. So we are going to be accessing the function here. So we'll go back into the ranged enemy. Instead of we'll just copy this specific comment box, okay, and paste it in and we're going to call this. No, forget the headstan. That's just for the sake of speed, let's just call this hits stater, that's the comment. But what we really want is we want to create a custom event. Yeah, okay? And this custom event is going to be called Range NEM hits stater. That's really what we want to call it. Just have that simple custom event ready. Now, with the event ready to go, let's now create a new variable. And we'll call this variable in headstar it is a basic Boolean and it is called in headstand. Now, right now, we'll quickly compile this. When the game starts, it is going to be empty. That's its default value. Now, what we will do is now that we have that headstand variable. When this ranged enemy headstand function is called, we just want it to do a quick check to see the enemy health. Let's go back. And now we'll say as ranged enemy, we want it to pull out the ranged enemy it stater function. This we have done multiple times, so it should make logical sense. Now that we have that, we know that every single time this animation plays out, right here, it's going to do a quick heads stater check. And what we want is if the headstand check comes out true that the player the enemy is dead, it plays out the full death animation. However, if the hits ends up being, you know, no, you're just in headstand, you're not yet dead, it goes back. To its idle animation for a short period of time. And then it goes back to its attack animation after detecting the player. That's the logic we are going for. So come back here. Let's quickly save all and go back into the ranged enemy. Here we just want to start by simply checking on the health value. The first thing we'll do is we're going to get the Dami health, drag it out here and we want to get Dami health, and we're going to set up a basic branch. And what we want to do is we want to check the Dami health on is it greater Okay. In other words, is it greater than zero? If the dammi health is greater than zero, this is going to be true. Okay. So if the dammi health is greater than zero, we set this up to true, and then we will simply perform some functions here. And to start with, we'll say, Okay, look, I dummy Health is less than basically, if it is less than zero, what we want to do is want to drag this out and then we want to say, Hey, no, rather, let me be clear that this logic is making sense. Okay. So if it is less than zero, what we truly want. Okay? No, if it is less than zero, in other words, it is false. We want there to be a delay of about 1 second, just a simple 1 second delay, and then immediately we destroy the actor. Okay? It's a simple check. It's a very simple check. And what that does is it means that the ranged enemy is now dead. So if we go back into the ranged enemy animation graph, notice that there is only idle and there is attack. But now, let's create a new animation state, and let's call that animation stat death. Okay. So from attack to death, it can transition, and from idle to death, it can transition. And the way that it can transition is, let's go in. We're going to have it check as the ranged enemy. We want to get hit Stern, right? And if in hits stater, is equal to, yes, it is in its stater. It can transition. Okay. So as long as the enemy is in its stan, it can transition. That's essentially it. And then we take a let's actually just copy this. So anytime the enemy is in any headstand, it starts playing the death animation. So let's copy and put that here. That saves that. We double click on death and we want to play the death animation from inside of the death node over here, okay, that little state. So it can go from idle to death and it can go from attack to death. However, it can only go from death back to idle in a situation whereby it's no longer in headstand, then it can go back to its idle animation, okay? That's essentially it for now. Now, this is what this looks like. Oh, it's not yet going back into idle. We'll get into that next. Now notice that right now in the ranged enemy, there is not yet anyway to get it back in rather, there's currently no way to give it the hits stater property. Let's change that up. So the way that we're going to do that is let's quickly get that comment box and put it up over here. Enter tt animation on any damage. Which is pretty easy to understand. So enter headstand animation on taking any damage. So we start by getting the event, any damage. Okay, we'll get the any damage event. And then we shall simply set in headstand and we'll set it up so that once it's in headstand, it sets in headstand to be correct. Now, with just that, we go back into the developer level. So it's taking damage. It's now playing that, but it's playing it indefinitely. So to stop it from playing, we go back in. And this time, when it does the basic double check and finds out that it is, in fact, its health is still greater than zero. What it's going to do is we want to set in headstand, so we will set it and we'll say no, it's no longer in headstand. So this is what that looks like. Notice that, right? So if you stop comboing the enemy, it immediately goes back, okay? That's essentially what we truly want. So let's come in here. So it throws a projectile. Now I'm hitting it. Okay. So it is actually taking damage, but notice it's not dying, and there is a bit of a delay. Rather, the delay before it attacks again is really too short. So let's suggest that in the next 86. 84 Setting Attack Delay After Taking A hit: All right. So now we have our nice range enemy that we can attack, and when we attack, it enters a bit of its stater and it can't attack us back. That's pretty cool. Let's make a simple adjustment so that once it's hit, it spends a lot more before going into its actual attack animation so that that its carries more weight with it. Now to do this, we really only need to open up one thing to start, which is going to be we'll go into the ranged enemy folder and make sure that the ranged enemy blueprint is open. And once it's open, now we can move forward and add in a bit more of a delay to the headstart. Now, the next thing we're going to do, you will notice when we go and do damage to the attack dummy while it is taking the damage, notice that the health bar is not working properly. The reason why that's happening is because once we called in the event any damage here, it stops being called in in the parent blueprint. So we're going to need to copy over all of the code of event any damage from the parent to make sure it's working correctly here. Now, the most speedy way of doing that is you want to open up your attack Dummy Blueprint and head over to the event any damage, and notice that we can come in and now make a copy of all of this and then put it into the child. Now, let me just show you what that looks like, and then I'll take you through the code. So, boom, there is a bit of headstand, and then it's dead. Voila. Now, this is what it fundamentally, actually looks like in the code. Actually, let's go back a bit, okay? So right now, the enemy is able to throw projectiles at me, okay? It's able to throw projectiles. Oh, snap. No. No. Window jack. However, once I smack it, now, notice it s for about 2 seconds, okay? That's the actual hit star. And for 2 seconds, can't do anything. Now, of course, that's exaggerated. In a real game, you want that time to be a bit shorter, but I'm exaggerating it just for teaching, okay? So the enemy rather the player character can smack an enemy only for the ranged enemy, and for a while, they totally cannot do anything and then they're dead. It's that simple, okay. It's that simple. Now, let me go into the code, and we're going to go in step by step. So we'll start off with the basic ranged enemy. Okay. So right here right now, okay, all you have is setting it up to go in headstand. But let's go through this step by step. So once we call the event any damage event here, now, it's no longer going to be working from the parent event. So we need to re add in all of this code. So let's start. There is a sequence. Let's signal everything up here for a bit. And follow this line. We get the dammi Health. Of course, we get that from inside the character. Okay. And once we have the dammi Health, what we will do is we shall subtract the damage from any damage from the dammi health and set that as the new dammi health. Once that's done, we want to cast to the dammi health bar. Now, the way we do that is we call up a widget. The widget is over here. We've already added it in. That's the health bar. We get widget and we cast to dammi Health bar. And then as the dammi health progress bar, we will get dammi Health, divide it by 100 and set that as the set percent, that is done. And all that does is it makes sure that when we hit the Dummy rather, when we hit this enemy, it actually shows up in its health bar. Okay, let's move on. Now that we have that Okay. Let's go back to the ranged enemy heads stater health check. Okay? This is where we are checking to see if the health is less than if the health is less than or greater than zero. Okay? That's the ranged enemy heads stater. Now, around here, what we want to do is there's going to be a 1 second delay, and then it destroys the actor. That's fine for now, okay. However, we want to set it up to be in headstan off. Is it shooting magic ball? No, it's not. Adding a quick delay of 2 seconds. And then we want to create a new variable called Cannot Shoot. Now, what's the purpose of Carnot shoot? We're going to get into Cannot shoot later, but just create that variable. And right now, Cannot shoot is set to off. That means after two second delay, cannot shoot will be off, which means it can shoot, okay? Now, let's go back into the ranged enemy animation. It's death animation. At the end of its death animation, we set it up to destroy itself. That is using a Notify. Okay? Now, inside of the ranged animation blueprint, it's simply set up so that if it's shooting the magic ball, it goes to attack. If it's not, it goes to idle. Won't have that set up, okay? And then from the attack to the death animation, that is, is it in headstand? Yes. If it's out of headstand, it can go back to attack, or if it's out of headstand, it can go back to idle or back from id, okay? This is basic logic. You've done this before. Now, let's head over to the destroy self. All that does is it leads to a function in the ranged enemy called destroy self. Now inside of the range enemy, essentially, we've set destroy self as a basic destroy actor. That's all it does. It destroys the actor if its hell goes below zero or hits zero. Okay. That's all it does. Now with this setup, on any damage, it's set to have its headstand on. It's no longer shooting the magic ball and it cannot shoot. Now let's see what that actually looks like codewise, okay? Now, let's go back to where the player is detected. There's one big change this time. Okay, we've added in, Is it in headstand? If it is in headstand, it should do nothing. I headstan is true, do nothing. If it's out of heads stater, then it should do the rest of this code. Of course, there is always the cast to hero, we've done that, the direction change. But after the direction change and setting wild rotation, we have added a new branch and the branch is pretty simple, cannot shoot. If it cannot shoot, it does nothing. If it can shoot, it shoots the magic ball. Now let's look and see what this actually looks like, okay? Going to set it to dbug I play. So right now, it can shoot, so it's shooting. However, okay, let me restart this. So once I hit it, it stand and cannot shoot for a bit. And you can adjust that to your liking. Now, if you followed along the tutorials properly, all of this has made clean logical sense. And now you have a working ranged enemy, and let's quickly go into male enemy to drag it into the world. Oh, I actually already have one here. It's an enemy that I've placed here. So I have a male enemy that comes and can attack me, but, of course, I can hit it and kill it, so it dies, and then we have a ranged enemy. Come moria. I and it ties. So we now have a ranged enemy and a male enemy ready to be used, and you have experienced how to use paper z d to set up these two enemies. So there's one more thing that we're going to do for the ranged enemy, and then we move forward. And that is going to be we'll go into the ranged enemy. We'll go to the widget of its health bar and we'll set it up to not be visible. And the reason we've done that is because we just want to clean up the look of our level. Okay? Okay. So now that their health bars are no longer visible in game, that's cool. Let's set that up for the mele enemy as well. I mean, with the widget. We don't need it health bar to be visible. That's good. Now that that's done. Okay. Develop a level. Voi a fini. Now that we're done with that, let's make another adjustment to the ranged enemy. Which is going to be, we're going to set it. They're actually two adjustments. The first one is we're going to make a slight adjustment to its velocity. And right now, it seems to be bumping up against the range enemy, which is something that we do not want to be true. So we want the melee enemy to be able to move and not interact with the ranged enemy at all in any way because right now it's getting attached to it, which is not what we want. And then we want to set it up so that the ranged enemy, once you reach a certain range, it stops throwing projectiles at you. We want it to only throw projectiles within a specified range. Okay? Let's do that. Next, 87. 85 How to Prevent your enemies from getting stuck on each other: So in this video, let's start with the basic simple problem. We have a melee enemy. Okay. So, come on, follow me. Follow me. Come on, come on, here. Okay. But once it gets to the ranged enemy, it gets stuck. So let's solve that problem, okay? Now, the way that we're going to solve that problem is we'll go into the Me NEM Blueprint. Okay. And we will select its capsule component because that's the one where most of that collision is happening, okay? Now we're going into details, and I want to search for its collision. Now, right now, it's set to block all dynamic, and let's change that to pastor. Now that it's in a custom state, notice that we can change its collision responses across the board. So what we'll do is we'll select pawn and we'll set it up to ignore, so it can be set to ignore, overlap or block, but we're simply going to set it up to completely ignore pawns in general, okay. Once that's done, we quickly compile. Now let's test it out quickly and see if it will actually get the job done. Okay? Okay. And there it is. So it completely now ignores, Oh, snap, I need to run. It now Okay, I died. But you can see that now it completely ignores the ranged enemy and it will no longer get stuck on it. Yeah, that's basically the solution. Let's move on. 88. 86 Creating An Attack Range For the Ranged enemy: Okay. Let me quickly show you the end result because the enemy was constantly attacking, but now it attacks the player. However, once I get out of a certain range, it stops attacking the player. When I get back in range, it starts attacking. And once I get out of that range, it immediately stops attacking the player. That's what we want. Now let me take you through the code step by step. So let's get into the ranged enemy. The very first thing that we're going to do is add in a big sphere. So this kind of sphere requires you to go into, of course, the capsule and add a sphere. I have set my sphere to about 20 units of radius. You can set it up as any radius you like. And I'm calling that sphere collision attack range. Once attack range is set up, simply add simply add two different events, okay? The first event is begin overlap and end overlap is the second. Once you have those two events created, let's go into the event graph. Now, the first thing we want to do is right before the player detection starts checking for head start, we want it to do a simple check under a new variable, which is a boolean, called in attack range. Basically, it holds whether or not the player is in attack range. So if it is true, it continues. If it is false, it does nothing. Now, when it comes to actually dealing with the attack range, let's start by looking at the two events. We have the component begin overlap event. And we have the component end overlap event. Now, that leads to two different things. They're both being casted to the hero because we only want the component to be the hero to cause this. And now, if it has begun the overlap, it will set in attack range to true. If it is ending the overlap, it sets in attack range to off, and then just for visual clarity. It shows if it's in attack range, it shows in attack range. Once it is out of attack range, it will print safe, and it will set is shooting magic ball will be off to stop the ranged enemy from shooting the ball. Let's see it in real time. Now I have entered attack range. I'm now safe. I am in attack range. I am now safe. But now although the attack range is there, now we go into the sensing range, okay? Because this also has the paw sensing that actually causes the attacks. So now that I'm in attack range, I hit the pawn sensing and it starts attacking me. But when I leave, I'm now safe, and it stops attacking me and throwing projectiles at me. That is the simple logic used to create an attack range around the ranged enemy and then using the sensing to manage the throwing of projectiles towards the player. 89. 87 A look at the level: All right. So now that we are done, working on these AIs, let's actually put them inside of a level. Let's go back into levels and now that we are done with some work in the developer level, let's go into level one. Now, this is our current level one, and we're going to do a bit more level design because this level was set to be very opened up. Let's compress it so that it takes up a much smaller area and doing so is actually quite simple. We'll get these two objects at the level start and move them here. Okay, much, much better with just this change. And then we have our player character. So right now, this is from the level start. Oh, there's something else we didn't add. So there's this little block that I added into the level. Okay, I'm dragging it here. Drag it right over here. It basically prevents the player from fully going up the stairs, just a block. And now we have these little steps the player can step on and please make sure, that inside of the mega scans asset, if you have used a mega scan asset, that to make sure the collision works correctly, make sure to look for the collision settings in it, and you want to make sure it's set to use complex collision as simple in order to guarantee that the player can actually step on it correctly. Now that we have that, let's see, we have the player starting from here. We'll have them come in, and then they'll start off by fighting a single melee enemy. Then after that, they'll move forward and there'll be a ranged enemy up there, and then there's going to be one more melee enemy that they need to fight, and then ranged enemy. And once they're done, they climb up the stairs and there's going to be a boss character up here, okay? Now let's do some basic additional level design. I'm getting that and copying it. The reason why I'm doing that is because I want to, let's see, Okay, this won't be good enough for me. What we're going to do is we're going to add in a shape, and you may wonder which shape, we just want a simple cube. Let's scale it. Let's unlock the scaling. I think scale of 50 on the X, ten on the Y and then 50 on the horizontal. Okay? So now we have this huge shadow cast, and then I'll select that block. I won't set it to rotation. I'll set it to movement. Let's move it forward this way. Nice. So now it's casting this huge big shadow over there. Let me move the camera forward this way and just want to adjust that shadow just a bit. Okay? This is like actual cheating in game development, okay? Using an artificial object to cast a shadow. So now there's that shadow, which I think makes it look much better. So now when you jump over, coming over here, you'll have some enemies to fight. And then once the enemies have been fought, you move forward, and then you climb up the stairs, and in this shadowy area is where the boss is going to be fought. This is perfect. But now, you'll notice that our sprite material is not responding to light. So let's adjust it so that it can actually respond to light, and we can see clearly when the player has entered the shadow area. Let's do that in the next video. And then we'll do some level design, drop in a couple of characters, and then we will call the Tutorial a wrap after I have showed you the final exercise, which is going to be creating a boss enemy. Let's go. 90. 88 Making Player Sprite React To Light: Okay, so I've put the player right around the area which is being caused by that little object over there because right now, when the players in shadow, they look late. When the player is in light, they look late. So we can make a simple adjustment to cause it to react to light. So first things first, go into settings and make sure that show engine content and show plug in content are both selected. What that's going to do is it's going to expose Unreal Engine to all of its engine and plug in content. That's the reason why we're doing that is because we are going to go into the player and then we're going to select the paper flip book and notice that its current material is set to the masked unlit sprite material, and we want to change that up to the masked lit sprite material, which is going to open up our sprite to receiving light. So let's go into level one, hit play. I notice that now our sprite is accepting light and it's reacting to it. Is color changes based off the bounce lighting around it. Literally, when the cape is out of light, you can see that that's pretty cool. And now, whenever the player character moves into a dark area, you can see the darkness around it. That's cool. But now that we've done that, let's add a little bit of light to the character so that they always have something that is shining light. Now, to do that, we simply go into the hero, select the capsule component. And what we want to do is we want to add light. Okay, we'll start off with a basic point light. Let's drag it out here. And over here. Now, the character will always carry around a little light with them. Move it towards the character. Let's see what that looks like. Notice here, it's a bit too bright, it's shining on everything. But when the player character is now in a dark area, they still have a light on them. We can come in. Raise up its position and move it farther back to soften it up just a bit, and then now much better not visible in light areas. But once you go into a dark area, there's just a little bit of light being put on the player character that's really helping them look a bit more y in the scene. Okay. Now, you can make all kinds of adjustments to the lighting. You can change its positioning, you can change where it is. It all comes down to you, but that's just a cool way to add some life to your sprite. 91. 89 General Touches For The Level: All right. So let me quickly just do some gentle, slow level designing. So I have added in another platform here, added this here. Okay, so let's quickly see. Can the player reach that platform? Yes, the player can reach that platform. That's good. Let me opy and paste that. Make sure that these two snap together correctly. Can the player jump on this platform and then this excellent. Now, make sure that it's a bit of a challenge. It's always good to put arranged enemy in a place which is difficult for the player to reach. Let me raise up its position just a bit. Let's see. Eat it and it's nice. Now that that ranged enemy is up there, I'm over here and put in, hold on, let me make sure it's position is negative one, negative 20. Now that's one ranged enemy. I'll put another ranged enemy right over here. Negative one on the positioning, good. Then I'm going to put a melee neem over. This is the next phase of game development. When you're done with your planning, you're going to do your code art and animation and then audio. That's going to make individual components, but individual components don't really make the game this enemy the player character, the levels. What really makes a game is when these components are put together in a way to interact with each other. Oh, sorry about that. Notice that it's struggling to move, why? Because it's missing navigation. Let's quickly add let's see, a big nerve mesh bounds volume. Let me increase its size to be about 20 here, excellent, and then increase its height to be about 20. That's too deep. No, I don't need a lot of width. Let's set that to about ten. Good and then move it over all of these different characters. Okay. Now, as far as its height, drop it down to the ground to begin with, but then significantly buffets height to, let's say, 20, so that it's able to look at these navigation areas. Okay, 20 is reasonable. Maybe we can go a bit higher. Let's make that 30. Good. There is this navigation bounds, increase its width a bit, increase its length about 30. I think 30 is just about right for here. Then since this blocks the car enemy, that's good enough. Then we'll copy that bounds volume to create a second bounds volume. And that bound volume will just scale its width down because this next one is only going to hold. I don't want it to reach up to the stairs. Here we are perfect and then copy that and paste it into the world, and here. This next bounds volume needs to be even smaller because all it needs to do is manage the arena over here. Nice. So our enemies are able to move on all those areas. Next, I'll drop another male enemy in over here. That is two, of course. And Valla we have the makings of a very basic level. Hey. Now, our enemies are actually able to chase us properly. That one's dead. Nice. Now we come up here, we're being thrown magical balls. Hey, hey, you die, you die. That one's also dead. And now, die die two, and now that that's done, we move on triumphantly. Now notice that this sprite material is not late, so we're going to make some adjustments just to that sprite material. So we shall select the ranged enemy, go into Viewport, select the paper flip book and adjust it to the late sprite material. And then we're going to add a point light to it. Okay. Actually, let's bring it in here. Kind of here. That's okay. And then we're going to quickly adjust the lights color to be green. Oh, that's green. Perfect. And then we're going to now that we've adjusted that light to be green, the next thing we're going to do is we're going to shrink the radius. Let's see. We're going to drop its attenuation radius right down. No 200. Let's do 150. 150 isn't enough, 100. Nice. Now, that's a nice little attenuation radius right there. That's good. Now with that, we'll go back to the level. And this time, I think, let me get the player character and move him way over here so that we can quickly get to the action, kill this dude. Nice, come over here. Now look at that. Oh, but we have a problem. So right now in the range enemy, the spotlight is under the flip book, so it's being flipped around. So now let's connect it to the capsule component so that it doesn't flip around. Okay. Bye bye. Now it is late and it has that little green glow. But we can always adjust the position of the green glow. We can put it closer to the feet and back it out just a tad. Just a bit. We can drop its intensity to 2,500 and then increase its attenuation radius a bit and then drop its intensity again to 1,500. Now with that, let's have a look at how it looks in gain. Please die. I attack you, bye bye. Now it's looking okay, but it's a bit too close to the ground now. We have but that's cool. It's still cold to see that. Let's increase it up a bit. Back here, and then raise it up a bit further. That should be fine. The next thing we're going to do is in the ranged EM, let's open that projectile, and then we're going to add in a light a light, LIGHT, a point light. Okay. Going to drag it out over here. And then, of course, light color is going to be green that nice green. And then attenuation radius will drop it down to about 1:50. 150 is too much. Let's make it 100 and see if this on which one is the sphere? Okay. So now let's look at how the projectiles look. By at me a projectile? Yes, the projectiles now have a nice little light that moves with them. It's just a gentle touch. Keep in mind, of course, you can Oh, my God. Die, die, die, die. Okay, you're gone. Now, all of this is just to show you some little touches. This is without even adding in your own custom audio or the heat effects and the damage. Now it's time for me in the next video, I'm going to give you your final test, which is going to be to create a boss EM. With everything you've learned, it should all come together. 92. 90 Make A Boss Enemy As Your Final Practise: Now that you have gone about learning everything I have to teach you on the fundamentals of 2.5 d development, you are now ready for your final practice. Now, what you will do on this area or whatever area you have designated for your boss character is you're going to create a boss enemy, and this is your final practice test before you move forward creating your own game projects. Now, the animations that you're going to use for that project are all going to be found in a simple free template on each dot IO called Demon slime and it has a lot of different animations from starting off as a little blob to when it can rise up as a fully matured boss character. It has an attack animation, it has a stop and it has flames as well as casting a spell. Now, the link for this is going to be included with the course. Now, once you have that and you've imported it, you now have all the knowledge you need to create a simple boss. As a simple illustration of what you could do is you could have the boss coming and attacking the player. That's a simplified example, okay? And then you can do other things, like, for example, hit so that once the boss has been attacked to a certain level, it spawns in arranged enemy. Now, hopefully I can get this in one try. It's damaged me. Game over. Okay. So that's a simple example. Now, there are many ways to design boss AI, but one quick tip I would give you is this one is set up with two different phases. In the first phase, all it does is it does a melee attack when in range. In the second phase, it spawns in a single ranged enemy that's meant to attack the player. That's just a simple set of examples to what you could do to be creative. If you add in the stump, you could make it so that in phase one, it randomly selects between a melee attack and the stump or casting a spell can be called as an animation before it brings in that ranged enemy. There are many ways to create a boss. I can only make recommendations. It is up to you as a game developer to create things for yourself. With that final practice exercise, I want to thank you for completing the 2.5 d game development course. I hope you've learned a lot to move you forward in game development. Remember to always think through, plan before you execute. And finally, really remember that planning things out is really overpowered, okay? Planning is okay. So don't be afraid as a game developer to just write stuff down and use that as your guide. And my last simple tip is for the sake of simplifying how you like to develop games. Always start with a generalized design, then move on to the code and then lastly rather after that art. And then, lastly, audio for whatever it is that you are doing for your game. Till the next time we meet, I am hyper dev and in case of any questions, can send me a message, but I hope you've learned a lot from this course. Otherwise, go out and don't forget your dream game isn't going to build itself. I bid you well.