 Game development is now more accessible than ever before, thanks to powerful game engines such as Unreal Engine being freely available to anyone to make their own games, but learning a huge piece of software like Unreal Engine can be really, really daunting, especially if it's your first time. But don't worry, I'm here to help you out. Welcome to Game Dev Academy, I'm Shane and in this tutorial video I'm going to show you how to create the game you can see on screen right now. Over the course of this project you'll learn to use the blueprint visual scripting language that makes game development so accessible in Unreal Engine, as well as how to include art assets, sound, how to use destructables, physics or manner of crazy stuff. So if that sounds good to you and you're ready to create your first game, then just hang on a sec and we'll get stuck in. OK then, let's make a start on this project and the first place we need to be is in this new project area of Unreal Engine. Here it is. And as always you've got the choice of the different types of projects you could choose, but for this one, because I want to really focus on doing everything ourselves, we're going to start with a blank project so we've got no code waiting for us, we're going to have to create everything ourselves. I also want to do something a little bit different, so we're not going to do desktop console for this one, we'll get it ready for mobile tablet, because this is going to be when it's finished, have a touch input for it, then mobile or tablet is a good fit. We don't want maximum quality, we'll go scalable 3D or 2D, again because we're aiming at mobile platforms, better to keep the quality in check and we're not going to have any starter content. You can bring that in later if you want to, there are ways of doing that, but for now we're going to go with no starter content because it'll help to keep the package size down when we're finished. And then the last thing I'll do, which you need to do as well, is give the project a name and decide where you want to save it to. And I decided to save mine into my shared files, so if you want to get access to the assets and to the project as I'm building it, you can use the link in the video description and I'm calling mine breakout tutorial and then we can create a project. So when a meal engine opens up, you'll be greeted with this sort of default level that it creates for you, but as I want to make sure we're going to build everything ourselves, we're going to create a new level with nothing in it at all. So to do that, we'll go up to file. We're going to choose new level and we're going to do an empty level. There it is. And then the first thing I'm going to do is save this level into a levels folder. So I'm going to right click in my content browser. I'm going to choose to make a new folder. I'm just going to call that levels. And then I'm going to call this level so file save current as I'm going to put it in the levels folder and I'm just going to call it level one and we'll click on save. The next thing I want to do as part of setting up is make it so that every time we open this project, a meal engine will take us to this new level. We don't want to go back to that weird default one. We want it to know exactly which level it should open in. So that's what we'll do now. So in order to do that, we're going to go to edit and project settings and that opens this window here and we need to click on the maps and modes section under project. So you can see that by default, the editor startup map is this template default, which we don't want. So we're going to click on the drop down box there and there is our level one that we've saved. So we'll do that there. And then whenever we start the game, we want this one here, the game default map to be level one as well. So that means that now whenever we open the game, or the editor will take us to the correct level. Okay, so now that that's done, we can close the project settings just for now. And the next thing I want to do to wrap up this step is to bring in and check the collisions on the measures that we'll be using to get the first part of this exercise set up. So I'm just going to create a new folder for that. I will call it static measures, then open that folder up, and then we can choose to import. Okay, so at this stage, you can bring in your own assets, or you can use mine using the link in the description. So if we go to the shared folder that I'm working in, there is a breakout assets folder. And there'll be more assets put in this as the tutorial matures as it as we get further through it. But for now, we only need these four measures. So we get a ball, a block, what I'm calling bounds, which is kind of what the the ball is going to bounce off as it goes through the play field. And also a paddle, which is the thing at the bottom that knocks the ball around. So we're going to import all of those. So I'll click on open. And then it's going to ask us some questions about them. How would we like to import them? So I'm going to let it auto generate collision, although there are collisions included, which so we'll have a look at that in a sec. The the import scale should be right. So I'm going to leave that alone. And what I don't want to do for this one, I don't want to really mess things up. I don't want to import the materials, or the textures. When it comes to materials and textures will create our own within Unreal Engine. So when that's done, we can just click on import all and it will do that for all four measures with the same settings. Here we go. So you can see now we've got the ball, the block, the paddle, and the gamebounds as well. So what I want to do now finally, is just make sure that the collisions are set up properly. Or if I'm not happy with them, I'll change them myself. So we'll start with the ball. So I'm going to double click on this. And this opens it up in the static mesh editor. And for a game like this, as we're going to set this prototype or physics and collisions and getting it to bounce around, all that stuff's really important. So we need to get it right. So what I'll do is this collision thing here, we'll be using simple collision. You can't use complex collisions for the type of thing we're doing. It has to be simple. So that's got to be right. And if we zoom in, you can see that this green thing here represents the collision. And while that's a good attempt, it's not good enough. So I'm going to put in a new collision mesh for this one. So if I click on collision here, we can remove that collision because it's rubbish. And we're going to click on collision again, and we're going to add a sphere simplified collision. And what's good about this is you can see it just fits perfectly. You can just see it poking out of the mesh a little bit. So that now will be perfect for what we need because it's the right shape and it fits the ball exactly. So we can click on save there. Now we just need to check the other three. So let's have a look at block. We'll turn on the simple collision. That's perfect. You can see that that fits exactly. So we'll save that. And you'll notice we've got a little asterisk next to the file name. And that's because it's not been saved yet. So we just need to click on save. That goes away. And then let's say the project crashes or something like that. When we reopen it, the asset will be there because it's now been saved. So let's check the game bounds. Okay. And we will just check the simple collision on those. And that's pretty good. So I've got a custom collision that I put on this. So it doesn't fit the outside exactly. You can see it just fits in here. And if we go over here, I did also try some funky stuff here, which I may take out the one you download might not have that in it anymore, because it's not necessary. But to get the collisions in the way I wanted it, I had to put custom collisions in like this. So that's working fine. As long as you can see something like that maybe without these cylinders, though, because they're not necessarily needed. But that one's okay. So we'll save that. And the final one should be working is the panel. Yep. And we can see that that collision mesh just fits that perfectly. So we can save all four of those. And we'll close the static mesh editors. Goodbye static mesh editors. Awesome. Okay, that brings us to the end of the first step. In the next step, what we'll be doing is setting up our input so we can control how the game is controlled. So I put some keyboard controls in just to get things up and running. We'll also be getting the screen size correct so that we've got kind of a mobile phone template so that everything works to get the right orientation. And we'll also be setting up a game mode and having to look at what a game mode is because that's kind of important. The first thing we'll do in this step then is get the input set up for our project, which will allow us to interact with the game using the keyboard. So in order to do that, we need to go to edit. We're going to go into the project settings, first of all, which gives us this beautiful window here. And the place that we need to go to is just here, which is input. And the section we're concerned with at the moment is the action mappings and the access mapping. So we'll start with the actions. And what we're going to need is some way to get the ball to go into play in the first place. So we're going to add an action mapping for this. We'll just drop that down. And the first thing we'll ask us to do is to give it a name. So I'm just going to call it fire since we'll be firing the ball. And then once I press enter to save that name, it asks me what key or keys I want to attach to that action. So in the first place we're going to be going around the WASD keys. So I'm going to add the W key for this, which is just here. But then I want to add a couple more so that we can play the game in different ways. So I'm going to click the plus icon here. And I also want it so we can play on the arrow keys. So I'm going to add the up arrow key to that. So if we just go to search, if we type up, there it is. So we've got the up option there. And just because it's a nice big key, I think we'll add the space bar as well. So we'll go plus one more time. And if I start typing space, there's space bar. So now all three of these buttons will trigger the fire action. We also need to be able to get the paddle to move left and right. And in order to do that we're going to add an axis mapping. So we'll click on plus again and we'll drop this down. And I'm going to call this one horizontal movement. Yep, I spelled it right. Well done. So for this one we're going to have it on the A and D keys to go left and right. So we're going to add the A key which will be in here somewhere. There it is. And we're also going to add the D key which is just there. And then we're going to add the left arrow and the right arrow as well. There it is. So that's how I'm going to control the paddle going side to side. At the moment though we need to change these. So D and right are okay because they're going to go to the right which is correct. But we need A and left to do the opposite of that. So instead of having one on the scale we're going to have minus one on both of those values. So that's our action mapping setup. The next thing we need to do is make sure that we are developing for kind of a phone screen sort of size. So we can close the project settings for now and in order to get the phone screen sort of size we're going to go into the editor preferences. And I'm going to go to play this play section here. And here you can see you've got common window sizes and within that you've got phones and lots of different phones you can choose. So most of these are quite high end but because I want it to fit on screen quite easily I'm just going to aim for the Samsung Galaxy S4 which will be something like that. And to test that out if we just go to play here and we go to a new editor window it will open this up and that gives us an idea of how our screen is going to look. So that's kind of your standard Galaxy S4 screen but I actually want my screen size slightly different to that. So instead of 360 by 640 I just prefer 480. By 640 you can have either or it might just change how you set up your level. So happy with that you can if you want change between landscape and portrait using that button as well which is pretty useful but we're going to be doing it in portrait mode. And the last thing I want to do for this step we can just close the editor preferences is to create a game mode which we not be using just yet but it'll be ready for when we are. So I'm going to go into my content folder back up to the top. I'm going to create a new folder to keep it all organized and I'm going to call this my blueprints folder. Okay like that and within here I'm going to create a new blueprint so I'm going to go right click a new blueprint class and I'm going to choose a game mode. And the first thing I'll ask you to do is to give that game mode a name. So I'm going to call it BO that's for breakout not body odor. BO game mode. And you should notice that I'm not putting any spaces in any of my names. I'm just capitalizing the first word as is the convention. So that's set up and ready to go. And what I want to do now is make sure that this is the game mode that's being used when the game starts. And to get that to happen I'm just going to go save all. You've got a little asterisk here so I'm just going to do save all to make sure that's saved. Go into my world settings and you can see here there's this game mode override section. And if I choose my new game mode from here BO game mode that will be set up and ready to go. So that brings us to the end of what I wanted to cover in this step. In the next one what we'll be doing is blocking out our level. So we're going to put some of the blocks in. We're going to put the ball in place and the paddling place. Get an idea of scale. Get the bounds in so that we've got an idea going forward. Make sure it all fits within the phone screen as well. So hopefully I'll see you in the next step for that. Ah hello again. Right in this step what we're going to do is get the level blocked out basically. We'll create a simple material. We'll get a camera in place. So we've got an idea visually of how this is going to work. So the first thing I'm going to do to get this layout is I'm going to change to from my perspective view to this top orthographic view. An orthographic views are great because they don't show perspective. So they're really good for lining things up. You can see here is the center of our world known as the origin or zero zero zero. And what I'm going to do is go into my static measures folder and the paddles kind of going to be the center of the world. The most important thing for me. So I'm going to drop that in here. I'm going to just zoom in a touch. There we go. There's the paddle. And what I'll do to make sure that I get that to zero zero zero is I'm just going to use these properties here. So zero zero zero. And that's now in place. And what I'll do is line everything else up in relation to that. So we'll get the ball. And we're going to put that at zero on x. And we're just going to move it up a little bit on y. Looking nice. Then we'll get the game bounds in place. So I'm just going to throw that in and we're going to put it at zero on x for now and zero on y. And then we're just going to move it over until it's kind of central. One two three four five six seven. So yeah it's about seven on either side. That's about central. So now I've got almost everything. The last thing we need is to get some blocks in place. So I'm just going to throw it in there. And let's just get it central like so. And then we're just going to move it up and get it into place. So let's take it up near the top. And I'm just going to put this one in the center about as high up as I want to go which is about there. And then I'm going to duplicate these. And the easiest way to do this or the fastest way is if you hold alt on your keyboard and then move it it will actually create a copy of it and move it down. So I'll put that kind of gap in there. We'll repeat the gap again and we'll do one more while I have four rows of them for now. And then what I want to do is duplicate these over. And I could just select all four like this by holding shift and duplicate them all together. Or a nitty little trick which I learned today is if you hold shift and alt and then that'll give you a marquee selection and you can select all four like that. And then what I'll do is I'll go like that and hold alt again as I copy. And I'm just going to put the same sort of gap in each time. And then we're going to hold shift and alt again. I'm going to select all of those and hold alt and just duplicate these over to that side. So that gives me my blocks that I can aim at. So now we can come out of this orthographic view. Let's just see what it looks like. Yeah pretty nice I'm happy with that. So let's go back to perspective. And at this stage we'll realize that we can't see anything. That's because there's no lights in this because we started from scratch. So there's a couple of things we can do to remedy that. I'm just going to change it to unlit. And that will at least allow me to see where everything is. And what I'll do is a more permanent solution is I'll just create a material that's emissive so that we won't need any lights for now. So as you can see I've already created a materials folder. You should do the same. I would show you me creating it but it won't let me delete the one I created earlier. Webbs I'm not upset about it but make sure you've got materials folder. And then in there we'll create a new material. So right click and we'll go material. I'm going to call it em underscore basic. It's just a basic material. So we'll double click on that bad boy to get it open. Hello there. And all's we need is a vector parameter. And the way I'm going to get that is I'm going to press three on my keyboard and left click. And that will give me a vector constant or a constant three vector rather. And then to make that a parameter I'll just right click and convert to parameter. And I'm going to call the parameter color. And then I'm going to connect that to both the base color and the emissive color. And I'm going to make the parameter white. Like so. Beautiful. Okay that's done. We can save it. Awesome. And now that's saved I can just close it and I'm going to go into my static measures folder. And I need to apply that material to each one of these measures. So we'll start with the ball and we'll add em underscore basic save. And you can see now things starting to happen. So we'll do it to the blocks as well. So let's assign the basic material there. Save. Lovely. And the game bounds. And save again. And finally the paddle. Yes. Save. Okay so they're all done. Let's just check. Yep. Looking good. So we can just close all these static mesh editors. So that I don't slow my computer down too much. And now what I want to do is put a camera in the level so we can get an idea of the layout. So we'll go over into our modes panel here. And I'm just going to search for camera. And I just want the basic camera. So I'm just going to throw that in anywhere. Doesn't matter where I put it because I'm going to set it to zero zero zero. Like so. So that just puts it in the centre of the world. And one of the cool things this does is it creates why you've got it selected. So there it is. Why you've got it selected it shows you what that camera can see. And what I want to do is pin that. So when I deselect it it will stay there. So I'll always know what the camera can see which is very useful. And then I'm going to press F on my keyboard just to frame it up so I can see what I'm working with for now. And I can see that it's facing the wrong way. So I'm going to press E to turn on my rotate tool and point it that way. And then I'm also just going to lift it up a little bit and point it down. I don't know what angle I want yet. We'll see what we got. And before I can line this up really what I'm going to need to do is get the preview right. So you can see that this camera is too wide. It doesn't match the sort of dimensions of a phone screen that we set it to. So we need to do that. And what we can do is hear this aspect ratio. We can put in the width of the camera and that will sort that out. So we went for 480. So I'll tap that in space x and then 640 and press enter. And you can see that now looks a lot more like the phone screen that we're going for. So you can decide what kind of angle you want this to be at. So I'm going to go just turn my move tool back on a little bit higher. And one thing I'm going to do as well is change my field of view. And because I'm redoing this I did find that last time I preferred a field of view of 55. So I'll go with that again. And then what I want to do is just get this set up so that I'm happy with it. So let's just move it back a bit. And I'm just using this view here just to guide where I want it. So I'm going to go a little bit higher, a little bit further back. And that's pretty good. So that gives me an idea of how my game's going to look. What I'll also do to check this is just click on play. And I would like to get an idea of how it looks in here. But as you can see that's just not right. Why did that window just go? Come back here window. So you can see I can move around in here but it's not, not what I'm looking for. So we need to make it so that when we start the game it's using the camera that we just put in there. So we go to the camera again. I'm going to scroll down and we're looking for auto activate for player. I'm just going to set that to player zero. And then when the game starts it knows that we want to use that camera. So let's click on play again. There we go. So possibly we've got a little bit too much black space at the bottom. So what I might do is just move that up a bit to about there. And then let's have another look. Yeah that's much better. So by the time we've got the the cliffs going up here and we've got, we'll put a castle in there it should look pretty good. I might tweak the the camera angle and position as we go but that's just to get it set up for now. Okay so that does it for this step. In the next step we're going to set about getting this actually playable start moving things around creating some actual kind of code do some scripting. So I look forward to seeing your beautiful little faces in that one. Okay here we go. So let's start turning this into an actual game. And the first thing we need to do is get the paddle working. So we need to get it moving left to right so it can hit the ball into the play field. And what we're going to do is create a pawn for that which is a type of blueprint and that's going to act as our player. That's the thing that the player will control. So we have a blueprints folder which is where the game mode is. So let's open that up. I'm going to create a new blueprint in that folder. So I'll right click in there and I'm going to open blueprint class. And the one that I want is a pawn for this particular part. So I'm going to call it player paddle like so and then we need to open this up. I'll just dock it alongside my level there. Now that that's open what I also want to do is go into the game mode and make it so that the game mode realises this is the player we want to use. So let's just go here and open the game mode quickly. I'll just make sure this is saved first. And then here I'm looking for the default pawn class and it's currently set to default pawn. But we want this to be our player paddle pawn instead. And that's all we need to change there just so that when we start the game it knows what we want it to use. So we'll compile that save it and close it for now. So back to our player paddle what we need to do now is get the paddle in here. So this little sphere here is just like a null actor it's the it represents a default scene root I believe. So it actually doesn't do anything we won't see it in game so we can ignore it. What we want to do though is put the paddle in so we're going to go up here to add component and we'll just give it a click and what we want is a static mesh. There it is I started searching for a static mesh popped up and what that will do is put our static mesh here. So I'm just going to call it paddle for now. And then we actually need to tell this static mesh component that we want it to be the paddle. So over here in our details panel is where it's asking us what static mesh we want to use. So from our list of meshes we've imported so far we can choose paddle. And that will just drop in there. That's pretty good so far. Then there are a few things that we need to do to the static mesh to the paddle to make sure that it works. So the bowl bouncing around is going to be based on physics the physics system in Unreal Engine. So we need to make sure that this is set to simulate physics. So in the details here if we go not too far down there's a physics section and I'm just going to tick the box yes I would like this to simulate physics so that when something hits it it's likely to bounce off. What I also need to do which is very important is make sure that this doesn't respond to gravity because we want this to be kind of hovering in midair if we turn gravity on it'll just fall. So we're going to disable this thing here for disabled gravity we'll disable it so take the tick out of the box so far so good. And the last thing I want to do is just increase what's called linear damping and what that does is kind of acts against if when we start it moving that stops it moving too freely and that's something we'll need to get the paddle to stop again. So I'm just going to set that to 20 for now. That's a nice number. And then there's one final thing that I want to do to make sure that we don't get on any unexpected movement out of the paddle. And that's to lock some of the constraints. So we only want it to move side to side which in this case is the x-axis and we don't want it to rotate at all. So we're going to lock everything that isn't just moving on the x-axis. So here we've got a constraint section so we're going to lock position on the y and z axes and we're going to lock rotation on x, y and z so it won't do anything we don't want it to. And that'll do it in here for now so I'm just going to compile this blueprint and save it. Now it's time to do some actual scripting. So whenever you're doing some scripting on a blueprint in Unreal Engine each blueprint has got its own event graph which is where the scripting happens. So we'll open that and you'll see there are three nodes there ready for you. So we can have it do something as soon as the game begins or when it overlaps with something or every tick which is kind of every frame every CPU cycle. But that's actually not what we want in this case. So I'm just going to delete all three of those so we can put in just what we want. I don't want this to be any messier than it needs to be. And we're referencing the horizontal movement which we created in the input section earlier. So if we just start typing input axis so then it brings up this axis event and there's the horizontal movement that we created earlier. So that's what we're going to do and what will come out of this is an axis value which can be anywhere between minus one and one which is what again what we set in the inputs earlier. So we need to be aware of that because we're going to have to do some multiplication with it. I'm going to use that to add an impulse to the paddle. So we need to add an impulse node. So I'm going to right click again and I'm going to search for add impulse and you'll see that this comes up and it also puts in brackets pad up. So I know what I'll actually be adding this impulse to. So I'm just going to put these either side of my screen. I'm just going to move the paddle down. I'm going to try and keep this as neat as possible because these can get like really it's like messing with spaghetti when it gets complicated which we don't want. So we've got an impulse there and that's what's going to add to the paddle. And what we need to do to get something to move in a direction it's known as a vector. So out of here the axis value we need to make that become a vector. So I'm just going to drag out of here and search for make vector if I can spell it. There it is and that will return a value and that's currently just happening on x which is what we want it to be doing and then what that will do is it's going to put a value. So let's say we press the right key that's going to make x a value of one because it's coming from the axis value and that's going to be something that will be returned here. But that's not actually going to be strong enough. If it's just moving one it's hardly going to move this at all. We're going to need much bigger numbers. So for that reason we're going to need to multiply this value here by something else. So that's something else is going to be what's called a variable and that's something that we can set a number in and we can do different things with it. Have it change in the blueprint during game which is really good. So we're going to use what's called a float variable which is just a number but it's a number that can have decimal places after it as opposed to an integer that can only be one number. So one two three not one point four eight seven whatever. So I'm going to add a new variable just here. I'm going to call it speed since that's what it's going to control and by default it's got this red icon here which means it's a boolean which means it can either be true or false. Which is no good. So I'm just going to change it here to a float and what I want to be able to do is to set its value here in default value but at the moment there's no inputs there for me to do that and that's because we haven't yet compiled it so it doesn't exist yet until we compile. So let's compile it and you can see now the speed appears and I'm just going to set this to a default value of 500 to get us going. So that means that when I put this into my blueprint so we'll just drag this from here and we've got the option to get it or set it at the moment we're just getting the speed so let's get that and we need to multiply it by this. So what I'm going to do is just drag out of here and I'm going to do float and the one I want is this one here which is float times float it's multiplication so let's put that there and we'll just get the result going into x there and we're going to multiply it so we're going to get one or minus one going into here and I'm going to multiply that by speed which will be 500. So what will come out of here will be either 500 or minus 500 since the only options we've got at the moment is that a key is pressed or not pressed so it can well it can be it can be 500 minus 500 or zero when a key isn't pressed so we get that and then the return value for this is going to go into the impulse here like that. So this is nearly done but actually this add impulse here is never going to be triggered because it's got nothing coming into it here it's not going to execute so what we need to do is connect that from here so this is when we get something on that horizontal input so when that happens do this so it's going to go through there and it's going to execute that so add an impulse to it so it's adding an impulse to the paddle there you can see there's a target and the impulse is coming from here get the axis value multiply it by 500 and put that into the impulse and that's everything that we need to do for that so what I'm going to do is I'm going to comment this so I'll select it all press C and I'm going to call that paddle like so so that later I'll know what this is so at this stage it's time to compile this and we'll save it and now we need to know whether or not this is working and we'll only know that through testing so it's time to go back to our level and we can see that we currently have a paddle in place but all this is really is a oh hello all this is really is a dummy paddle this won't do anything so what we can do is delete that for now and what you might be tempted to do is to import this blueprint like that that actually won't work for what we're doing for the method we're using we've got to put in what's called a player start and that is that tells the game when it runs to spawn your default actor at that place which will be our paddle so we're just going to get a player start no that says play to start oh shame so player start I'm just going to throw it in anywhere and then I'm going to set it to zero zero zero like so so that should be in the right place so what we need to do now is just click on play to test this and see whether or not it works so I've clicked on play the good news is that a paddle has appeared so I'm going to click in my viewport window and then I'm going to press the arrow keys left and right and we can see it is moving but very slowly this would not be a fun game to play so we're going to have to go back into the blueprint and make some tweaks to get this to run properly so my advice to you is to get hold of your speed variable and make this number bigger until you're happy with it so I already know that I like a value of 25,000 but you might want it to go faster or slower than that so make sure you put your own value into something that you feel happy with so I'll compile that and then we'll test again and see how that feels so that's much snappier it's also hitting the edge of the level so that I can't get out of that so that's all working pretty nicely so now we've got our input set up it's also working on A and D when I press those that's pretty good so if you do want to make your own little changes to this the three things that are worth changing are let's go to the paddle it's worth playing with the mass it's kind of the default mass at the moment but you can make it lighter or heavier and see what effect you get you can also change the linear damping which is how much kind of external force act on that paddle to slow it down and stop it after you've stopped pressing your button and it's also worth changing the speed as well just and any combination of those three things will give different results you just get something you're happy with so that it feels kind of fun or at least not horrible to move that paddle side to side so that's pretty much it for this step well done for sticking with it we're now getting into proper scripting and stuff it's very exciting in the next one we'll be doing a bit more setting up and scripting and we'll create a blueprint for the ball and get some logic working on that now that we've got the paddle into our level and working the next thing we need to look at is getting the ball in there and get that moving as well so in this step we're just going to get it launching into the level and get it bouncing off stuff for now that'll be enough to get us going so let's do it so the first thing we're going to need to do is create a new blueprint so I'm already in my blueprints folder and in here I'm going to right click and choose blueprint class and this time I'm going to choose an actor there we go and I'm going to call this there we go and that's because it's a blueprint and what I should have done is named this one so I'm going to rename this BP underscore player paddle there we go so now everything's named properly so we're going to open the BP ball there it is and the first thing we need to do is the static mesh that is the ball so same as with the paddle we're going to go to add component we're going to find static mesh and then it asks us what we want to call it I'd very much like to call it ball because it is a ball and then over here I can choose which static mesh that's going to be so from here I'm going to search for my ball there it is so now we've got ball into the blueprint and now we need to set the behavior of the ball so here we're just going to make sure that we simulate physics so that it will collide with things and bounce off of things I'm going to set the linear damping to zero and then going to disable gravity because we don't want this falling I'm going to need to lock some of these as well so we don't actually want this to rotate so I'm going to lock all the rotation axes and the position so the depth the up and down in Unreal Engine is the Z axis and we don't want it to move up and down we just want it to move side to side backwards and forwards so we're going to lock the Z axis as well okay so that does it for the actual mesh and getting it to behave as we want to next we need to get into the event graph and set up the behavior get the logic going so we'll just compile and save this for now and we'll jump over to our event graph for the ball so we've got some events ready for us if we want to use them in this case we don't want those two but we are going to eventually use begin play but first of all what this event well what this event play is going to do is going to call a custom event so we're going to tell it to launch the ball at begin play and then we're going to create this event down here which is going to be to launch the ball so we'll do that first of all so I'm going to right click and just start typing custom event there it is and we're going to add our custom event and I'm going to call this launch ball there we go that's a descriptive name right so as this we want this happening on begin play I'm just going to get this going now so begin play I'm going to type launch launch ball there we go so as soon as play begins it will run this launch ball script that we're going to write here so the thing that we're going to add an impulse to to get the ball moving is the ball so we're going to get that from components here so let's drag that in we're going to get it and we're going to add an impulse to this to get it moving so whenever begin play happens we're going to launch ball which will add an impulse to the ball so far so good and then what we'll do is tick this box here for velocity change and what that means is that it won't take mass into account it will just set the ball to whatever speed we tell it to go it'll go from zero to full speed without taking an announcement account which is what we want in this case and we're going to add an impulse to it so I think if we go we'll just see if it moves first of all so let's set it to a thousand on the x-axis and then we will compile and save that for now I'm just going to drag this alongside my level and then we're going to put this ball into the level and see if it works so first of all let's just this is our dummy ball which we no longer need that's just there to kind of give us a sense of position so I add it at zero minus 70 zero I'll remember that so let's delete it we'll bring in our blueprint and I want it at zero minus 70 and zero and that'll put that in exactly the right place and now all that's left to do is test it and see if this ball moves and bounces off stuff so let's play there we go so it does it launches when we start the game and it bounces so we are going to look at this bounce in the next step but all we need to do now is just get it working properly but so it moves we need to fling it off into the level so we need to change the angle of the impulse so we'll press escape just to cancel that for now and we've got it running at a thousand on the x so what I want to is to fling it up and in this case I know that's going to be minus 1000 if I just did a thousand it would fling it down so we're going to go that way and then I'll compile that and then we'll test again and then the ball goes which is pretty good so what that leaves us with is there is a bit of a problem so the ball is not bouncy enough the surfaces aren't bouncy enough and that's because it needs a physical material that's what we'll be covering in the next step so make sure you stick around for that but for now we've done what we set out to do in this step we've created our blueprint for the ball and we've got some behavior on it to get it into the level once we get it bounced around we'll actually be able to try out our game and see whether or not it works as we want it to so I'll see you in the next step where we'll sort out the physical material get it all bouncing around properly in the last step what we did is got it so that when we played the game it'll fling the ball it's not bouncy enough and that's something that we need to sort out in this step so it doesn't matter whether or not I can move my pedal side to side because that ball is never coming back down the play field we need to sort that out with something called a physical material so what I'll do is I'm just going to move into my content folder here and I'm going to put my physical material in the materials folder so that I'm keeping everything together so to create a new physical material it's right click in here and then we go to physics to create it and then you'll see physical material listed there so we'll give that a click and then you get this weird box with only one option so we'll click that because it's our only choice and then select and then we need to give it a name so I'm going to call it PM physical material underscore no friction because there's going to be no friction on this material it'll also be very bouncy as well so we just need to press enter to name that and then we need to open it up here it is so it gives us some settings that we can mess around with the first thing we want to get rid of is friction we want there to be no friction on this whatsoever so we'll take it from 0.7 to 0 and the other thing we need to change is this option here called restitution and it gives you the name here you can look in the tooltip it says restitution all about us of this surface between 0 no bounce and 1 where the outgoing velocity is the same as incoming that's the one we want we don't want it to lose any speed any velocity so we need to set that to 1 boom very nice okay so that's actually all we need to change in this physics material so I'm going to save that and I can close it for now but we need to assign it to everything and I planned ahead for this so what I did is made sure that at the moment everything's got the same material applied so we could actually if we wanted to go into the ball here and there is an area here to add the physical material so we can put it in there and there it is but I'm not going to do it that way what I'll do instead is open the actual material so the the basic ball color that we created here and if I click on the the main material node here at the top there's a physical material option there and that will do it for everything that's got that material applied so I'm going to choose my no friction material and then I'm going to save there we go and now that's saved I'm going to test it out again so let's play and now we can see that the ball is not losing speed and it's bouncing very nicely and it gives me an opportunity to for the first time really test the game so what I'll do now is I will let the game run for a little bit and you will hopefully see the problem that we need to correct in the next step by the time I'm done okay so here's our problem basically there'll be times when the angle of the ball would be too acute to make the game playable this here is not fun and it's very unlikely that I'm going to be able to there you go so the ball will just kind of stop sometimes and that it can break the game there are times as well I've not managed to catch it on this one but it will get caught on the side and you'll never be able to get an angle back into the ball which again is not fun so going forward in the next step what we'll need to do is take control of the angle of the ball and we're going to clamp it so that it can only go at four angles so it'll be going at 90 degree increments but kind of at a 45 degree skew so that should mean that the ball the bounce of the ball the direction of the ball is always going to be predictable and we know it's not going to kill the flow of the game so that's something that we need to pay attention to going forward that's the end of this step though we've now got kind of what I would call a minimum viable product this is the absolute minimum of what the game is it's a ball that we can hit backwards and forwards there are no wheel mechanics yet but this if it feels fun knocking a ball up and down the playfield then we know we've got something to build on and that's what we'll do going forward right here we go then this step is going to be all about controlling the way this ball is going to move so that it behaves predictably and in a way that's going to be more fun so we're going to keep it at 45 degree sort of increments of now at 90 degree increments that that's going to run diagonal so what we need to do is get into the blueprint for the ball and set this up here we go so it's going to our blueprints holder here's my ball and I'm going to hop straight into the event graph when it opens up here it is so this is my event graph so what I'm going to do is create a new custom event and that's going to be the thing that will happen that's going to make the ball do what we want it to do so right click and I'm just going to start typing custom event and then the first thing I'll need to do is give this a name and I'm going to call this velocity since we're also going to use this to keep the speed the same and angle is what I'm going to call it there might be better names for it but I know what this means so that means it works for me and we're going to call this every tick so what I'm going to do we've got something happening on event begin play but up here I'm just going to have event tick so this will happen every CPU cycle and it's going to run velocity and angle there we go so that's set up so now what we need to do is build this script it's going to be slightly more complex than what we've done so far the difficulty curve kind of goes like this straight up so stick with me and I'll try and explain what I'm doing as I'm doing it so the first thing we need to do is get the velocity of the ball so the ball will already be moving and we need to get that information before we can manipulate it so I'm going to do get velocity and it's this one here it'll say target is active which is what we want because that's our ball so we'll do that first of all and then what we want to do is clamp that so out of the return value I'm going to type clamp vector size and what this will allow us to do is to clamp that velocity the actual speed to a constant value so you could clamp it between like a high and low value but we want to keep it exactly the same speed and we'll use this node to do that so we'll need a new variable to represent the speed of the ball so here I'm just going to click on plus and I'm going to call it ball speed and we want this to be a float so I'm just going to select this I'm going to change it from boolean to float remembering that float is a number that can have decimal places and then we'll compile that so that we can set the default value to for this to 1000 like that and that means that the ball will start out at that velocity at that speed so what we'll do now is we'll get this ball speed and bring that in and get and we're going to plug this into the min and the max values of the clamp vector size so what that will do is it's going to take whatever its velocity is and make sure that it can only be 1000 and what it also means is that when we come back into this variable at any point we if we think the ball is running too fast we can change it if it's running too slow we can change it or if we want to speed up this like the speed of the ball throughout the game to make it more complicated then we can control that here as well which makes it nice and easy so that will basically control the speed what we now need to do is get the angle sorted out and we're going to take this vector size so we've got the speed so far but we haven't really done the angle so let's drag out of return value and then we'll create something called a rotate vector here it is and we can use this to take the vector which is the direction the ball is moving and rotate it to be whichever direction we want it to be in so to do that we're going to drag out of here and get something called a make rotator this little chap here and we're going to set the z axis which is the yaw to 45 and it's this change here that's going to make sure that we're always operating in diagonals which is what we want so out of the return value of this we're going to create a make rot from x and then what we need to do this return value has got x y and z properties but we need to control those individually and in order to do that we can right click on it and we can split the struct pin which then will give us return values for each of the three axes we can rotate them so what we'll do now is get the return value from the z axis and we need to divide that so this will be returning a number which will be a float and we're going to divide that by 90 so we can use that to give us one of four angles you'll see how it works in a minute so you can get a divide by either putting in a forward slash or you can type divide and I'm going to do a float divider by float and I want to divide this number by 90 and that will mean that whatever the angle is it's going to when we round this it can only be one of four angles so the problem with this at the moment though is that we can't work with it yet until we round it up or down to the nearest integer so we're going to drag out of here take the result and we're going to do a round and that will round the number to the nearest integer and you can see the colour coming out of here has changed now because it will only return an integer which is what we want so if we take a number like let's say it's going at an angle of 160 and divide that by 90 round it and then what we'll do next in a minute is multiply it by 90 that's actually going to round it back up to 180 degrees so it only gives us the angles that we want so we're going to take the return value of them and we're going to multiply so again you can either type multiply to get this or you can just put in an asterisk and we're going to do an integer and we're going to times it by integer in this case and we're going to times this by 90 or multiply this by 90 there we go lovely stuff so far so what we've done then is taken what is any number between sort of zero to 360 or zero to minus 360 done some comaths with it and we've spat out an angle that can only be zero, 90, 180, 270, 360 or minus 90, 180, 270 and that's going to be what keeps control of this ball for us so we'll get a mate rotator and then the result of this it needs to be plugged back into Z so in doing that you'll see this little conversion node comes up and it takes the integer and changes it back to a float now what I could have done is I could have done an integer times float here and then the output would have been a float but I wanted to show you what happens if you need to convert one type of number to another Unreal Engine works that out for you which is a nice handy little trick so with this value we're going to get the return value and we're going to connect it to a get rotation x vector and this is what we can use then to control the direction of the ball again and then we need to unrotate this so out of here I'm going to go unrotate vector lovely and then we need to make sure that we get it at 45 degrees again so from here this one here the mate rotator we could make a new one over here if we wanted to but what I'm going to do is just drag the result here into there because these are both doing the same thing so we're rotating it here and then we're unrotating it again here by 45 degrees so we need to multiply this by a vector length now so let's create a vector length length there it is vector length and we can see that the result of this is a float so out of here we need to do a multiply and we're going to do a vector multiplied by float so let's plug that in there and then we need to figure out what to do with the result but before we can do that we need to get something coming into the vector length which is going to be the speed of the ball so here's the ball speed so the clamp vector here is what needs to come out of here so we're going to bring this over here and oh I'm so lost right now and then plug that in there so that that's getting the speed that can be multiplied by the angle and then we're going to use this output here so we've got angle up here speed here and then we're going to put that back onto the ball so we started way back at the beginning by getting what was happening with the ball and now now we've done all this modification of it we're going to put it back onto the ball so out of here we're going to create a set physics linear velocity of the ball there we go and what it does is it gets the ball for us so the static mesh here so that it knows that's the target and the new velocity is the result of this maths that we've been doing okay so now we need to trigger all this and so to do that we've got an execution pin all the way over here and so I'm just going to bring this over and this just needs to be connected in here so every tick what's going to happen is this is going to be triggered which by the time I've gone through it all we are getting the velocity modifying it changing the angle putting it all back together and that's our new velocity so what we need to do now is compile and save this and then we'll give it a test and see whether or not it allows us to get any different angles and what I'm going to do here is just a little trick so as well as doing this I'm just going to get it to print the the angle of the ball so that I know what's happening so what I'm going to do is after it's done this I'm going to do a print string and this will print the angle for me as some text in the top left hand corner of the screen so as I'm only really interested in the angle I'm going to get out of here the make rotator we'll plug that into the in string again it will convert it because it's coming out as one type and we want it as a text string so we can see that modification happening so I'll compile that again save and then let's test ball's not launching okay then so it's clear that the testing has highlighted a problem and I know what it is I've done something very silly so the way we've currently got it set up we're actually using a set physics linear velocity here and that's what I should have used in the first place I should have got the physics linear velocity but instead I use this nonsense node here the get velocity so we need to swap that out so instead of get velocity we're going to use get linear physics velocity for the ball that's the one that we should have used I apologize for showing you the wrong thing so we'll need to swap this out so let's get rid of that and we will drop this bad boy in its place and then what we need to do is this execution pin here needs to go back over here and the first thing we're going to do is get the velocity and then the return value is going to go into there and then we can take this pin here and plug it into there or we could if I was a better aim there we go so what we do now it'll make more sense is we are running this custom event let's get the current velocity of the ball the physics linear velocity as we should have done in the first place do all the same things to it and then set it back onto the ball and we'll do the print string again to see whether or not it's working this time so let's compile and save across your fingers hey there we go and then you should be able to see that on y the angle is changing so there we've got minus 90 there's 90s it comes back down there's 180 and that's what that maths has done for us it's making sure that the ball will only ever move at one of those four predetermined angles as we've set them and that will ensure that the game remains predictable that the ball is not going to spend too long at one end of the play field and that's going to keep the pace of the game up you can obviously do your own little trickery with the maths to get the ball moving in different directions if that's what you want or to kind of correct it if it's moving at any unwanted angles but as I'm doing this as a making your first game in Unreal Engine tutorial I don't really want to make it any more complicated than that because as you can see I've done this before and I still cocked it up so there we go what we'll do now then is we'll remove this print string because it's served its purpose so in the next step what we'll be doing is just kind of tidying up the work that we've done in this step so we're going to use something called reroute notes to try and tidy up some of this spaghetti looking stuff here and we're also going to comment any of the bits that we haven't done so far so these areas could do with commenting just to keep on top of things so it doesn't get too confusing plus it'll be a nice easy step after this more complicated one I think we're all ready for a little bit of a breather that was hard work so I will see you in the next step okay so here we go in this step we're going to set about making our blueprints look a little bit tidier so from the previous step we were left with this which is a little bit messy and difficult to follow you've got the wires going behind nodes and it's a little confusing to look at so we're going to try and rearrange this so that it's easier to look at so the first thing I want to do is I'm going to have the main execution pins and wires going all across the top so what I'm going to do is just sort of move this up so that I get a pretty straight line which I believe is there that's not straight at all is it no that's not straight let's move it down a touch that's pretty straight okay so now we can make some more changes from here so I'm just going to move this to here so I can see what's happening there and what else is happening I'm pretty happy with that I can see where that's going I'm just going to tuck that in a little bit that looks okay and then let's have a look where some of these pins are going that are quite confusing to look at so this vector length here I'm going to see this is quite confusing and difficult to follow so I think what I'm going to do is bring it down and sort of change the root so I think what I'll do is just here I'm going to double click on this wire and that will add a reroute node so with that selected I can then drag it and use that to put it down here and then I can move this down to get this straight again you don't need to have straight lines it just helps with my OCD if things can be straight if possible and then we've got the same sort of issue here with this one that's going behind a few of these nodes so let's zoom in here I'm going to double click on this get myself a new reroute node and bring that down and that suggests now that that one's not straight let's move that up a bit that's pretty cool so that's easier to look at so far and then I think the rest of it there are no overlapping wires so that's a lot neater yeah so there are still things that I could do with this just to try and keep things a little easier on the eye so I'm just going to try and keep things in a line where I can it's not ever so important it's just something that helps me sleep at night if I know that things aren't any less neat than they don't have to be so I think that looks pretty cool I think for consistency I'm going to move that down there because I've got the same on the other side okay so that's pretty pretty neat now much easier to follow we've got a couple of wires that overlap none that are completely hidden and now what I want to do is comment this so I'm probably going to put some comments within comments for this so that I know which bits are doing what and for that reason I'll probably move things around a little bit more so let's just move that along here oh I didn't want to move that one so let's select all of these and I'm just going to move them along a little bit over D3 it's very nice okay and then we know that this area here or this one specifically is clamping the ball speed so I'm going to start these these two nodes and then comment clamp ball speed so I know exactly what that's responsible for and then this section of maths here I'm also going to comment and this is going to set to 90 degree angles so that I can remember what that bit's responsible for and then the whole thing I'll put in a comment and I'm going to call that speed and angle of ball and that will really neaten that up I know exactly what I'm looking at now plus when I want to neaten things up later I can click and drag the whole lot around which makes it a lot easier and then just so that I know what I'm looking at here I'm going to comment this one speed oh that's a nice spell speed speed and angle and I know that they go together this one's going to be launch ball and this one here is also to do with launch ball and I'm probably going to call this one event so that I don't get them confused and then I can just line those up so that they look nice and neat together beautiful okay so that's looking pretty neat I don't need to do any neatening up of this one because that's pretty pretty clean but the ball now looks much better easy to follow so I'm going to compile that and save it and now we're ready to move on to the next step now it's time to get the block into the level and behaving properly so we need to create the blueprint for that and set up the behavior to make sure that it disappears when it gets hit by the ball so step one as you should be able to work out by now is to create a blueprint for this so I'm in my blueprints folder already I'll right click and blueprint class this is going to be an actor the same as the ball is there we go and I'm going to call it BP underscore block and then we'll open that up okay so the first thing we need to get in here is an actual static mesh so let's do that add component static mesh and I'm going to call it block because it's for the block and then for the static mesh I'm going to choose the block from my list there we go so far so good we'll just compile that so it's in place now this next step is incredibly important and it'll all break if you don't do with this what I want to do is have this disappear when the ball hits it and unless we do this next step this just will not work because it will never register a hit event and I've banged my head against walls for far too long but I forget to do this so let's just do it now while we're thinking about it so with the mesh selector we're just going to scroll down a little bit and it's this collision area here that we're looking for and it's this simulation generates let's just move that generates hit events and by default that's turned off so we need to tick that box so that when there is a hit event it's registered and we can do stuff with it okay so we've done that let's compile it beautiful next job then is to go into our event graph and we'll delete these we don't need these right now we're going to use something that comes off this the event so we'll right click on the block and there you can see we get a list of events that are available to us and what I want is add on component hit so when something hits the component which is the mesh then it will do what we want it to do so there is our event and what I want to do is restrict this at the moment it could be that if anything hits it it will fire off this hit event and we want it to be only the ball that will do it because later when we start making this look pretty and anything to it there might be debris flying around there might be overlapping meshes and we don't want those to sort of automatically delete themselves so from other actor we're going to drag out of here and we're going to cast to the ball cast a BP underscore ball there we go and so now when it reaches a hit event from something it will ask is it the ball if it is the ball it will do the next bit which will be destroy actor and that will remove it from the game if however it's not the ball it will do nothing it will still register the hit event but it knows not to do anything that's what we want so when it hits checked is it the ball so it's casting to the ball it's having to cast to another blueprint for this so what it's doing is talking to the ball blueprint and so it says are you the mesh that's interacting if the answer is yes okay we can destroy the block and that's how it should work so we'll compile and save that and now what we need to do is get all these dummy blocks out of the level put in the new ones and test so let's go into top view for that make it a bit easier I'm going to hold control and alt to allow them to do a marquee selection no shift and alt shift and alt to do a marquee selection delete all those and now I can bring in my blueprint block there it is so I think x and z should both be zero and then I can line these up so I'm going to have a bit of a gap behind I think I'll put it about I'll just put it there in line with that or as in line with it as I can get it that's really not in line is it whatever so I'll place it there and then let's a little gap between them and then we'll select those three move them over to the side hopefully keep the the gap consistent it looks like it's consistent and then we'll have a few rows of these like that is that gap consistent I think it looks like it let's go for five rows I don't know how many there is an actual breakout something like that let's go back to our perspective view and now we need to see whether or not these will disappear when the ball hits them so let's hit play what goes the ball come on baby you can do it hey it destroyed it boom and that's it we've now got a lot closer to this function as a game so as the ball goes up there now it will remove these blocks until either the blocks are all gone or we lose control of the ball so that's pretty good isn't it well done Oz we are so good at this right so that will do it for this step I'll see you in the next one enjoy destroying your blocks so what we want to do now is to get the ball to spawn when we spawn a new ball at the paddle wherever the paddle is so we need to first set that up in the paddle blueprint so I'll open that up the player paddle here she is and what I want to do is go into the viewport section of this and I want to add an arrow component so here on the add component if you scroll all the way down to the bottom you'll see that it's listed under utilities or you can just search for arrow and you won't really be able to see it but if I just move this out of here this is what the arrow looks like funnily enough it looks a lot like an arrow so I'm just going to move it about 90 and I've moved it minus 90 you can see on why I've moved it minus 90 and that's because I already know which way mine's facing because I did test this before I did the video and then what I also want to do is rotate this so I'm going to start rotating it this way and I want it to be at an angle so just using this I can't get 45 degrees so I'm at minus 40 so I'm going to make that minus 45 and what that does is put this arrow component so that it's above my paddle or it will appear above the paddle in the game and it also means that when it launches the ball I can make it launch at a 45 degree angle because we can follow the direction of that arrow what we need to do now though is check that that's worked so what I'm going to do is check in rendering visible yes but currently it's going to be hidden in game and when the game's finished we want it to be hidden but for now we need to be able to see it so I'm just going to deselect that I'm going to compile my blueprint and then we'll go to play and test it out and you can see that that has appeared exactly where we want it to the problem though is that it's not yet following the paddle and we need that arrow to go with the paddle so that let's say we lose a ball and we want to spawn a new ball over here then the arrow needs to be there so we can spawn from there so we're not there yet the way that we need to do this is we'll go back into this player paddle you can see here we've got the default scene root paddle arrow and what we can do is make the arrow if we just drag that onto there we can attach the arrow to the paddle so we'll do that and you'll see you get a little sort of dependency thing going on here and then we'll compile that again and we'll test and now when I move side to side you can see that the arrow is following the paddle which is going to be very very useful for us when we want to spawn balls the next thing we want to get set up is give the player paddle the ability to spawn a ball and we're going to go back into our blueprint for that and we need to be in the event graph here we are so I'm going to create a new custom event as I am fond of doing so right click custom event and I'm going to call this event new ball that seems like quite a descriptive name for this so when this is called I want to do a spawn actor from class there it is and so anytime this event runs it's going to spawn an actor which makes sense because we want it to spawn the ball so from this class here what we're going to do is tell it that we want the ball so there's BP underscore ball which is what I called my ball so that's now going to be the one that gets spawned whenever we call this and then what we need to do is you see we've got a spawn transform and that the information we can give that is where we want this ball to spawn which is going to be at the arrow so we need to set that up as well so what we're going to do is get a reference to the arrow so I'm going to drag this in and we're going to get it and then we need to get the position of that so we're going to drag out of the arrow I'm going to do a get world transform and then the return value is going to go into spawn transform so let's review what we've got going on here so whatever new ball is called it's going to spawn a ball there you go and it's going to spawn it at the position of the arrow which is exactly what we want so I'm just going to neaten this up a little bit let's just put all these things here not like that get these two and I'm just going to bring those up a little bit I'm going to put this all in the comment which I'm going to call spawn ball good name and then we need to be able to test this out so I'm just going to create a new event which is begin play so whatever the game starts and we're going to do spawn ball no we didn't call it that we called it new ball didn't we new ball so at the beginning of the game it's going to spawn a ball and we're going to be able to test this in a minute but it won't work yet because there's already a ball in there and the ball's launching as well all we want to do is get it to spawn at this stage so we need to disconnect a few things as well so we'll go into that and let's just compile this we'll go into the level we'll delete the ball that's already there so we don't get confused lovely and then we're going to go into the ball blueprint for a second and somewhere yeah so on event begin play the ball is being launched we don't want that just yet so I'm just going to disconnect that by holding Altama keyboard and clicking on the wire that connects them that's disconnected that and I'll compile that so now let's test this and see if it's working it is so we've got a ball that's being spawned at the beginning of the game at the location of the arrow or the base of the arrow the next problem we've got is that before we launch it we want the ball to follow the paddle we want it to go with it so that's the next thing we're going to set up in this step so that's just stop testing right the next thing I want to do them is I'm going to go back into my player paddle here it is and what we can do is we're making this blueprint the paddle spawn the ball but they're different blueprints so what we can do is if we want to do anything with the ball from within the paddle it helps to have that as a variable that we can talk to so at the moment we know that this is the ball so the return value is basically the ball so what I'm going to do is just drag out of here and then from the options I've got one of the top ones here is promote to variable so then we get this so it's going to say once you've got the ball make it a variable and there you're going to see it's called new variable underscore zero we're going to change that to ball and then going forward within this blueprint we can do things with the ball which will be very helpful right so now what we'll do is we'll go into the ball blueprint I'm going to make it so that the ball once it's spawned will follow the paddle while ever the ball's not in play so what we're going to do is create a new custom event custom event and I'm going to call that update position there we go and so we're going to use this event to be the thing that updates the ball we only want this to happen though when the ball's not in play so when it's not active so to control that we're going to create a boolean variable booleans can either be true or false so it's going to be is the ball active true yes it's active false no it's not so while ever it's false we can update the position so we're going to create a new variable click here and I'm going to call it active like that and by default let's just compile this by default you can see that that's set to false it's not active which is what we want for now and then we can control whether or not it's active by setting this variable to true or false once we launch the ball or when the ball is dead so we'll set that up later okay so what we're going to do now is get this set up so we'll get active and we're going to get it and what we want is that whenever this is not true so we're going to drag out of here and make a not boolean so if that's not active we're going to create a branch now a branch is basically just an if statement if it's true do this if it's false do this so we're going to in fact if you even type if you'll see that branch here branch comes up but I'm going to search for branch because that's what they call in blueprints so we'll create a branch like so and so the first thing that this update position is going to do is check whether or not the ball is active in order to move forward it's not active which will be true and then we're going to get a set act location there we go so this is going to set the act location of the ball and we're going to relate that to the arrow but at the moment we don't have access to the arrow because that lives within the player paddle blueprint this one here not within the ball so we're going to do something called casting to another blueprint and we'll do this at the beginning of the game we'll ask this blueprint to talk to the player paddle blueprint and say I want access to something in your blueprint which is going to be the arrow so we'll set that up now so just up at the top here we've got this event begin play that's currently launching ball I'm just going to put some more stuff over here that's going to talk to the player paddle blueprint this is still disconnected for now so just here I'm going to right click and do get player controller just here and then out of the return value we're going to do get control pawn which is our paddle and then out of here we're going to do cast to player paddle there it is so this is all tickety-boo and that's going to happen at begin place I'll just connect that up so as soon as this happens we're getting all this information from the player paddle and then as blueprint player paddle we're just going to promote this to a variable and we're going to call that variable player paddle so I know what it is oh let's get rid of that capital don't need that so player paddle and that now at the beginning of the game we're going to have access to player paddle so that's one of the first things that the game's going to do when it starts up it's going to say to the player paddle can I have access to your blueprint and then we've got access to that within this blueprint going forward so that means we can now go back here and do stuff with that information so what we need is a player paddle reference so I'm going to drag that out here and we'll get that and what we want to do the thing that we're really interested in is the arrow so I'm going to drag it out of here and type arrow and you can see I can get the arrow so now I'm getting the position of the arrow which is good and from that we need to get the world location get world location because we need to know the position of the arrow that's why we're interested in it and then the return value of this this get world location information that we've got we're going to put into the new location so where we want the ball to be put so the target itself do it to the ball because we're working in the ball blueprint and then if the ball is not in play get the world location of the arrow and put the ball there so that should make it follow it but we need to then have something to trigger this update position to make it work so somewhere in here I think we already have event tick we do so you can see every tick it's currently updating the velocity and angle of the ball what I want it to do as well in fact let's just um so that's just doing speed and angle so we're going to have to do a little bit of reorganizing here and we also want it to do every tick update position there she is and I'll put that in a comment just so I can see what I'm doing update position of ball just so I know what's happening there okay so every tick that's going to happen and then what I would like to do is just kneading all this nonsense up a little bit and then we'll put that in a comment as well update update can't spell update ball position when a little bit french there okay so that should work so at this stage we're going to compile and test now I know this isn't going to work so I'm making myself look stupid on purpose here because there's one other thing we need to update but I want to show you the problem before we fix it so we're just going to compile that and then we'll test and the idea now is that the ball should follow the paddle but it isn't doing and that's because we need to make one change so if we're going to that BP ball it's because the ball isn't the root so it's happening to self which is the whole blueprint but the ball is kind of contained within the blueprint isn't like the folks of the blueprint to fix that we're going to drag the ball here on top of the default scene root and then the ball becomes the default scene root so we'll compile and save that again and then play it and we're getting somewhere now so what that means is that when a new ball spawns it will spawn where we want it to which is going to be just above the paddle and we can take aim before we launch it so we can move left and right and so if let's say we're just aiming for that last tricky block we can put the the paddle over here and then we can fire obviously we've not implemented a launch ball yet so we can't do anything with it but we're getting there in the next step what we will be doing is getting itself to launch the ball so that we've actually got a game that we can play so I hope to see your beautiful ass in that next step now that we've got the ball following the paddle at the beginning of the game what we need to do now is get it so that the player can shoot the ball into the game themselves so previously we had it that the ball would just fly off into the level at the beginning of the game we don't want that we want to give that ability to the player so let's get that set up shall we so the first place I want to go is into the ball blueprint so let's get that bad boy open here it is and I want to update this launch ball event so if you remember we set an active property an active variable on the ball and we need to know at times whether or not this is active or not when the ball is launched into the level that means the ball is active and that's going to stop us being able to spawn a new ball so just into this launch ball event what I need to do I'll just move this along here is out of launch ball we're going to set set active and we're going to set that to true and then we'll know that the ball is in play so we'll compile that and while I'm in this blueprint I also want to we set this up here which is to get the player controller so I'm just going to comment this as well get player controller or just get play will be fine actually that's so just so I know that I'm casting to it there if I ever forget which is likely and we no longer need the launch ball here so I'm going to get rid of that as well and that because we're going to handle that elsewhere so we'll just now move these over here just to keep things lined up a little bit okay so I'm done in this blueprint let's compile that I'll save it as well and then what I want to do now is go into the player paddle blueprint and this is where we're going to set up the ball launching so we need this action to be triggered by an event which is going to be when the player presses the fire key so if we go to the project settings hopefully you'll remember that we set up an input right at the beginning for fire that's what it's called and w up or space bar will cause the ball to be fired so we can now go into our player paddle right click and if we just type fire because that's what we called it we get an event for that beautiful so this is going to happen when we press that key or one of those three keys so what we need to do first of all is get some information about the ball and we've got a ball variable here which if you remember when we spawned the actor the ball we set that into a variable so every new ball that comes in that spawned what we can do is then mess about with it so we're going to get the ball and we need to know a few bits about it first of all we need to know is it valid so we're going to do is valid and we're going to use the one with the F next to it there we go and what that tells us is whether or not the ball exists so if the ball doesn't exist if it's not spawned for some reason then we can't launch it so that's one thing that we need to know did the ball spawn properly is it actually there we also need to know is it active so we're going to get active because if it's been launched into the game and it is active we don't want this to work so only if it's not active so moving forward from here then this actually needs to have a not coming out of it a not boolean because we're only going to work with this if active is not true so there's a not there and we need both of these so not active and is it valid if both of those are true we can move on so we're going to add an and boolean to get those two to work together so plug those in so there you go if the ball is valid and if it's not active we can move on what we've set up here is a condition so we're going to just come out of here and we're going to do a branch there we go so when we press fire the first thing we're going to do is ask these questions is this is the condition before we can move any further so is it valid and is it not active and if that is true we can move forward and so what I'm going to do I could just use this ball reference here but that's going to get a bit messy so I'm going to get a new reference just to bring it a bit closer get ball and then out of here I'm going to go launch and that relates to the custom event launch ball that we have in here this one there it's going to add the impulse to it and set the ball to active and that's going to happen on true so what we're saying is we press fire ask these questions if it comes back true perform launch ball on the ball so we can now compile that and now would be a good time to test whether or not this is working so let's go here we'll press play I'll click here to make it active so I can still move left and right which is a good sign the ball at this stage is still following the paddle and if I press I'm going to press up on my keyboard and it fires so we've managed to get that functionality working perfectly so now what's going to happen is I'm going to let the ball go and this creates a problem because there's nothing killing that ball when it falls out of the play area so we can't use anything to trigger the spawning of a new ball to keep the game rolling so moving forward in the next step what we need to do is get that functionality in place so what we're going to do first of all is put a kill zone in something to kill the ball when it goes out of the play space but just to tidy things up before we move on let's comment this so I'll put it on in there press C and I'm going to call this launch fireball I think fireball there we go that's lovely and we'll line that up okay so that's that step finished I will see you in the next step where we will be able to kill some balls now that we're able to fire the ball into the level ourselves we need to be able to start building on this functionality so we need to be able to have the ball when it gets past the paddle so the player they'll lose the ball the player's going to lose the ball and they need to be able to spawn a new one but first of all we need something to trigger the fact that that ball's gone I'm going to do that by creating a kill zone so the way I'm going to handle this is I'm going to create a new blueprint so a blueprint class and it's going to be an actor and I'm going to call it kill zone is that like a superhero name or something like an x-man if it is in the comments tell me because it sounds like it should be if not I'm going to I'm going to copyright that kill zone the x-man it is it's mutant power is killing stuff obviously right so we've got our kill zone let's open that here it is and all we need to put in this is a box collision so that when something overlaps with it we can do something so let's add a component and I'm just going to type box so that I don't have to search for it there's box collision and there it is and what I want to do with this I'm just going to leave it called box is I'm going to drag this onto the default scene route so that this is the only thing in this blueprint and that'll just stop any problems with errors later so that's done what we then need to do is go into event graph we're going to get rid of all of these events we don't need any of them and instead we're going to go to the box right click on it add event and we're going to do it on on component begin overlap as soon as something begins to overlap with this box something will happen what do we want to happen we want it to destroy the ball actor so other actor we're going to drag out of there and we're just going to type destroy that's not how you spell destroy they even close destroy why can't I spell destroy I did it destroy actor that was hard work right destroy actor now why am I telling it to destroy the ball actor because the only thing that could possibly overlap with it is the ball nothing else will be able to get near it so there's I don't need to complicate this by casting to the ball and making sure it's the ball so it's going to leave it really simple if anything overlaps with it kill it so let's compile that and I'll strike this over here for now in case I need it and we'll go into our level so this is not going to work until we put one in our level now the first thing I want to do so let's just get a kill zone let's just save them all first just in case okay so I'm going to put one in there and then I'm going to set the location of it to just be zero zero zero and that's so that I know that it's on the right level and then I'm going to move it up into the level now this is not where I want the kill zone to be but if I move it below here which is going to be off camera if it destroys the ball I won't see it which will make it difficult so I'm going to test it up here first I'll make it a bit bigger and I'm just going to stretch it to fill the play area and you can see I'm overlapping it with the the outer bounds area or the the game bounds and why won't it delete that because it's overlapping it's because in the game it will only be any new overlaps when the game starts this is already overlapping so that's safe but when the ball overlaps it it will destroy it so I'll leave that there and we'll just click on play to test it so there we go left and right press up and as soon as it hits that it disappears so we're now able to destroy the ball now obviously we haven't set the functionality up to create a new one yet but we don't need it yet that's the next step so what I'm going to do is bring this down here and what I want to do is make sure that I can see this in game in fact let's just test this first I'll put it back up there I'm going to go into my kill zone select the box collision and you can see that it's currently visible but it's hidden in game so just for now I'm going to remove that because I want to be able to see where I'm putting it to make sure that it's where I want it to be so let's just compile that and let's just play make sure we can see it we can so I'll know exactly where I'm putting it so I just don't want it to be in the way so now what I can do is bring this back towards a player and we can see where the player starts so I just need it to be below that so we'll try there it will go a little bit lower actually and then we'll go wider let's try that yeah so you can see it's just just just below the paddle so the paddle is not going to accidentally collide with it and then we'll send the ball into the game and test it and make sure that it behaves as we expected to yep we saw the ball disappear so if we want it to fall off screen before it disappears then we can just move it off screen a little bit but I'm happy with that for now so let's just press escape there I'm going to go back into my kill zone make it hidden in game because I don't need to see it anymore compile and then I'm just going to do one more thing in my level before this steps complete and it's to create more of these so what I'm going to do is just got my move tool on and there we go hold alt I'm going to put one up here and then I'm going to get another one here and I'm just going to change the shape of it make it thinner and taller and these are going outside of the game why are they doing that? because just in case the ball manages to get out of the game bounce somehow what I want to happen is it'll at least spawn a new ball if it gets out there and just keeps flying off forever the game will be broken the player won't be able to keep playing and they'll have to crash the out which we don't want so we're giving it a failsafe it's still going to be a bug and it won't look right because the player will lose a life but at least the game won't be completely broken so it just gives us a nice little failsafe so I'll put these out here like so and then what I'll do I probably shouldn't have turned these off but I'm just going to there you go make it so it's not hidden in game again and let's play it and the main reason I'm doing this is just a test because I've left them overlapping I want to make sure that they're not killing each other which they're not so there you go you can now see the outside of the game bounce if the ball manages to squirm out somehow we're fine it won't completely crash the game beautiful okay and that will wrap this step up now that we have the ability to destroy the balls in the next video we need to be able to spawn a new one as soon as the game detects that one has gone so that's what we'll be doing next now that we have the ball being destroyed when it leaves the playfield we need to make it so that we can spawn a new one and that's actually really really easy to do so this step's going to be a short one it won't take as long to do it but we need to do it it's short but important much like my pee never mind right so the first thing I'm going to do is sort out the name of Killzone because for some reason I just completely ditched my naming convention so we'll fix that first I'm just going to go rename and I'm going to call it BP underscore Killzone bonus points if you were shouting no you're naming it wrong when I did that and there we go that's done right what we need to do now is go into BP ball let's open that up and the thing that's going to trigger the spawning of a new ball is when the last ball gets destroyed and there's actually an event for that so if I just right click and type destroyed you'll see that event destroyed pops up there it is lovely so basically what we're saying to Unreal Engine is as soon as this particular blueprint this ball gets destroyed we can spawn another one of them so what we're going to do is go to we need to get the player paddle I will show you why so let's just open the player paddle up and the reason that we're going into the player paddle is because it's the player paddle that has the spawn ball blueprint so we need to get the player paddle and then from here I'm going to type spawn ball no what did I call it new ball is what I called it let's just double check yeah the customer event is called new ball that makes sense right so what we're saying is that whenever this gets destroyed run the new ball script in the player paddle blueprint and guess what that will do it'll give us a new ball so let's just comment that up so new ball when one is destroyed yeah so we need to test it let's do that so compile save and into here so let's play so what I need to do first is launch the ball that's all still working jobs are good and then we'll let it flap around the level a little bit I need to move my paddle out of the way and it works so now we could just play this forever until we destroy all the blocks and then well we could still keep playing it and that's that's all good so yeah a successful step well done everyone what we're going to be doing in the next step is starting to get it so that we can set these blocks up with different colors and have different scores so that then we can get the on screen score display and start to and it's into more of a game in this step what we're going to be doing is setting up our block blueprints so that we can have different colored blocks and have the blocks with different scores all coming from the same blueprint actor so that's what we'll set up now but first of all I just want to do a bit of tidying up in the ball a couple of jobs that we need to do so the first thing I'm going to do is find my begin play section here which is where I'm getting my player and I want to get the game mode as well because we're going to need to make it so that we're getting scores from the blocks when they're destroyed and we're going to need to store the scores in the game mode and then get that printed to screen so we need to make sure that we've got access to the game mode in here and so the way I'll do that is I'm just going to right click here and do get game mode oh get game mode there we go and out of the return value of this I'm just going to cast to my game mode so there it is bo game mode for breakout and then what I want to do is just get that so that it follows from this begin play because as soon as we begin the game I want to make sure that we've got access to that so there we go let's just line that up a little bit lovely and what I want to do is make sure that I've got access to this as a variable within this blueprint so I'm going to as game mode drag out of here and then just promote to variable and that's going to set this as a new variable and we're going to call it game mode and then we've got access to our game mode which is good and of course it's always a good idea to comment so let's add a comment to that and it's just going to be get game mode so we know what that's doing the last bit that we need to do on this before we finished is just compile and save and then we're done in this blueprint for now where we need to be working now is in the block blueprint so we'll move back here to find it there's the BP underscore block so let's get that open and now we can add some features to the block so all we have really on this happening so far is that when the ball hits it then it's going to destroy which is fine but we need to get a few other bits of functionality in there as well and we're going to do that through the use of the construction script the construction scripts basically these fire every time a block is spawned so we can have control of that at the actual spawn of a blueprint rather than at the beginning so in the regular blueprint in the event graph we can do things on begin play but we want this to happen whenever it spawns so into the construction script so that here's the little purple thing to get started so what we're going to do to get the blocks with different colors is we're going to create a dynamic material instance and that will just allow us to when we drop a block in the level we can then change the color of it and it'll all be based on the same blueprint so that's really cool so what we'll do is just click on block up here there we go and then we're going to just from our construction script we'll drag out of here and we're going to do a dynamic material instance so there it is create dynamic material instance for the block so we will select that and what we need to do is set the source material for this so what we're going to be creating dynamic instances of it's going to be the m underscore basic for now which is just the one material that we've created so that that makes sense now we need a new variable so I'm just going to click on the plus symbol here we're going to call this block color well we get my capitals in the right place block color and what I'm going to do with this is I'm going to click on this little i here so you can see there it says the variable is not public and will not be editable on the instance of this blueprint that's telling us that it's not doing what we want it to do let's click that and it'll change the variable is public but missing till tip I don't think that's supposed to happen I think there's a little bug in on real engine so what this means I'll explain it for you is that now we've clicked on the i this makes this this variable public and so when we're in the level whenever we create an instance of this blueprint we can change this variable which will be very useful to us for creating our dynamic material instance for each of the different blocks the type of variable is not right for this because at the moment it's a Boolean and we want to change the variable type to linear color so it's not in the kind of standard one so I'm just going to start typing it linear color there it is and then we know that that will be a color which is what we want whilst we're not going to be doing anything with the points yet we are going to take this opportunity to set it up so we're going to add another variable as well I'm going to call this one points so this is what each one of the blocks is going to be worth this needs to be public as well so that we can change that from within the level and we're going to change the variable type to float integer probably works as well but I'm going with float so at this stage I'm just going to compile and save just so I know where I am and it gives me access to some of my variables here as well so you can see now I can change things here if I want to or if I can see what I'm doing I've got a color there as well but we're not quite done with this construction script yet so out of the return value here we need a set vector parameter and you can see that we're now going to be setting the color using this it tells you in the tooltip this the target is the material instance dynamic we've got a dynamic material instance here I don't know if change the ordering of the words but that's going to allow us to set that and what we need to do is just get the block color so let's get it we're going to connect it to the value so that's what's going to be setting the color of our dynamic material instance and just so that we get the right starting color I'm going to set the default color of the block material to white and it will at least match up with what we've got already I also just want to give a name to this parameter under parameter name I'm just going to call it color that should do nicely and that should do it for us for now so we're going to compile and save this and see whether or not it's having the desired functionality in our level so let's go back to level one you can see I've already got my my rows of blocks set up so let's get a little bit close to these so I can see them lovely and I'm just going to select I'll select them a row at a time so let's get this top row here and the color for these there kind of furthest away so I'm probably just going to set these to red you can see now that I've got them selected these parameters that I've just added have become available so I can set the color of these blocks hopefully so let's set these ones to red hey hey hey it's working whoo so we'll set those to red bonza and let's say that these are going to be worth 100 points that is some big points right there okay so keeping sort of in line with the original I think the next row I'm going to have as being like an orange color so let's just find something that looks kind of orange that's nice and orangey I think so click okay on that and the points for these let's have we're going to set these at 50 that is a good points number I think then we're going to work our way down to the next row I think you can see where I'm going with this now you can probably work out the rest for yourself but I shall put you some video just to be helpful according to my little guide that I've got on screen as well for the breakout colors I think this is going to be like a lighter orange so let's just or maybe going towards yellow something just a yellowy orange let's let's go with that and the next set of points we're going to set to 25 we'll halve it again and then we're going to go to the next to last row right here we'll give these 10 points each and the color we'll probably just keep working our way around this color wheel I think is a good way to go so you'll need to be hitting the green spectrum a little bit and then we'll just go to this nearest row of the blocks and five points these are rubbish blocks we don't want any more than five points for these because they're not that good they're just the closest ones and we'll have a nice greeny green color hey that looks beautiful it's like a rainbow okay let's have a little look see how that's looking in game oh that is looking pretty there we go so we now have different color blocks that we can add in level and we can also assign different points to them which we can add up we're not actually counting the points up yet we're not doing anything with them but it does mean that we will be able to go in forward so before we can actually do anything with the score we're going to need a bit of a UI to the game so we're going to need to count how many lives or balls we've got left and we're also going to need to put the score on screen so the next step is going to be about setting up that UI and getting it to display moving forward we're going to be adding some more game style mechanics to this so we're going to make it so when the ball falls out of the level we're going to lose a life and as we hit the blocks we're going to start collecting points and we need a way to communicate that to the player I'm going to do that do the use of a heads up display or HUD which will be creating and adding to the screen in this video so let's get stuck in I'm already in my blueprints folder which is where I need to be and I'm going to right click in here and at the bottom of this create menu you can see that there's a user interface section oh there it is and at the bottom of that menu you can see there's widget blueprint and that's what we're going to be creating so we'll click on that the first thing Alaska has to do is give it a name we will we're going to call it for heads up display and then we need to get that open so we can work on it so double click and here it is so at present you can see this rectangle here represents the sort of shape of our heads up display and we know that we're currently building for a portrait style phone screen so this is not going to work really so in the top right of the screen you can see it says screen size here we're going to go down there we have phones and I'm just going to stick to the Samsung Galaxy S4 preset because it kind of fits in with the the shape I want without being too high res so that's what we're going to do this still leaves it in landscape mode though which is not what we're looking for so this little choppy up here switch between landscape and portrait is what we're going to use to get this facing the right way and then just as we do in any blueprint we can move this around so I'm going to center it just by clicking with my right mouse button and dragging it into place now we can start bringing in the elements that we need from over here which is called the palette and the first thing I'm going to create is something called a horizontal box so I'm just going to start typing this horizontal box there it is and I'm going to drag that in like so I'll zoom in on it a little bit and I'm just going to expand the size of it so that I've got room to do what I need and I'll get its contract back down to the size I want in a minute so this box here doesn't do too much on its own we need to add some text to it to allow it to display what we want it to so I'm going to use this text here which is just a block of text so I'm going to put one in there and you can see it kind of snaps inside it knows where we want to put it and I'm going to put another one so I've got two text blocks side by side and I've kind of aligned them to the left as well and then I'm going to select this first text block and you can see the details are over here and here's the text and it currently says text block so I'm going to change this to points oh not popings points and then I'm going to add a colon and a space so that it has that little bit of extra room before I actually put the score in and then when I press enter you can see that that updates and then for the next text block I'm going to just put in like a dummy score for now so let's say that the highest sort of score might be 9,999,999 maybe if they score more than that they break the game so there we go that's kind of set up as we want it to be and now I want to do we've got a lot of this original box here this horizontal box that we don't want so let's click on it and there's a tick box over here that is size to content so when I click on that you'll see that that's snapped it back to size and I'm now not using any more of a horizontal box than I need to so what I want to do now is get this box positioned so I want to kind of plop it up here in the top left so you can see the position X and Y are currently have values I'm going to set those both to zero and that'll stick it right in the top left of my screen but I don't want it to be right up there because there's no sort of buffer so I'm going to bring it in by about 30 on position X and 30 on position Y and that just brings it in a little bit now this is where my points are going to be I also want how many lives we've got left to be displayed top right and I could go through the process I've just gone through again by creating the box putting the text in or I can duplicate what I've already got so here's horizontal box here and I might just call this I'm going to rename this so I know which one it is so this is going to be points and then I'm going to right click and duplicate this and you see it gives me another horizontal box I'm going to rename this one two lives and then with this selected what I'm going to do is change the anchor position to the top right and you see we get a little flowery icon and that's telling us that everything we do with the size and position is in relation to that anchor point so I'll show you what I mean by that if I now make it zero and zero it anchors it over here whereas this one you see the anchor point for that one is in its original position and its position is in relation to that so back onto this lives one I do know that what I want on position Y I believe it's Y is 30 and that gets them at the same height and I'm also just going to do position minus 30 to give me some of this just to bring it in a little bit and then I'm going to align this on X I think if I make it one that should align it up about consistently which looks good and we see we get points and a number again we don't want those anymore so from a hierarchy this time I'm going to change it to lives and then the number doesn't need to be as big at all it's only going to be one digit really so what I'm going to do is just put one in there for now and you can see that's moved across as well everything's nice and aligned it didn't stay too far over so now we've got the points positioned in the top left and the lives positioned top right so at this stage we've pretty much created our heads-up display but it's not going to appear in game yet we need to set it up so that it will appear in game so let's compile and save it and I'm just going to dock this up here and then I need to get into my game mode that's where we're going to load in the HUD so we'll open it a little like this we need to get into the full blueprint editor to get at all the properties so let's open this up and the HUD is something that we are going to want to create on BeginPlay as soon as the game starts running so this is the event we're going to be using so from BeginPlay let's create Widget it's a widget that we created for our heads-up display and then the class from here we can select the HUD that's what we called it so it's going to create that for us and later we're going to want to talk between the HUD and the game mode so that the HUD can get the information to display on screen how many lives have we got left what's the current score so what we're going to do is get the HUD out of the return value we're going to promote it to a variable and we're going to call it HUD and that will help us to get that working later to get the functionality into the heads-up display so it's not actually just displaying static values it can change dynamically based on what's happening in the game and one other thing that we need to do with this heads-up display is add it to viewport so we can create it but we've actually got to get it into the viewport for the game so we can see it otherwise it would be useless okay so what I'm going to do now is just comment this up and we're just going to call it add HUD so we know what that's doing and then we'll compile save and now it's time to test so what I'm going to do is I'm going to test in two ways so you can see you don't get confused by it so I'll play first of all and you can see let me just release my mouse lives is up here and here which is not in the aspect ratio that we created originally and that's fine because it's taken up the whole window so if instead of doing that I use this drop-down and we do new editor window you can see this is kind of the size and shape that we'll be working with and it looks to me like our points and lives are pretty much where I want them to be so I'm happy to wrap up at this stage if you want to though you might want to go back into your HUD maybe change the font colors positioning make it so that you're happy with it make it your own you know be creative with it and then moving on in the next video we'll get the lives counterworking so we're going to set how many lives we want the play to start with spoiler alert it's going to be three and then we're going to get this part of the HUD to dynamically show that we're not going to start taking lives away just yet I don't think we'll see but we are going to get the HUD to display that for us so that's what's coming up next last time we set up the heads-up display which you can see I've still got open here but it doesn't do anything yet it's very static so this video is going to be about getting the lives set up and we're also going to create a reset game action as well which is what's going to set our elements in the heads-up display back to kind of defaults and that's actually where we'll start in this video we're going to create the reset event first of all we're going to do that in the game mode I've already got that open from last time and we still need to be in the event graph for it and the first thing I'll do is create a new custom event and I'm going to call that reset good name we also need some new variables to track things like how many lives we've got so I'm going to add a variable and I'm going to call this one max lives so this is the maximum number of lives that we can have which is what will be the default when the game resets and you can see by default it's a boolean which is of no use to us we're going to set it to an integer which can be whole numbers and then to be able to use this you can see at the moment there's nothing displayed for this variable we'll compile it and then we've got an option to set what we want the max number of lives to be I want it to be three so you should then get four lives in total you'll start with one one bolt of fire and then that'll replenish three more times we now need to create one more variable and this is going to be lives so this is how many lives the player has so that's already coming in as an integer which is good and we'll just compile that so that we can do things with it so the first one we're going to want to do when we reset the game is set the current lives to whatever number so we're going to get this in drag it in and we're going to set it so when we reset the game we're going to set the lives to get max lives so the first thing we're going to do is set the lives to whatever the max lives variable lives which at the moment is set to three now what we're going to do is move back to the heads-up display so we can work on the functionality and in the last step we just worked in this designer part of the heads-up display screen there's also a graph part where you can add some functionality and that's what we're going to explore now so let's give it a little click there and the one that we want is event construct so when this is created so we can delete the tick event and we'll also delete pre-constructs we don't need that right now but it is this event construct that we're going to start with one of the first things that we're going to need to do is get this heads-up display talking to the game mode the game mode's holding all the information about how many lives and what the score is going to be so the first thing we'll do is get casting to that and we'll promote it to a variable so that we can talk back and forth whenever we want so out of event construct we're going to cast to game mode and it's bo game mode is the one that we created the breakout game mode and here just to make sure we get the game mode we're going to go get game mode there it is so the first thing we're doing upon creating this heads-up display is making it so that it can talk to the game mode and then as game mode we're going to promote to variable we're going to call the variable game mode so we know what it is and then I'll comment all this with just get game mode so I know what it's doing so now that we can talk back and forth between well I just need to compile that now that we can talk back and forth between the HUD and the game mode we can start doing things with that so back into designer for a sec and remember we said that we're setting up lives at the moment so we're going to get this lives textbox and I'm leaving that out one deliberately for now and I'm selecting the textbox for the number of lives so I've just got it from down here because it's a bit messy up here so just click on that one there and then we're going to create a binding to some functionality so here we've got bind so give that a click and we're going to create a binding and then this opens up a new little scripting window a widget blueprint for us and in here we're going to need a variable called lives so let's create a variable lives lovely this variable needs to be an integer as well so let's change that to an integer and then so that we've got access to it we need to compile and then we can actually use it in in our script so what we're going to do now is drag this in and we're going to get lives and then out of here we're going to create a two text node and what's going to be an integer and that's going to go into our return node like so and then we're going to compile there and save as well and then we need to go back into the game mode to get these talking to each other so what we need to do now is to get the heads up display and from here we need to set lives and that's the the lives that we just created in the heads up display so what we're going to do then is connect this up so that that's going to execute so whenever the game resets it will set the lives to the max lives and also set that on the heads up display as well so that's what's going to display and that will be magnificent so we're going to compile and save and now's a good time to test but we're not expecting it to work and I will tell you why so let's just click on play and see the lives is currently set to zero it should be setting it to three and the reason that this is not working is because we've not yet got anything making the game reset and this only happens when the custom event reset happens so just for now we're going to call this event over here so that this actually works and this is happening on begin play so now we'll compile save and test again and now that's working it's showing that we have three lives so in the game mode it is setting that the player has three lives and it's also displaying that the player has three lives and that's everything that we needed to achieve in this step if you're feeling confident you could have a go at setting up the score yourself it's going to be a very similar process but if you're not feeling so confident don't worry because that's what's coming up in the next step so I will see you there for that now that we've got the HUD working with the lives and that's all being tracked we're now going to do the same for the score so we've got to get the game mode set up to track the score and also feed that information through to the heads up display so that that's all working correctly and we'll start by setting up the binding in the HUD just like we did for the lives so let's make sure we've got the HUD open we have I'll just zoom in a touch so we're going to be working on this box here which is where our placeholder score is and we're going to go into here and create a binding for that which again opens our widget blueprint as in the previous step in here we need to create a new variable for the HUD and we're going to call it points so we've got lives already so let's make a new one and we'll call it points of course we don't want it to be a boolean because that won't work that can only be true or false so we'll change it to an integer which will work for our purposes just nicely and then so we can work with that we're just going to compile the blueprint and that means that we can now drag the points in so we're just going to start by getting the points like so and as in the previous step we need to get a two text node so that we can return that into the return node up here so we're getting whatever the point should be return value is going to be changed to text and then send that to the on-screen display we now need to go back into our game mode so there it is bo game mode and i'm looking for my reset event because when we reset the game what we've got happening so far is we're just resetting the lives but we're also going to reset the score back to zero so that's what we'll set up now so what we're going to do is we've already got our hood here so we're just going to drag out of here and we're going to set the points so there's points there we can set that and we're going to be setting it to zero that'll work nicely so now when we reset the game the two elements of the heads-up display are going to be set the lives to whatever the max lives are and then set points back down to zero now would be a good time to compile that to make sure that that's all going to be working properly now what we're going to need to do is create a new custom event within the game mode and we're going to use that custom event to actually keep score to update the score so we'll right click create a new custom event and we're going to call this update score like so we're also going to need a variable in this game mode to track the score so we'll create a new variable and we're going to call that current points like that that's already coming as an integer for me so I don't need to change it that's good and we're going to select this new custom event and on the inputs here we're going to add a new parameter I'm going to call that parameter points and we'll use that shortly and that's going to be an integer as well okay so what we can now do is we've got this current points so we'll drag this in and we're going to set it and we're going to drop this just at the end of our reset game script so we're setting the score back to zero and we're also setting the score on the hod back to zero so that's all working fine so now we're going to do this update score script which is going to have a check in it so because we're going to take points of the player whenever they die we need to add a check so that if the score ever goes below zero we just set it to zero we don't want to have minus scores so we'll set that up now and hopefully it'll all make sense so the first thing I want to do is just get current points and we're going to add so we're going to do int plus int I believe int plus integer plus integer there we go and we're going to get the points from here which again we can set later and the current points we're going to add those together and then we need to do the check coming out of the result of this because if we're adding minus 500 to 200 that's going to give us minus 300 which we don't want so we're going to add the check and the check is is it equal to or less than like that and we're going to add a branch to this because this is the condition so I'll just drop that down there and then we can connect that up so what we're asking is when we update score is the score first of all going to be zero or less than zero if that's true we just want to set the current score to zero so set current points to zero so that makes sense if it's false however then we can actually add the score on because we're probably going up rather than down so if it's false we're going to set the current points again but this time instead of just setting it to zero like that we're going to set it to the result of this addition here and we'll just pop our we'll pop our reroute node in here just to make that a little bit easier to read there we go so that's going to add those and set the current points to that but we also then need to so at the moment we're tracking the points but we're not sending it to the HUD so we need to get that updating there as well so what we're going to do is get the HUD and then as the HUD we're going to set points to so it's going to follow this whichever way it goes and the points target is going to be the current point so we'll get this and that's going to go in there like so so I've got a feeling that I could do with neatening this up a little bit so let's attempt that just going to drop a reroute in here so I can follow that yeah so that's looking pretty good that makes sense so I'm going to add a couple of comments while I'm here so I'll add a comment up here for reset game and we'll add another comment here oh hello I'll add another comment on this one for update score you can see that my use of spaces is at very inconsistent I apologise for that try and cut out your use of spaces if you can because you can create problems if you're not thinking there we are reset game update score so far so good so at the moment we can track the score but we've got nothing yet telling the the score to be counted when we break any of the blocks and that's going to be the final stage of this particular step we need to get that working so let's compile and save the work we've done here make sure everything's compiled and saved in the hood as well and the final place we need to go in this step is the block since that is where the points are being counted so in the event graph at the moment we've got destroy actor happening but after we destroy it we also want to know how many points was that block worth and then we can add them on to the score so that's going to come after the destroy actor so we're going to need to cast to our game mode since that's where the score has been counted so cast to game mode and it's the bo game mode we want and then objects always going to be get game mode otherwise it won't work and then as the game mode we're going to update the score which is what we want to happen so the target point is that we're going to add on this is why we added this point to the custom event earlier so we can remove points and we can add them on mostly for adding on actually so what I'm going to do is get points and this is going to convert to an integer because I had that as a float for some reason that's not a problem so that is now going to get those points and that's what's going to be added on when we update the score so I'm going to compile and save that so now's going to be a really good time to test this so what I'm going to do is just play the game and I want to see the score being counted so when I release the ball as soon as it hits some blocks that should start being counted which it is and it's also sending that to the hood so everything's working as intended so at the moment if I just let the ball go we're not going to lose anything on the score and we're not going to lose any lives because we've not yet set those behaviors up but that is what's coming in the next step now that we've got the score being counted it's going up and we have got the right number of lives being tracked and that's all displayed in the hood which is beautiful we now need to start taking things away so when the ball goes beyond the paddle we need to take a life and maybe some points as well so let's get into that so the first thing I'm going to do is what happens when we lose a life so I'm going to go into the game mode and I'll create a new custom with them and we're going to call that life lost so this is what's going to happen when we lose a life oh that's not good let's get there let's get the capitals in the right place life lost so the first thing I want to do with this custom event is get it to update the score and we're just going to take some points away so what we can do out of a custom event is call another custom event so we're going to get the update score event and here in this point we can take some away so let's go minus 500 for now let's be really harsh if they didn't want to lose the points they should have been more careful what I also want to do now is create a new custom event for game over so this is what's going to happen when all the lives are gone so let's go custom event and it's going to be called game over good stuff so this game over event is going to be what we're going to do if the lives is zero or less than zero so what we'll do then is when we lose a life we need to check was that the last life basically so let's get how many lives do we have so we'll get lives and then we need to do a check is this equal to or less than zero and then we'll do a branch out of there because this is our condition on the branch and the question is let's just move these over a little bit so after we lose a life we update the score take 500 off but then we want to know what's happening with the lives and if it is or equal to zero or less than zero then that will be true and then we're just going to do game over and that will run our game over script that we will set up okay so now we know what's going to happen if this is true if it's false what we're going to want to do is take a life off so our max lives are set to three we're going to need to reduce that by one and we're also going to need to display that on the hood so the first thing we'll do we'll come out of false then we need to set the current lives so we're going to set lives to whatever our lives was and we're going to take one away from it so let's get lives again and then we're going to do an integer minus integer and we're going to do one so be careful with this one don't put minus one in there because we're already some minus operations so we're telling it to take one away and then that's going to go into there so we're setting the lives to lives minus one so that should take three down to two we're also going to get the heads up display and as the heads up display we also want to set points on that as well and that is just going to be the result of that so whatever we've just set the points to set that on the hood as well that should all be good so game over what I need to do for this one is just for now it's kind of a placeholder but we're just going to get it to quit the game so whenever we lose all our lives and game over is called it should just quit the game so let's comment this game over and we'll comment this with life lost and that should all make sense but even though we put this beautiful script together this life lost script nothing yet is going to call it and that happens in the ball blueprint because that's where the current ball is being destroyed so let's open the BP ball up so here is where the ball is destroyed new ball when one is destroyed I've got it at the bottom of all my scripts and what I'll do is just create a little bit of new space move these all over to the side a little bit and then what we need to do is talk to the game mode so let's get the game mode and from the game mode we're going to run life lost like so so let's just connect this in the middle so before it creates a new ball it's going to run this life lost script so now let's give all this a test and see if it's going to behave itself shall we right so I'm just going to fire the ball what we're looking for is that the points are removed so it should take 500 points away which is going to set it back to zero here and we lose a life as well that didn't work ah okay I know what I did right silly shame let's go back into the game mode I'm setting points not lives you absolute mug shame delete that lives so we're going to set lives to the result of this okay hopefully this will be more successful now let's compile and test and we'll fire this off so again remove the points hopefully and take a live off we lost all the points we're down to two lives brilliant let's try this again so now we're going to lose more points hopefully and we're going to lose another life yep and we'll do this one more time and here's the final one does game over work when we lose our last life not doing very well for points on this one am I yay it works okay so that pretty much ties this step up so what we've got working now is both counters lives counters are doing what they should lives starts at three goes down to zero and then ends the game the points will go up but every time we lose a ball we're going to lose 500 points you can obviously change the mechanics of that if you want maybe you don't want to be so punishing just take 100 points off maybe you want to start with more or less lives by changing your max lives variable that's totally up to you but that's going to do it for now in the next step we're going to be setting up a game over screen to make it a little bit clearer to the player that the game is in fact over and then we wouldn't quit the application if we were running this on a phone we'd probably return back to a menu screen but we're just going to go probably with game over message and then we'll just reset the game so I'll see you in the next video for that now that we can make it so the player runs out of lives and there's a game over state what we're going to have to do next is communicate that to the player and we'll do that through our heads up display so we'll go straight into our HUD into the designer and we're going to put a game over message in the middle of the screen when all the lives have gone so to get started with that I'm going to create a new text block and what I want to do is anchor that to the center of the screen and I'm going to set the position x and the position y to zero but if you look it's still not quite in the center and the way that we're going to sort that out is this alignment so if we do 0.5 and 0.5 that then puts a 50% on both axes along the way of the alignment which ends up being centered that's what we want so that's now going to stay in the center so for the text we're going to want it to say game over and I'm going to put that all in caps because I want this to look kind of old school so we'll do that I'm going to put a a sad face in there and I want to size the the text block to the content to make sure the alignment stays where I want it so that's a good start now we've got it saying game over but I don't think it's big enough so let's get the the size of the text a little bit bigger and to do that we're going to drop down this font section underneath appearance and here we can change the font if you've got other fonts installed you can change them what all I want to do here is change the size so I'm going to change the size to something like 60 nice and big make sure the player can't miss it what we need to do next is put a behavior on this to make it invisible most of the time and only become visible when the player loses all their lives and for that we need to scroll down to behavior and you'll see there's a visibility section and we can bind some behavior to that so I'm going to click on bind and then go to create binding and then the return node is interested in whether or not it's going to be visible hidden or whatever so we need to set that up but we're just going to leave this here for now because before we can get the text to be shown or not shown we need something to trigger it so we're going to have to go back into the game mode set up a game over variable and we're going to use that variable to then trigger whether or not the text shows so let's get the game mode open here's my BO game mode here's all the scripts I've got in here so far and the first thing I want to do is just create a new variable and it's going to be called game over question mark is it game over and we'll save that and it's automatically coming as a boolean which is what I want because this state's going to be either true or false and then what I'll do is compile this because I want the default state of this to be false and we can see that it currently is set to false so I'll leave it like that we want this not to be the text the game over text we want it not to be on screen at the beginning of the game so anytime we start a new game we want to make sure that this script is also set to false so here's our reset game script and the last thing I want to do now is after we've reset everything else we're also going to set the game over to false so every time we start a new game it's no longer game over and whenever it's game over we need to set the game over variable to true so what we're going to do is get game over here and we're going to set it to true whenever game over happens and then what we'll do is add a delay of five seconds so let's just set that to five before it quits the game and we're going to change this quick game I think in the next step to just resetting the game so we don't have to exit the application but that should do it so game over should be the only thing that sets the game over to true everything else should be setting it to false so we'll compile that and that will mean that now from our heads up display we can use that game state to decide whether or not this should be visible or not so we already set this up previously so we can get to the game mode so let's get the game mode and then out of here I want to get game over we need to know what that is and then that's going to become a condition on what to show so what we want to do is is game over equal to something there we go so if game over is set to true then we want to return the visible and we're going to go backwards a little bit on this one and out of here we're going to create a select there it is there it is and what this is going to do is if this is set to true we are going to have this be visible so what we're going to do is plug the result of this into the index and that gives us basically is it true or false so if it is false we want it to be hidden if it becomes true make it visible and that's all we're doing to set this particular bit of the heads up display up so now we need to run out of lives and test if this is working so let's compile and save I'm going to play and now I'm going to lose some lives okay so I'm down to my last life so now I've just released the ball when this ball comes back down my hope is that it will tell me it's game over which it is it'll wait five seconds and then it will close the app hey and everything worked so that brings us successfully to the end of another step well done for getting this far you're doing very well at this you're making a game wow well done so in the next one what we're going to be doing according to my notes is setting up the reset game so what that will entail is just when we lose all our lives instead of quitting the app we'll reset it it's a quick step but it's one that we need to do so I'll see you for that one we now have a game over state setup for the game and we are communicating that to the player we're leaving the message on screen for a little while and then we're having the application quit and what we're going to do now is just make that game over state the actions that we do at game over a little bit better and we'll start with making it so that no new balls are spawned once it's game over just because it will look better and to do that we're going to go into the paddle the player paddle and that's because this is where spawn ball is happening and what we're going to do is set a condition on this so that the ball will only be spawned if game over isn't true so what we need to do first of all is get the game mode and as we've done in previous blueprints we've not got it as a variable here so we'll set that up so up here on begin play before I do a new ball I'm going to get game mode and I'm going to make that a variable so we'll do cast to game mode and that's going to be our BO game mode just as it's been every other time and under object we want to do get game mode and then as game mode come out of here and we're going to promote that to a variable and we're going to call that variable game mode let's get rid of the space shape there we go and we're just going to set that up there and then we'll do new ball so let's comment this up a little bit so this little area here is getting the game mode and that gives us a new ball I don't need to comment that it's already there so now here we have access to the game mode so what we'll do is go to the game mode and we'll get it and then out of that we need to get the game over variable we really need to know if it's true or false, don't we? and that then is going to feed a branch so let's get a branch and our condition of the branch is is it game over? so if it is game over we actually don't want to do anything so I'm going to disconnect this so I'm going to hold alt and just click on that wire and we're only going to move forward in this script if that is set to false if it's not game over we can spawn balls but if it is no spawning no balls x-ray on the balls eh? I think that's right so that's pretty good we've got to check on that now what we want to do is make it so that the game resets instead of quitting and that's in our game mode I believe yep so we're currently set to quit game I don't want to quit anymore I want to reset the game I'll do that by just loading the level again so after the delay I'm going to do open level and here you can type the name of the level and we can see here that mine's called level 1 and you need to get this typed exactly right so capital L E V E L and then the number 1 for me and that should work so let's compile that make sure that I compiled my paddle as well which I didn't and save everything and we need to give that a test so I'll just cut out the bit where I lose most of the lives and then I will see when it's time to lose the last life okay so here's the last life so what we're hoping for them is that when this life loses no new ball spawns and the level after five seconds will reset so game over's there no new ball let's reload the level there we go we've got a game guys okay so that's kind of it then for the nuts and bolts of it to get us up to the kind of prototype stage now we've got something that functions as a simple breakout game what that means though is that going forward we can spend a little bit more time on making this pretty and then some new features so if you cast your mind back to step one I showed you that we're going to have a bit of a castle we'll have walls that we can knock down the ball's going to be visible when it goes behind things it's just going to be good so moving forward it's going to be the fun stuff or the things that I think are fun not that this hasn't been fun but everything's just been black and white and boring so let's make it more beautiful yes let's do that now that the functionality of the game's basically where we want it to be now we can start having a little more fun and making this thing look prettier and the first thing we'll need to do for that is to bring in some more of the assets that we're going to use for the project so we're going to theme it to look like a I don't know what the area of the world's called like a valley maybe and that's where the ball's going to bounce around we're going to put a castle in there I'm going to smash the castle up it's going to be wonderful but first of all we need those assets so let's go to we have a static measures folder so we're going to go in there and we're going to import if you are using my shared files if you've got access to that via Patreon or if you've got access to the UE4 breakout folder by clicking the link in the video description then you should see breakout assets and breakout tutorial the tutorial folder is just this project that we're currently working on and the assets live here and we're going to be looking in the static measures folder and you can see a lot of these we already have so the ball block and bounds we already have as we do with the paddle but the others so the castle gate the cliffs cliffs and cliffs the grass and also the tower and wall we need to bring all of those in so I'm going to select them all at once do a mass import and click on open and then here we just need to make sure we do one check so the mesh section it might be contracted like that make sure you expand it and we're looking within here you could also maybe need to click on this bit as well within here we're looking for this option combine measures make sure that that is enabled because it's very possible that when I've made these measures they were made up of multiple measures within the file and if that's the case we need to combine them to stop things getting confusing so once you've done that you can click on import they will then all come in or I can just click on import all you may then see this error message don't worry about it it's just because I didn't worry too much about my models being perfect because they're just simple models and it makes no impact on what we're going for so I'll ignore that error and then we have these objects that have all come in I'm just going to save all to get rid of that asterisk which means that then if the project crashes I'm not going to lose anything and then what we can do is have a look at some of these so let's go to castle gate here's what it is you can see some of them have multiple material slots and it's all of the ones that are going to become destructible later we'll have multiple material slots if it's not going to be destructible such as the cliffs that should just have one material slot like that and we're going to put a material on the ones with one material slot first so I'm just going to close that for now I'm going to go up to content and into my materials folder and we need to import a texture file so let's go to import and then back to the breakout assets here's my textures folder and it's just the color palette.tga we're going to use the target file for this open that and then make sure I save it and that's going to be used in the material so let's right click create a new material I'm going to call it m underscore palette so what this material as you can see is it's what we call a texture atlas so I've put all the colors that I want to use in one file you can see I left myself some space around here if I wanted to do any other colors but these are the ones that end up using I think I use some of the white down here as well and that means that we can have lots of colors on an object without having to use multiple materials so let's open up this palette material I'll just put the main material node for the palette over here and then what I need to do is you can see here's my preview we're going to put in the texture that we just brought in so I'll right click and I'm going to create a texture sample node text sure and there it is listed or if you want a texture sample node you can also just hold T on your keyboard and left click and that'll create one too so let's just close that and then the texture that I want to use is just here I'm going to choose color palette that's the other one that we should have available so we'll click on that and then I'm going to connect that to base color and then after a little while when it catches up you'll see that the preview of the material goes here and you also get a preview of the finished material added to a sphere over there so there's a couple of other things I want to do with this material one of them is just add the texture sample into the emissive color and that just means it will kind of emit its own light so we don't have to worry about lighting if we don't want to which will also mean that it will run a lot more efficiently on lower end hardware and then the final thing is I want it to be rough I don't want this to be shiny at all and the way I'm going to achieve that is by adding a constant to the roughness and I'm going to set that number to one one being completely rough zero being not rough at all and then I'm going to save that material and I'm going to start adding it to some of my assets so I'm going back into my static meshes folder and then as I said all the ones that will be destructible later won't get this material but the cliffs definitely will so let's open one of the cliff pieces at an angle we can see and then up in the material slot here I'm going to just choose m underscore palette and then that color should be kind of nice I might go back and just take the emissive down because I'm not a massive fan of that so let's just go back into my palette and so the emissive at the moment is stronger than I would like so I'm going to multiply that by a number just so it's not too strong so let's add a multiply node and the result of the multiply will be what goes into the emissive color a will be this and then b is going to be another constant and I'm going to set this to a quite a low number let's try zero point one hopefully that's better so I'll save it and then go back to my cliffs and yeah now we can see a little bit more of the kind of low poly look some of the triangles showing up so that's kind of nice nice okay so that's the first one done let's get cliffs two we'll add the same material palette let's see if we like the look of that yep save that we're going to do cliffs corner add the material again yep that's looking good we'll save that one we need to do the grass yep looking good and there should be one more that I've somehow not imported so I'll do that now so back into static meshes and I missed the ground so let's import that so yeah all the settings should be fine open that up add my palette and save okay so I'm done with all these now I can close them and if we have a look in here these now all show that they've got colours on them so the pieces that will be destructible castle pieces they need to be put together using a different material otherwise when we destruct them it won't get the right colours they look really odd we won't like it so we'll create one master material for those that we can easily change the colour of so back into my materials folder and I'm just going to call this material m underscore destructible destructible I think it is destructible okay and we'll open that one up and this is going to be put together in a very similar way but in the base colour we're going to use a vector parameter and that will allow us to change the colour easily and we're just going to call it base colour that's nice and easy and I'm going to have it set up in the same way as my other material so the roughness is going to be a constant of one so we'll set that up and then I'm going to have a multiply that goes into emissive colour that's going to go into a and a constant is going to go into b and that's going to be set to 0.1 just like I did with the palette material okay so that's basically built but this colour's not right yet okay so to get the colour for the base colour I'm just going to cheat a little bit because I want it to match up with what's in our palette so what I will do for that is I'll open the palette up and I'll just bring it in as a smaller window and then I'm going to go back into my destructible colour here so I'm just going to put it out of the way and then click on my base colour go to this here to select the colour the colour picker here's the eyedropper tool and then I should just be able to mouse over that and I can choose so the destructibles are made up of these three different shades of grey so I'm going to start with the darkest grey and then I can click on okay and I can close that for now and that will just set up the darkest one of the three colours and that's done for now so I'll save this and then I'm going to close the destructible material for now and I'll close the palette as well for the time being and then this M underscore destructible I need to create three material parameters from so let's do right click create material instance and then this M underscore destructible material I need to create three material instances from which means that I've only got one main material which is more efficient but I can make small changes to it so let's right click on here create material instance and I'm going to call this M underscore destructible 1 and we'll do the same create material instance and this one's going to be M underscore destructible 2 and then the next one can you guess what I'm going to call it M underscore destructible 4 I'm just kidding destructible 3 I am so funny right so the first colour is actually fine because it's the the dark colour so that one's okay I'm just going to drop that there for now but this one's going to need the next colour so what I'll do is just open this colour palette again so I can get to it and then here's base colour I can click on here get my eyedropper and there's the second of the colour so I'll click on that and then I can click on okay and save that one that gives me two colours and then destructible 3 which should be this one I'll do the same thing with turn on base colour click on here get my coloured sampler and then get that colour and then click on okay save I should be able to close that now and you can see that hopefully I have three different colours and I can now add these three colours to my destructible meshes all the meshes that will become destructible so let's start with castle gate so the material should have a slot so I've got colour 2 and colour 3 so that tells me which one that I want to use on them that's why I named them this way so we've got destructible 2 and destructible 3 there you go that looks pretty nice so that's that one done let's save it and then I need to open up tower and again it tells me colour 2, colour 3 and colour 1 on this one so I'll put colour 1 on here destructible 1 colour 2 on this one destructible 2 and colour 3 is destructible 3 and then hopefully as we move around it we can see that we've got tower bits we've got darker windows a lighter bit on top that looks pretty cool save that one and then the final one is the wall that should have darker coloured bricks on it and that's using colour 1 and colour 2 so let's have destructible 1 which is the brick colour and destructible 2 which is the rest of the castle wall okay let's save that I can now close all of these other windows I don't need them I've got all my assets set up and ready to build another block out of the level with which is what we'll do in the next step now I've got all the assets in materials made and assigned we can do another block out of the level put a castle in there something to smash up so I'll see you in the next step for that right then now that we've got all of our assets and materials in and made and assigned we can start doing something with them so we're going to do another level block out and we'll probably do it over two steps in this step we're going to put in the ground and the cliffs and get the kind of play space done and then in the next one we'll put the castle together as well and then we'll have something to work with and then we'll start making things destructible and assigning blueprints to them again so the first thing we need to do in this one then is get a ground in place which I'm going to start with so if we go into our static measures folder here is ground and what I'll do is just I'm going to drop it anywhere and then I need to set the location to zero zero zero and then I'm going to put it in the corner in fact I'm going to bring it back a little bit as well so I'm going to put it over here so it's kind of lined up with that back corner and then I'm going to scale it so I'm going to make it wider than the play area and then longer than the play area and that will mostly do it for the ground there is one more little thing that we need to do and I'll try and show you what it is so if I send the ball off you should be able to see as it gets into the distance that half the ball is sitting underneath the ground which is going to look weird especially when we start adding shadows and things that's going to look all kinds of odd which you don't want and we need to calculate exactly how far to drop the ground to make sure that it's underneath the ball and thankfully that's easy to do if we click on the ball here or hover over the ball you can see the approximate size is 50 by 50 by 50 so if it's halfway through but the ground is cutting halfway through then we only need to drop it half of the the height of the ball to get it in place which means 25 basically so we'll select the ground and then Z in Unreal Engine is the height so we're going to go minus 25 on the location Z and that should be perfect we'll just play it first of all make sure that the ball doesn't look like it's going underneath the ground nope that looks good okay so I'm happy with the placement of the ground happy days next thing I want to do is get some of the cliffs in place now remember we're going to keep this bounce here this is what everything's going to bounce off it's already doing a fantastic job so what we'll do is we'll put some cliffs there for decoration but they won't collide they're just there to make things look pretty so I'll start with cliffs one and I'm going to make the position zero zero zero so let's set that one to zero and then that one to zero and that one to zero and then I'm not particularly happy with the scale of this I'm not sure why I made it to this scale but it's smaller than I want and the scale that I like with these assets is 2.5 times bigger so 2.5 tab 2.5 tab 2.5 and the reason I like that is because you should see that that now perfectly lines up with the grid lines which makes snapping much easier and I'll try and show you this so I'm going to change my location snaps to 500 I believe is right it will be so if we move it there you'll see it now snaps to grid points but I actually going to need to move it slightly different so let's just change that back to 100 for a second and it needs to be there and then I'll change my snaps back to 500 and as I make copies it will snap them in place if I hold all on my keyboard and move it that'll create a copy and I'll just put it there and I'm going to leave that as it is for now I want the gap there because I'm going to bring in cliffs two which is going to fill in that gap so that's that one done let's bring in cliffs two and then we need to change the scale again to 2.5 2.5 2.5 change the location to 0 0 0 and then I'm going to put these in position so I know that needs to go there I'll change my snaps back to 100 so I can get the depth of this right they now look like they're lining up I'll go back to 500 hold alt to make a copy and drag into place that looks pretty tidy I'm happy with that so I'm just going to keep those there for now I think in fact I might just do one more copy of this one alt and there and then I should be able to put the corner piece in just there so let's bring that in same again 2.5 tab 2.5 tab 2.5 get that in place and then position 0 0 0 and then it's just a case of putting this exactly where I want it to be so I'll change my snaps back to 100 for this and that looks pretty good so you can see that all of these pieces should fit together it's a modular kit that I created although weirdly although these fit together perfectly in Maya there is a bit of a weird join there but we won't be able to see that in game so it's not a problem it just upsets me a little bit but anyway that's fine I might also I think the colour's slightly off on this one but I will fix that in the texture for download time so don't worry about that it might look weird on mine but it'll look much better on yours so don't you worry anyway there's that first side done and we could just place the other pieces on the other side by hand or we could be a little bit smarter than that and select them all so I'm just holding shift while I select them I'm going to hold alt and just drag them over here and that red arrow there indicates that I've just moved them on the x-axis so the x-axis is what I need to change the scale if I go to minus 2.5 what that will do is invert it which is perfect for what I want because then I can just bang that in place and I've now got two sides might be a little bit too symmetrical but it will do the job and then I've just got a little gap here that needs filling which I'll just fill with this one so hold alt I'm going to turn my rotate tool on which you can do by clicking here or I'm going to hold E on my keyboard press E on my keyboard to open that and then I'm going to rotate it by 90 degrees and then I'll leave my snaps on 100 for this and just get it to line up and you should notice that it doesn't fit perfectly that's overlapping a little bit and that's more my own poor planning than anything else but it is an easy fix so I'll just put my scale tool on by pressing R and I'm going to scale it in and you can see there that's when it perfectly matches so I'm going to put that in there and that's my level done although I did forget to press alt when I copied it so let's get another copy of this so put my move tool on hold alt and I'll put that back in place there we go Shane beautiful so we're almost there let's see what that looks like so we're getting there I'm you know a little bit so destroyed about that joiner we'll find a way to fix it don't worry the assets that you download will probably be fixed will probably have that fixed so don't worry it's just upsetting me anyway that's okay the only problem is let's just go back to play this black area up here and then we need to turn off this so you can't see it anymore I think what I also want to do is just shift everything along one so I'm going to select all the cliff pieces because we can't see any of the white here which suggests that the the collision is not going to look right so I'm going to drop my snaps down to 50 now just so it's just intersecting that line there so that's better that's pretty much lined up where I want it to be and just in case I'm just going to set my snaps back to 500 hold alt and I'm just going to snap that didn't work hold alt and then make a copy just so that that's going to be covered up I don't want the the end of the world to be present so that's pretty nice so this black area up here needs something doing with it as well and the way I'm going to do that is with another piece of ground I'm just going to bodge it really but it will be fine so I'm going to set the location to 000 just to get me started and then I want the scale to be wider much wider than the the kind of play space that's pretty nice and then the height is going to need to be fairly big as well so let's do that and now what I'll do is bring this back try and get the height to line up not quite so I'm going to change my snaps back down to 50 now and I'm going to rotate this by just 10 degrees and the idea being that this will intersect where the cliffs are and look like it kind of becomes a hill that's the idea so I just need to move that up a touch that was pretty good that intersects just about in the right place so this doesn't need to be a position ultra perfectly but close enough and then what I need to do is just make a copy of this so I'm going to put my rotate tool on hold alt on my keyboard and then rotate it around to create a copy I might just need to make it a bit taller on this axis and then I'm going to drop this into place on the side as well that looks pretty good does that join about right it does then what I need to do is make one more copy alt drag it over here and now what I need to do is just take that rotation off of it so that I can just flip the scale so we're going to go minus this number on the y-axis I think I need it might be the x-axis view depending on which way you rotated and then I'm going to rotate that back 10 degrees and just put that into place as well and then hopefully when we play it that looks like a full game world so this is pretty good so far if we play it the ball looks like it's bouncing off the right place that's pretty good there's one last thing to do then and that's to hide the game bound so that we can't see it in game so I'm just going to select it scroll down in my details panel and under rendering I want act to hidden in game tick you can also if you want to tick that so you don't see it in the editor that's your choice I'll leave it on for now I'll get rid of it later and then we'll play again and now when we throw the ball into the level it should look like it's bouncing off the cliffs which it does okay so that's it for this step that gets us started one thing that you might notice is that there is a difference between the colors that we're seeing in the editor and the colors in game they're darker in game and that's because I'm currently in an unlit mode in here if we go to lit they will look identical there we go so that's just something that might be bugging you I just thought I'd point that out now but that brings us to the end of this step in the next step we'll repeat kind of what we've done here but we'll build a castle and then we'll be ready to start getting the gameplay working on that as well so I'm looking forward to it I'll see you there now that we've got our level our world kind of built next thing to do is get the castle in there which again I've taken a modular approach on building this so that you can build different shaped castles if you wanted you could make it bigger smaller I'm going to create a really basic one but you can if you want to build something a little bit more ambitious that's your all choice I'm not going to tell you you're wrong so first thing I'll do I'm just going to switch this back to unlit so it's a little bit easy to see what I'm doing and then I'm going to start putting assets in so I'm going to start with the gate which is going to be kind of the center of the castle so I'm just going to drop that roughly in the middle and then I'm going to set everything to zero and we'll see where that's ended up we're going to push that back a little bit and that should fit perfectly because we've already dropped the floor down so that everything should match up so I'm going to put the front of the castle about here and at the moment I've got my snap set to 50 I've modeled all the pieces of castle to fit a hundred so if we want something to kind of fit together nicely 50 snaps is pretty good so I'm going to put the first piece of castle there the gate's going to go out the front I'm just having one gate on this and then what I want is a piece of wall there we go and I want to just get that to sit on the ground as well and then line up with the gate which should be like that that should fit perfectly then we're just going to put three pieces of castle on either side of the gate just to get us going so there we go that's pretty nice now what we need are some towers at the corners so let's bring in a tower try and get that on the ground if I can there we go and then drop this into place which should be roughly on the corner so let's just put it there for now and make sure we've got no gap yep that's cool I'm going to hold alt on my keyboard so that when I move it it copies it put it over to the other side that looks pretty good pretty symmetrical nice and then what I want to do is just select everything apart from the gate I don't need the gate and I'm going to move this back so I'm building the back of the castle as well so two one two one two one two one two one two hopefully I've moved that back far enough I'm going to put seven pieces of wall in here so we'll see I might have to move it in a second so we'll just fill that gap in with another piece of castle wall very good and then I'm going to take a piece of castle wall I'm going to rotate it by 90 degrees and then drop this in place over here where are we about there let's make sure that that looks right yep that is pretty lined up and then we'll create some copies of that three four five six do you know what it's only six instead of seven it's not going to be perfectly square this castle but that will do I also need to just make a copy of that because I've forgotten to actually duplicate it again and then we'll get these six pieces of wall and we'll drop them over on the other side so I'm holding alt to copy again or to duplicate there we go and that builds the castle now you'll notice that it all looks really repetitive but what you can do if you want to is pick some pieces of the wall and then let's just work out which axis we need to go on use the y-axis if we set that to minus one the bricks are different on the other side so we can add a little bit of variety like that it doesn't really matter too much don't spend too much time getting your castle perfect because at some point you're going to replace this with new assets that are actually blueprint so all this really is is blocking it out making sure that we like the layout so let's have a look I like the size and position the the collision should work but obviously nothing will disappear or get destroyed just yet so that's fine so what I want to do now is put some of these blocks inside now I might replace these with something later but for now what I want to do is just get rid of the ones that won't fit inside so these ones on the end are definitely not going to fit oops deleted some wall don't do that and probably these aren't going to fit either so I'll get rid of these and then the remaining ones I'm going to pop inside the castle so all of these should be the remaining blocks I'm just going to pull these forward and that's pretty nice that's the treasure inside the castle for now let's just have another look do we like the look of that? I think we do everything is working beautifully so that is now the level block out basically done we've now got the world the new world the little valley that the castle sits in we've got a castle and we've put our blocks inside so they've been protected by the castle as well what we need to do next is add a little bit of lighting to this level and we're also going to put some of the grass in and around just to decorate it a little bit and that'll kind of cover the whole look of the level for now so I will see you in the next step for that now we're going to do a little bit more decoration making it look pretty before moving on to some more blueprinting and in this case we're going to add a little bit of lighting to make it look nicer and some little tufts of grass just just to make it look a bit more visually interesting so at the moment we've got this awful unlit view so if I change it to lit it doesn't look much better so I'm going to improve that by adding a directional light so we can get a directional light by going over to lights in our modes panel and here is directional light up at the top and we're just going to drop one of those in there and you'll see that straight away it makes the whole game look like ass so we're going to have to make some changes to improve that and I'm going to start with changing the intensity to four which will really help it doesn't blow out the colors so much you might choose a different number you might prefer three maybe you want to do a little bit in fact maybe I prefer three I'll leave it on three for now and then what I'm going to do is change here so I could change the color of the light by doing this but I don't want to do that I'm just going to use temperature instead and then I can drag the temperature down a little bit towards the warmer end of the spectrum to give it a kind of an end of the day sort of feel next I want to do is work on the shadows a little bit I'm not a massive fan of these shadows down here which I'll get rid of in a minute but what I do want to do is make sure that all shadows in my game are dynamic and I'll do that by changing the light to movable and you'll notice a little change in the shadows that means that it won't pre-calculate shadows this is fine for us because we're only going to have things that need to cast shadows casting shadows and for everything else we'll just turn it off and we'll start doing that with the cliffs in a minute but first of all I'm just going to try and choose a nicer angle for my light to be shining so I'll just have my light selected with my rotate tool and I'll make sure that the light is sitting in the front of the castle and then maybe not like that and then maybe I will just change the angle a little bit there as well that's kind of nice I like that okay next thing then I don't want ugly shadows coming off this side of the valley just doesn't look nice so the way I'm going to get rid of them is I'm going to select all the cliffs from my world outliner so that's all of them and then in my details panel I'm just going to type shadows to help me find it and there's cast shadow they're all casting a shadow let's turn that off it makes everything look a little bit neater and it's also saving some resources so that's good and I'll just press escape to deselect all of those so now I'm fairly happy with my lighting I'll just have a quick look at it in game yeah that's not bad I might make some changes later just to stop some of the shadows being too harsh but the overall colour of the environment and the landscape I like so I'll keep that as it is for now next thing I'll do then is add some of these tufts of grass which we've got here and I'm going to do that using the foliage tool so the foliage tool lives up here we'll turn it on and the first thing we can do is drop some foliage here so we'll put our grass in there and then we'll get all different settings that we can change but first of all we're going to have to update our static mesh for the ground because if you look at the moment we can paint on these top of the cliffs which is good I want to do that but there's a problem when we try to paint on the ground or any of the ground pieces up here and it's to do with the way that the collisions are set up so we just need to turn collisions on for a minute to allow us to paint and then we can turn the back off so let's just do that now let's find all my pieces of ground there they all are and then I'm going to look for the collision bit here and there are multiple values because I've messed around you should have it set to a project default but I'm just going to make sure that block all is turned on for now and then I can go back to my foliage tool and when I drag my brush around it should allow me to paint everywhere there we go that's a good sign now we can set up some of the settings on the the brush and on the foliage to get it ready to paint so the first thing I want is actually quite a small brush so I'm just going to use my square brackets to size that down to something like that I only want small little tufts in a few places so I don't want to overdo it I'm also going to put the paint density up at one and make sure the static measures is ticked there then we'll click on the grass here and we can make some changes let's just make a bit more room make some changes here so the density there is fine I'll set the radius to 100 that stops them from appearing too close together scaling uniform is good I want them to be a bit bigger 2 and 2.5 so the smallest grass will be two times the original and the largest grass will be two and a half times the original that's fine I don't want to align to normals on this because I want the grass to pretty much point up so I'll turn that off because this is at an angle up here so I don't want that to to happen and also these are all funny angles on the cliffs as well so we won't do that I do want random yaw and I'll set a random pitch angle of five just to add a bit of variation I don't want the grass to cast any shadow so I'll turn that off otherwise it could look very messy make sure no collision is on and that should do it and then it's just up to you to put some little bits of grass around your level so just to make it look a little bit prettier and the thing about this grass that looks good or that I think looks good is when we make it look kind of really pixelarty later that'll look really cool so let's just have a little look at that in game yeah that looks okay maybe I've overdone it a little bit but I'm a maverick sometimes I get a bit out of control but that'll do nicely for now I quite like that maybe I need to soften the light a little bit but that looks pretty good okay so that's going to do it for this step we've now got better lighting we've got dynamic lighting as well so the shadow is going to be nice and dynamic we've also got a bit of decorative grass in there we're now ready to make it so that the pieces of castle wall and the towers etc when we hit them they'll disappear so that we can get into the treasure on the inside so I'll see you in the next step for that now it's time to get these pieces of wall and the gate and the tower to start disappearing when they're hit just like the blocks do and to do that we're pretty much going to follow the same process we're just using a different static mesh so I'm going to go into my blueprints folder and I'm going to do it for the wall seeing as that's the there are more pieces of wall than anything else so let's go for blueprint class and I'm going to go for an actor and I'm going to call this bp underscore block because it's now a block piece but it's a wall variant of that so that's my name for it bp underscore block underscore wall let's get that open and then the first thing we need to do is add that static mesh to it so we're going to add component it's going to be a static mesh there we go and we'll call it wall so I know what it is and then static mesh over here I can choose the wall hopefully there we go I'm just going to check for the placement of the pivot yep that's perfect so far so good and then the next thing we're going to do is really really important if you don't do this it won't work we're going to be making this disappear when it gets hit and you need to make sure that hit events are being generated and I'll show you what I mean if I scroll down here on the right hand side here is collision so you can see here it says simulation generates but we can't see what all of that is if we just move that over simulation generates hit events so unless we tick that box hit will do nothing so let's make sure that that's ticked next up we need to go into the event graph for this and we don't want any of those let's delete them what we do want I'm going to right click on the wall go to add event and it's on component hit and then the first thing when something hits it we need to check was that the ball that hit it because it's only the ball that we want to destroy this so we're going to cast to the ball there we go BP underscore ball that'll do nicely and we're going to use that to see if that was the other actor was that the thing that hit the wall and if that was the case let's destroy the actor so we'll drag out of there destroy actor and that should do it let's compile that and we'll give it a tiny little test so we now have this here now unfortunately I don't know of a way of just replacing this static mesh with the blueprint if I go BP underscore it doesn't show up if anybody does know a way of doing that give me a shout that would change my life so what I'm going to have to do is delete these pieces of wall so let's just put my a better tool on so let's delete these for now and I'm going to bring in my BP underscore block underscore wall there it is and then it's just a case of getting this into place now hopefully my snaps still mean that it should yeah automatically go to where I want it and then I'll hold alt and I will create some copies of this okay so now I've just done the front row so it's going to be a good time to check that this is behaving as intended so let's hit play and I just want to hit something at the front and that's not a good shot there you go that disappeared so that's now behaving as intended all we need to do now is replace all of the wall pieces with this blueprint and then I'm going to start letting you go out on your own a little bit now you need to create two more blueprints that function exactly the same so you're going to do another one for the tower so I would call that BP underscore block underscore tower and I would make sure that I do all the same steps that we just did for the wall you might want to also invert some of these pieces of wall or these new blueprints so I think it's just one if we do minus one on that we can flip it around so we get different brick arrangements but fair warning there's every chance that we're going to replace these again when we move up to the destructible measures so the ones that actually break apart so don't spend too much time making this look pretty because it could all be for nothing so that wraps up this step make sure that you spend the time to get all of the other pieces of wall disappearing and then I will see you in the next step hopefully you've now got all of your different pieces of castle turned into blueprints that will disappear when you play the game so what you should have like I've got here I've got BP underscore block wall which is fine that one all works and then basically just a copy of it which is BP underscore block underscore tower and BP underscore block underscore gate and I've just replaced those in my level you can see some of the little blueprint icons showing below them and what I want to show you is that this works but also I'm showing you something else so if I just begin the game from here you should see that they are disappearing but I'm hoping to demonstrate something else and that is when the ball goes behind the castle it's really easy for the player to lose it I can't see where it is now so I can't be positioning my paddle in anticipation of where the ball is going to come back out and that's going to get even worse once we start having these measures destruct and there's crazy crap flying all over the place so we need to do something to help the player out here to give them a way of seeing the ball when it's behind some of the measures and that's what this step's all about so we're going to do that a really kind of cheap nasty dirty easy way but it will do exactly what we want we're going to do it through the use of another material one that always appears on top which will be perfect for our user so what I'm going to do is go into my materials folder first of all and create a new material and I'm going to call this material M underscore ball trans can I spell translucent translucent is that right or is it just the same translucent I'll change it later if I realize it's wrong hate spelling things wrong anyway let's open this up and this is going to be a really simple material to put together and the trick is we're going to disable a depth test and that's going to make sure that it always appears on top so we're going to set it to a white color so I'm just going to use a constant three vector for that there it is and to be fair I could also just use a constant for this but I might want to change the color later so we'll just set that to white for now then what I want to do is make sure that I've got an opacity available to me so I'm going to change the blend mode of the material to translucent and then you'll see opacity becomes available so I'm going to put a constant into there there we go a little constant and I'm going to set that to 0.4 and that's just going to be that we've almost got like a ghostly version of the ball behind things it's not going to be fully there so that's good that's pretty much the material done the last thing we need to do is click on the main material node we're going to scroll down to the translucency section we need to drop down here for the advanced options and this area here disabled depth test tick that box that's what will make this material show above everything else then we can save this material and go and add it to our ball blueprint so let's now go to the ball here it is and the way I'm going to do this is I'm actually going to add another ball and have it slightly smaller inside the ball because I don't want to change the material that's on the ball that's got our physics material on it so I don't want to mess with that we're just going to add another version of it inside so what I'm going to do is add a new component which is going to be a static mesh there we go it's going to be called see through ball and let's find the ball in here there it is and now I've got another copy of that ball selected but what I'm going to do is turn my scale tool on and just scale that down slightly I want to scale it down not as much as that so I'm going to change my snaps down to this one and there we go so that's just inside the ball slightly and then this new copy of the ball is going to have not m underscore basic it's going to have m underscore ball translucent and we won't really see anything happening here it's only in game that we'll really be able to see that happening so let's compile and save this go back out into our game and we'll give it a go so everything looks identical to how it did before but now when it goes behind parts of the castle it still shows up which is really going to help the player to be able to control the ball to anticipate where it's going to end up which is a really useful feature I think okay so that's going to wrap this step up we've now added a really useful feature what we're going to do going forward is get these meshes to start destructing so that that's going to be something that we really need to do before we can add any more functionality because extra functionality might be going on to the wall and the towers etc so let's get the destructible mesh set up and then we can work towards finishing this project so I'll see you in the next step where we'll start knocking walls down now it's time to start smashing this castle to pieces and we're going to do that through the use of destructible meshes now it's possible to create all the different chunks that your mesh will be destroyed into in your 3d editor but we're just going to do it in Unreal Engine because it's quicker and easier so what we need to do is go into static meshes and normally you would just right click and up here there would be the option to create a destructible mesh but it's not yet showing because you have to turn on a plugin first the plugin for that is not loaded by default so the first thing we will do is turn that plugin on so if we go to edit and then down to plugins the name of the plugin we're looking for is Apex so I'm not going to scroll through I'll just search for it here APEX there it is and you can see it is not enabled so we'll click on enable and then we need to restart the engine for that to take effect so I'll do that now and I'll see you on the other side okay my engine's just reopened it's taking me back to the plugins window so I'll just search for Apex again make sure that that's worked yep that's enabled brilliant we can close this window now and to double check that it's worked I'll right click on this wall and there it is create destructible mesh and I'm going to have all my destructible meshes just in the static mesh folder so that'll work fine so right click create destructible mesh here it is now the first thing we'll notice is that we can see our wall but there are no materials on it the first thing I'll do is put the materials on so that you can be compiling in the background so you're looking for skeletal mesh and you've got 0 and 1 that's because this one has two different materials on it so I'll drop these both down 0 and 1 and then I think this one's got destructible 1 as that colour that looks okay and then destructible 2 should be the lighter colour yeah that looks okay so now I've got my materials on there I can now start setting up the destructibleness of this so I'm going to scroll back up to the top here and then change some of these settings so I want to enable impact damage which will help it to actually destruct and then I'm going to set the impact damage to 100 and default impact damage depth to 100 as well that'll make everything work the way I want it and then I need to work out how many pieces I want it to break into so I'm primarily aiming this at a mobile platform so I don't want to give the physics engine too much to think about so I'm going to drop the cell sight down to 16 you might even get away with fewer than that and then there's this random seed here which will fracture it in different ways but we'll just go for the default and see what it looks like so once you've got those settings and you're happy with them you can click up here to fracture your mesh and you'll see it'll show you how it's broken you can have a look around it and what I like to do as well is use this slider to explode it and you can see how the pieces have broken up and actually I'm really happy with that so I'm going to keep that as it is if you're not happy with it put another number in there fracture it again and then you'll see what it looks like and you might like that one better but I'm happy with this so I'm going to click on save now we want to test this so I'm just going to pop that over there and I'm going to put some copies of this in the level so I'm just going to put it over there and what I don't want is this to overlap with anything because that will set it off which I don't want to happen so I'm just going to make sure I've got some gaps I'm going to put it all the way along here because I want the ball to be able to hit it as long as there are gaps I'll be fine there we go so I'm going to give this a quick test but I'm not going to get anywhere near the result I want yet but just to show you where we are so they sit there and I can hit them but then when I do they kind of wake up and just drop through the floor and there are a couple of reasons that that's happening but what we'll do first of all is sort out the dropping through the floor which is not good part of the reason I'm having that issue is that first of all these are below the floor so I'm going to move them all up and then I'm going to press end on my keyboard and now they're no longer through the ground but that's still not going to change anything so when I hit one of them it's still falling through the ground that's because the ground has no collision box yet so we need to add one so let's open the ground up and the easiest way to add one of these for this shape is go to collision and we're going to add a box simplified collision and then if we just make sure that we can see collision so simple collision's on you'll get a little outline on there indicating that that exists so let's save it and we'll play again now there's a chance that this won't drop through the floor there we go so once it's been hit it will now land on the ground and it will fracture a little bit so we're getting closer to what I'm looking for what I'm going to do now now that we've got a collision box I should be able to put these on the ground because they're still hovering above it so if I select them all and press end that will drop them down to the next collidable surface so now they're sitting perfectly on the ground so let's press play again and see what happens when I hit them they fracture that's pretty nifty right so I'm not getting enough of a reaction out of them yet I want them to be knocked down and you can see the second time the ball goes through them once they've been fractured it can then just knock the crap out of them which is good but this indicates that our destructor mesh is working we're just going to use a blueprint later to get a little bit more control over it we're going to control what it will collide with when it will collide we're going to make it break up a little bit after it's been hit using an impulse so there's going to be a lot more going on with it but for now we've figured out how to make a destructible mesh and how to get it to interact with our ball so I'm not going to do the other two I think you can figure it out so when I meet you in the next step you should have the gate destructible mesh ready to go and also the tower destructible mesh ready to go making three destructible meshes in total ready for getting the blueprint set up so I will see your beautiful ass in the next step at this stage then you should now have created three different destructible meshes one for the wall one for the tower and one for the gate and as you can see I've put them in my level just so that I can test them and I'll do this really quickly so let's throw a ball at them and make sure that they actually are being destroyed got to get past the first few first yep there we go that's all working as expected and yours should be too but what we need to do now is make it so that the way that these destruct happens to this so we're going to need to update our blueprints but first of all we need to get rid of all of these because we don't need them because they were just for testing purposes so let's get rid of them like that okay so now it's time to go into our blueprints and update them so let's go to content and back into our blueprints folder and as I keep doing I'm going to do it on the wall because I'll see the most impact with that so let's open BP underscore block underscore wall and this is what we've got so far we're going to need to make a change here so this is just the static mesh we need to add a destructible mesh so what I'm going to do is add a component and start typing destructible and it will pop up and there it is so I'm just going to leave it called destructible because I'll know what that is and then what I'm going to do is with this wall I'm going to hide it so let's just scroll down and we're going to untick visible and that is because when I load in this destructible I need to see whether or not it actually loads in and I'll show you what I mean by that so I'm going to go to destructible mesh and I want the wall underscore dm so I've selected it but nothing has shown up here and it should have I've googled this apparently it's a bug although it's been a bug for as long as I can remember so I'm starting to wonder if it's just the way things are but to get your destructible mesh to show up the best way to do it is just click on simulation and then click it again to turn it off and then it will show up so I was just using the original wall as a place holder so now when I turn this on enough I can see that they're in exactly the same place which is what I wanted so that means I can now delete this I have no further use for it so now we have our destructible wall in there instead but at the moment that's not going to generate any hit events with the ball because we haven't got the script set up for that so let's set that up so first job is to scroll down or scroll up in this case where are we I'm looking for collision make sure that the simulate generates hit events just like we did previously otherwise when the ball hits it nothing will happen so we'll turn that on first of all and then we'll go into our event graph and this is mostly alright it's just not using the right component so it's on component hit wall we need it on component hit destructible now so let's right click here we'll get an end event on component hit there it is and what we're going to do is just replace this so I'm going to pop that in there and other actors going to go in there and then we can get rid of that that's no longer needed now we could leave it here but we wouldn't see any of the fracturing because it would destroy the actor as soon as the ball hits it which will completely gates the point of having destructible measures so what we'll do is give it a little delay so that we can see the the destruction happening so I'm going to just after we've checked is it the ball we're going to add a delay of probably one and a half seconds I think suits what I like so it will be able to do a little bit of destruction before it's then destroyed so let's compile that and we need to test oh dear they disappeared and I've tested this a couple of times this happens whenever I leave it in but whenever I bring in a new version of it it does behave so what we're going to need to do is get rid of all the previous block walls unfortunately again if anybody knows a better way of doing this then drop me a comment down below because I'm not sure why that happens but it just means that now we get this one I'm going to press end to make sure it's sitting on the ground so I'll bring it above the ground and press end there you go and then I'm going to drop this in place and it's not going to be in line with the gate because that's currently above the ground but that will be put on the ground when we update that blueprint as well so what we need to do now is just create our copies and get all of this castle set up again so I'll just do some editing wizardry and I'll see you when I put all these walls back in place and I'm back okay so you can now see that I've replaced the original blueprints with exact copies of the same blueprint and now the castle is put back together and so we should now be able to use the destructableness of these meshes to good effect so let's do a quick test so they won't destruct spectacularly yet so you might just see that one cracked a little bit and they are also affecting each other so you see now a piece of wall next to that one has started to crumble but then hasn't been destroyed yet because the ball hasn't hit it so it's not perfect yet we've also got some weird physics going on oh it stopped the ball interesting and that's because we're not quite there yet but we are now much closer so again I'm going to leave you to do the updates on the towers and on the gate so you're going to make sure that you update the blueprints to include the destructable mesh you're also going to make sure you update the event graph don't forget to generate hit events otherwise it won't work and then I will meet you in the next step where we'll do a little bit more wizardry on these destructable meshes now you should have made sure that you've swapped in the new destructable mesh blueprints for all the pieces of the castle so that means the wall the tower and the gate and that will mean that everything now gets destroyed when the ball hits it but it also gives us a bit of a problem and I will show you what I mean before we move on so if I just fire the ball into the level it will hit one of the meshes but then everything will crumble and then the whole game will come to a crawl because there's too much physics simulation going on and it's not good and that's because at the moment anything can cause these meshes to fracture even pieces of other meshes around it and we only want it to happen when the ball does it so that we're getting a lot more control out of what we're doing and that's what this step is going to be all about so let's jump into that so we'll do this on the block wall blueprint seeing as that's the one that I have the most pieces of and the first thing I want to do is make sure that the gravity is set to off on my destructable mesh we only want to turn things on as we need them so you can see enable gravity is listed there let's turn that off what you also want to do is make sure that simulate physics is in fact set to off because you're going to get some weird resource if you have it set to on by default so we'll leave that set to off so we're getting exactly what we want now the way we're going to stop this firm fraction when anything hits it is through the collision presets and I will show you where that is here we go collision presets so if we just expand that a little bit you can see we've got all this information and at the moment it's blocking everything which means anything can cause it to break so what we'll do is we'll change this to custom we're going to put it on ignore but then only the bits that we want it to be affected by we're going to tell it to block and then we're going to tell it to only block the physics body which is the ball since until the ball hits it we don't want it to collide with anything so it's only listening for collisions from the ball that's the only thing it will be looking out for that'll work nicely and then what we want to do is have certain things change once it has been fractured so what we'll do is we'll get a new event and the event we'll get is on component fracture so when this fractures we're going to have it do some stuff so the first thing we'll do is once it is fractured we're going to turn the gravity on so that things will fall down so we're going to get the destructible and for that we need to enable gravity so there we go set enable gravity so the first thing we'll do as soon as that is fractured is take that box enable gravity so now things will fracture and then be dropped to the ground so we'll just compile that for now once the mesh has already been fractured then what we want to do is tell it to ignore the ball otherwise if the ball goes through the debris again it can send it everywhere and it's going to make it look too messy or too messy for my liking so the next thing we'll do is once it's been hit by the ball once we'll tell it to ignore it going forward I'm going to do that with a collision response node so we'll go from here set collision response to channel and we're going to do that for destructible there we go and what we're going to do is on physics body we're going to tell it to ignore that so now once it's been destroyed it's actually not going to respond to anything really but what I do now want this to respond to is other bits of destructible mesh so the debris can kind of crumble off of each other otherwise it'll all fall into itself which we don't want so we'll get another one of these set collision response and this time we're going to turn on destructible and we're going to tell it to block that so that's two out of three that we want to change and now we also want to tell it to block world static measures so that it won't fall through the floor so we'll have one more of these there we go so world static and block so that now sorts out our collisions everything's going to be a lot more controlled because of this so let's just hit compile for that and now it's the moment of truth we want to test this so keep in mind that the towers and the gate aren't going to behave themselves yet but hopefully the walls will so let's try and hit a wall yeah so that wall went pretty nicely so let's just hit a couple more there we go so that's hitting and it's fracturing and then it's disappearing after a certain amount of time but it's not affecting any of the other blocks around it which is what we want now because we're being a lot more controlled it's stopping the walls from crumbling spectacularly so what we need to do now is get them to destroy a little bit more flamboyantly so let's have a look at that so the way that we're going to get this to break up a little bit more is once that we have set all the collision things up we're going to add a radial impulse which is kind of going to spin things around which will make it look a bit more spectacular when they break up so we're going to go over here I'm going to do a radial impulse for the destructible which makes sense but we need to know where to add that impulse and we need to add it kind of at the center of the wall but up a little bit so it's happening kind of in the middle and I'll show you how to do that for the destructible we need to get the world location get world location lovely and what we want to do is use that return value in the origin but we want to tweak it a little bit so in order to tweak it we're going to split this pin so that we get the x, y and z values and we need to just manipulate the z value a little bit so we'll split this one as well and x and y we're going to leave alone so let's put those in there but we're going to add to the z so if we just pull out of here and we just put in a plus symbol there we're going to do float plus float and the result's going to go into z and what we're going to do is just add 50 onto this which means that the impulse will happen 50 above the ground which is what we're looking for so that's pretty nice that'll be the radial impulse being added so we'll have that happen after all of our collisions have been set up so let's have a little look at that and see if this is now happening a little bit more beautifully so we'll hit play hopefully we'll hit a bit of wall so it's doing something but it's not doing enough so let's go back in and we've not really done the radius or strength so we need to add something to that so what I'm going to do is put in some numbers that I've used before that I know that I like so we'll set the radius to 40 which is the distance where this is going to take hold and then the strength I'm going to set to 10,000 okay so let's compile again and let's see what we get this time hopefully a slightly better destruction yeah there we go so now that wall when it gets hit it's properly crumbling bringing down the castle and now there's one more thing that I want to change because we've still got things crumbling when we don't want them to and not disappearing so let's go back into here and we can actually now do away with the on hit because if it's being destroyed and it can only be destroyed by the ball then we know that's going to give us a hit as well so I'm going to get rid of that and all of this I want to happen after this has gone so I'm going to pop this at the end here so after I've done everything else let's add the delay so we can get rid of the ball because we know it must have been the ball because it's a physics object so we'll add a delay of 1.5 seconds and then destroy it so we'll give this one more go again we're only looking at the walls because the gate and the towers won't work yet so let's see what we get this time so it hits the wall so we know that the towers still going to cause us some issues so we'll ignore that for now we're just focusing on the walls to make sure they do what we think they should everything's kind of now destroying but I find that I get some strange physics on the wall pieces especially it is all of them but after they fall it's as if they're being kind of pulled backwards and forwards which I will try and show you there we go happened a little bit there on the left hand wall I'm not really sure what caused us that but I do know what fixes it so there's one last thing that we'll do before we move on and that's to sort that out so into the wall here's our blueprint and here we've got the default scene root and the destructible and what I find fixes this problem is to make the destructible the scene root just like that that's all you've got to do so if we compile and save that and then we'll test again now I'm expecting all the wall pieces to just behave themselves so as the ball works its way around nothing flies off too crazily everything just breaks we've got that little radial impulse doing its thing and everything looks pretty nice pretty controlled pretty tidy which is what I'm going for we'll leave that step there then all you need to do now is go and make those same changes to the tower pieces and the gate piece and then everything will just be working fine and dandy it will be beautiful once you've done that I will see you in the next step where we'll start setting up the stage clear behavior so I'll see you in the next step for that this step is going to be all about setting up a level clear behavior so what we need to do is find a way to count all the blocks and then when that reaches zero we'll need to say to the player well done you've beat the level so that's what we'll be doing now the first thing we'll need to set up is a way of counting all the blocks in the level because they're different blueprints so we've got one two three four different types of blueprint that we need to be counting the most straightforward way isn't just to count each type of those blueprint and add them up we can do it in a different way and the way I'm going to do it is through the use of tags so we can give each one of these blueprints a specific tag which you'll call block and then we can count everything with that tag so that's what we'll do we'll start with just doing it on the gate first of all so that then we only have to get rid of one block to beat the game and that'll make it easier and faster for testing once that's working we'll push it out to all the other ones as well so let's go into blueprints and we're going to find BP block gate there it is and what we'll do is add this tag so if we scroll down you can see there's an actor section here and if we just expand the advanced section you'll see that there's a tag area here we can go for plus and I'm just going to go for block all in lowercase and that's all we need to do there that's easy so let's compile that and save it what we need to do now is set up something that's going to count anything with this block and we're going to do that in our game mode so let's open that up so the first thing I'm going to do is create a new custom event and I'm going to call this blocks remaining check so it's going to check how many blocks are remaining so descriptive name so the node that we're going to use is get all actors with tag here it is and in here we can input what tag we want to use so I'm just going to type block so the first thing that we want to do is get all of those actors and what that gives us is an array which is like a list of different things so we could have it list all the different types of blueprint that have this tag but we don't want it to list them we just want it to count how many things are in that list and in order to do that we'll drag out of here and we'll type length and that's just going to give us the length of that array how many different items are in that array and when we've got that information we need to just turn that into a variable so I'm going to right click on that promote to variable and I'm going to call that variable blocks remaining so now we have a way of counting what blocks are left and putting that into a variable that we can use now what we're going to do is just check that that's doing something with a quick print string so let's just go here I'm going to do print string here we go and what we want it to do is just print this so that's just going to put on screen how many there are there so at the moment it's going to run on that but we'll just do it on tick so every tick we're just going to run that just to make sure that it's working so let's make sure we've got this all connected up properly so there we go now we've got event tick in to get all actors with tag set the variable and then we're just going to print it to screen so let's compile and save that and we'll just give it a quick test and straight away you can see that it's printing one on screen so there it is going down so every tick is printing that now we don't really want to do this every tick we just want to check that it is working so the idea is now that if I can hit the gate there we go that then goes down to zero so that's now counting perfectly nice so we can close that for now and we're also going to get rid of this tick because that's served its purpose and we're going to leave the print string in there for now just so that we can check that it's working as it should we'll get rid of that once we're happy that it is all working so now instead of running this check every tick we need to find something a bit more appropriate that isn't going to be as intensive on the system so we're going to do it every time the ball hits something that's when we'll run the check since it's going to be the ball that destroys them anyway so every time the ball hits something we'll run this check how many blocks have we got left so into the ball blueprint we're going to create an on component hit event so every time this hits something that's when we're going to run this and then we need to talk to the game mode so that we can do this check so let's get the game mode and then from the game mode we want to run the blocks remaining check there it is so every time we get a hit on the ball let's run that check so now we'll test this again and so now every time that the ball hits something we should see the print string doing its thing so when it hits this wall here yep it puts it up to one and now that's only happening every time that we get a hit let's see if we can destroy that so there we go and now once that's destroyed that goes down to zero perfect so that's doing its job so now whenever that blocks number reaches zero we're going to need to run the level clear behavior and before we can do that we need to create the level clear behavior so we're going to need to go back into the game mode for that we'll create a new custom event and we'll call that level clear beautiful and we're also going to need a variable for this a boolean variable which is going to be called level clear because it's a question level clear there we go so we've now got our custom event and we also have our variable that we can set to true when our number of blocks gets to zero so let's do that so whenever we call level clear the first thing we want to do is we're going to be setting level clear to true that's the first thing we want to do and then what we're going to do is just add a bit of a delay and then we're going to load a level as I've not created any more levels yet we're just going to reload level one but if I was creating more of a game I would create level two and we would load that one so let's add a delay and we'll put five seconds on that to give the level clear message a little bit of time to show and then we're going to run open level and I have the level written somewhere else yeah it's level one with a capital L so level one okay and that's pretty much our behavior set up so let's just comment these blocks remaining check and this is going to be our level clear behavior there we go so now we need to do something to trigger this level clear when is this going to run well let's get rid of the print string for a minute so we're just going to disconnect that let's drop it out there so what we need to do now is create a branch and this branch is going to fire if the blocks remaining is at zero or less than zero so let's create a branch awesome and the condition is going to be is this less than or equal to zero so there's our condition and if it's true we're going to run level clear there we go so that's what's going to have that working beautiful and I think what we will also do is just put that print string back in for now just in case we need to check anything so I'm just going to drop this in here we'll get that okay so that's all now doing its thing compile and save so this should now work because we've only got one of these blocks we should be able to just hit the gate and that should reload the game because that's going to be level clear so let's give it a quick check see if I can hit the gate first time oh good shot so that's now gone down to zero there should be a five second delay and then it should yeah then it reloaded the level brilliant so we've got a bit of an issue in that the ball keeps moving after it registers zero so what we're going to have to do is find a way of stopping the ball before we move on because we don't want the player to lose a life after they've got all the blocks so to stop the ball we'll go into the ball blueprint again so it's happening on hit so we're going to keep this as it is and we're going to run a branch and the branch is going to be is level clear true so let's get level clear there we go so we'll plot that into there and if level clear is true what we're going to do is get the ball speed in fact we're going to set the ball speed so what we'll do is we'll set that to zero and that will just stop it moving so there we go just neaten that up a little bit awesome so let's try that one more time compile save and play so now hopefully when I hit the gate there we go and it didn't work oh there you go it took a little minute but it did stop and that's just because it's waiting for the one and a half seconds while the wall crumbles we could tighten that up a little bit but I think it will serve our purpose so I'm going to leave that as it is so the last thing that we need to do is create a level clear message so we can display that to the player and then that's going to be our level clear behavior all set up so we'll just comment this first and I'm just going to call this level clear this is all to do with whether or not the level is clear so that will do and now we need to go into the heads up display here it is and the first thing we'll do the game over message is pretty much what we want but we just need to change the wording and when it displays so the first thing I'll do is just duplicate this awesome and then we'll change the text to level let's put it all in caps level clear exclamation mark exclamation mark number one exclamation mark smiley face yeah okay and now we need to set up when should that display and we're going to go and find visibility here it is and we add a binding to that so create a binding awesome so we need to go to the game mode and we're going to get the game mode we also want to get level clear so get level clear and we need to know if that's equal to true so let's get out of that we'll put a couple of equals in is that equal to true there we go so that's our condition and then we want to set the visibility so from here we're going to get a select same as we did on the previous message and into our index we're going to get our condition so if this is false it's going to be hidden and if everything comes true it will then become visible so that should all work fine so let's just compile that and save it and now it's time for another test so let's see if we can get this level clear message to display so hit that boom wait one and a half seconds and we cleared the level yes oh it's just an easy game you're just going to hit the gate and then it resets we've done it guys we have set up the level clear behavior the only thing that we need to do now is add the block tag to all of the other blocky things so let's do that so let's go to what we got we've done gate we need to add it to the block so let's find tags and add block nope I'm not going to in caps there we go compile save and then we're going to do tower so there we go vlock and I think I maybe need to do one more oh no I don't want to play yet save we need to do the wall that's it so drop that down add a tag the tag is block and then we compile and we save and we test okay so this time I don't want to hit the gate straight away although probably will so now we have 45 blocks showing which is good so what I'm going to do now is cut because you're not going to watch me playing all this is boring until I've just got one block left and then I'll come back and start talking and we'll make sure that level clear works with everything in place here we go and Bosch last one's gone level clear pops up ball stopped and reset hey there we go everyone so we now have the level clear behavior set up wonderful so in the next step we're going to be looking at adding some audio to this to make it feel a little more interesting to play to give the player a bit more feedback as well about when they hit it's happening and when things have been destroyed and also a happy little sound when they win I think so see you in the next step for that now that we've got our game over behavior set up let's go about adding some sound to the game to make it feel a bit richer and a bit more complete so if you want to use my assets then that will be in the audio folder of the assets download and the first thing we need to do with those is get them imported so what I'll do first of all is create a folder for them and I'm just going to call that folder audio which seems like a pretty good name there we go and then I'll go into that folder and we are going to import to that so here's the breakout folder that I've shared if you have got access to that via the link down below and then into the assets folder there's an audio folder and these are the sounds I've got them from this website it's a free 8-bit sound effect website but I did need to change the bit rate on some of them to make them work so not all of the sounds on that website just work out of the box anyway let's import these ones and then they appear in the folder and then you can play them by just doing this so I've just got it coming through the speakers I don't know how well you'll be able to hear the sounds that's nice so that's game over we'll have hit and level clear so that's all our sounds what we need to do now is set up when and where we want these sounds to appear so the first thing we're going to do is make it so that these castle blocks make a nice demolishing noise when the ball hits them so for that we're going to go into the blueprint we'll do the BP underscore block underscore wall first because that's got the most impact so here's our script so far and what I want to do is just put this audio in before the delay it has to be before the delay otherwise it will wait one and a half seconds before playing the sound so it's really really easy to do what we do if we drag out of here just to put it in between the radio impulse and the delay and I'm going to do a play sound and it's the play sound 2D that we're looking for and that'll just drop that in there and you can choose this asset from here and all the sounds that we've imported will now appear and we're going to use the crumble sound and then we'll just compile and save and we'll just press play and we'll test we'll hit a castle wall just to make sure that that is in fact working yeah lovely so that's that one done what we need to do now is the same for the castle tower and the castle gate but I'm not going to show you that because it's exactly the same process so I'll do it myself and I'll cut that out so that it's done when I test the game but I'm going to let you do that one on your own just put the play 2D sound in it's the same sound effect you'll be fine okay so I've just completed that so here it is on the wall straight after the impulse same on the gate impulse play sound delay and then on the tower impulse play sound delay nice and easy what we'll do next is the sound for the little breakout style blocks inside the castle we've got a different sound for those so we'll put those on now so let's find our block blueprint there it is and for this one because there are no delays we can just put the sound at the end so what we'll do is do a play sound 2D and this one's going to be the collectible sound which makes a nice pleasant noise so we'll compile and save that and then it's now time for a quick test just to make sure that all the sounds are doing what we think they should so the crumble sounds working okay it's working on the towers as well and there we go carnage yep so that's all working fine so far so good what we need to do now is add a sound that will play when the ball hits the cliff so that the edge of the game will the bounds and we're going to have to handle that in a slightly different way because we're going to add that to the ball but we don't want that sound to play every time the ball hits something only when it hits the cliffs so we have to do that slightly differently but it's still very straightforward so let's open the ball blueprint first of all there we go we're going to attach this sound to the on component hit so it's just going to change the way that we've got this laid out a little bit so I'm going to move all of this along a little bit and we're just going to change that because that's what handles the level clear this bit here is just going to be what handles playing the sound so because we don't want this to happen when the ball hits a static mesh which is the case what we'll do is on hit we're going to do a check so we'll cast to static mesh so what we're doing now is the first thing is we'll check did the ball hit a static mesh actor and the only static mesh actors in the scene that it can hit are the cliffs so we'll do that check and if that comes out as true then we'll play the sound if however it comes out as false if it fails we just go on with the script and we do the blocks remaining check but if it is in fact the ball hitting the static mesh we're going to do our play sound 2D there we go and we will select the asset 2 which is just going to be hit and we'll connect that up as well and I'm just going to put some re-root nodes in here so I can see what I'm doing drop that down there and drop that down there there we go so this is a little check did it hit static mesh actor if it did we'll play the sound if it didn't don't play the sound but keep doing the same thing so let's compile save and we'll give that a little test as well just to make sure that it's playing the sound when it hits the side but not when it hits anything else yep that's pretty good yep start doing it when it hits the paddle that's working as intended we'll now do something similar for the paddle when the ball hits the paddle we want that same sound but we'll handle that slightly differently and we'll do it on the paddle so let's go into that blueprint there it is and we're going to do an uncomponent hit for this one which I don't believe we have in here yet so let's do uncomponent hit here it is and we want to check did this hit the ball so for other actor we're just going to cast to to ball cast a BP ball and if it's the ball that hits it we're going to play our sound play sound and the asset's going to be hit and that means that if it's not the ball so if it hits the side which it might do when we're moving side to side we don't want that sound to play because that'll be distracting it's only going to happen when the ball hits it but that's something else we're going to need to check so let's make sure that that's behaving as we think it should so we're just now listening for when the ball hits the paddle do we still get that sound come on baby no and there is a very good reason we didn't get that sound and I'm going to fix it now I should have remembered but I didn't so into the paddle the problem is we're not generating hit events so that hit didn't register let's tick that compile save let's try that again so this time we'll make a sound when we hit the paddle here we go okay so that's pretty much all the collision sounds in place and it's already feeling a lot more dynamic if not a little louder so what we need to do now is add some little jingles that will play when the player either loses a life or clears the level both of those are going to happen in the game mode so let's now open our game mode and we'll do the level clear first because that's nice and easy so it needs to happen before the delay otherwise it'll wait five seconds and then play the sound so we need to make a little bit more room in here so let's move these along a little bit and then just here we'll have a play sound awesome and the sound that we want to play is level clear and it's that easy so we'll compile that and we also want to do one on game over so again this needs to happen before the delay so we'll move these along a little bit let's add our play sound and this time it's going to be the game over sound okay so that now is everything set up so what we need to do now is test that the two end jingles are working and if that's working we'll move on to the next step so let's compile save and play so the first thing I'm going to do is test the game over sound because that's the easiest to get to I just have to let the balls fall so here we are about to lose the last life and beautiful okay now what I'm going to have to do is play this game for a little bit we'll get to the point we're about to get level clear and then I'll come back and we'll see if that music plays there we go hey there we go so now we have all the audio in our game set up and working as intended so that brings us to the end of this step in the next step we're going to do a little bit more work on the visuals I want a bit more of a pixelated old-school eight-bit look to this game so we'll implement that next now we've got the audio set up and working as we want it to the next thing I want to do is have one more look at the visuals just to get the overall look that I'm going for as with the sound I'm going for a retro aesthetic so what I want to do is get it to look nice and pixelated big chunky pixels and I'll show you how I'm going to achieve that so the best way to do that is if I just play the game first of all and you can see that's kind of it by default but we're going to use some console commands to manipulate the way it's rendering so the first thing I'm going to do is do r.screen percentage and you can see it comes up there as a suggestion so I just press tab to get that and then I'm going to drop the screen percentage down to 40 percent which means it will render at 40 percent of the resolution available to it but the downside to this is it's not yet given me that chunky pixelated look that I want because it's trying to smooth it out so we need to turn that smoothing off and that's another console command so it's going to be r.upscale quality so there's the upscale quality there I'm going to set this to zero to turn it off and that's it that gives us our chunky pixelated look that's brilliant let's just check how it looks when it knocks things down oh my god it looks so good so that actually is probably a little bit too chunky for me with the size of the pixels so what I'm going to do is just turn the screen percentage up a little bit so r.screen percentage let's try 50 percent yeah so then we don't lose as much detail but it gives us a nice old school aesthetic so now that I know what I want I need to make sure that it remembers this so if I just quick the game and do that again it remembers it in here and that's fine but it won't remember it in the standalone game and I'll show you what I mean by that so if instead of just going to play I go to standalone game this will take a little minute to open but then you'll see then instead of respecting those settings I just put in it does its own thing there you go so it's just turned everything up to max which is fine but it's not actually what I want so we need to make sure that it knows that when we're in the actual game that what we want to do is keep those settings and we're going to do that in the level blueprint so we need to open the level blueprint so let's go up here to blueprints and open the level blueprint here we go and we've not done anything with this yet but what we'll do is come out of begin play and we're going to do execute console command there it is and what we do is just type in the console command that we want and it will carry that out when the level opens so it's going to be r.screen percentage and then we're going to do a space and set that to 50 and then we'll do another one of these and this one's going to be r.upscale.quality space zero and that should do it that should then mean that these settings happen every time we play the game but let's not leave it to chance let's compile, save and we'll play standalone game again to make sure that that's working as expected here we go then that's just opened up and we have chunky pixels so that's the first part of the visual tweaking done the next part is I just want to work on the colors a little bit because it looks quite dull and a little bit lifeless and also for me the shadows are a little bit too dark and it just doesn't work for me so we'll improve that a little bit now the way I'm going to go about this we'll just close the level blueprint for now I'm going to do it in the shader so let's go to materials and the color palette m underscore palette what we're going to do is just boost the emissive strength so I'll show you that happening so we'll set that to 0.4 and then we'll save this and that should then be reflected in game and there we go everything just got a whole lot lighter it looks a little bit more pastily but more importantly the shadows now aren't quite as dark so that's cool but now the castle kind of stands out it doesn't look like the rest of the game so we need to repeat this for that shader so if we go to m underscore destructible here it is I'll just make sure that we can see that change so we have the same emissive property here so let's change that to 0.4 to match we'll hit save and then this castle will look like the rest of the game there we go then that now got a lot brighter and looks much nicer I'll let you decide whether or not you want to increase the emissive value on these blocks inside I'm going to leave them I think they look okay the next thing I want to do though is try and bring some of the color back because whilst I do like raising the brightness of the material it does wash the colors out a little bit so to bring those back we'll use a post processing volume so if we just go in classes and search for post that will pop up I'm just going to drag it into the middle so I can find it and then in the details for it I'm just going to search for infinite and then tick for infinite extent which means that will happen everywhere then I'll search for saturation which is how colorful things are I'll put a tick in the box to say that we want to use it and then this value here will control the saturation for all colors at once so I'm just going to pull that up so you see that brings the green back in so I want it to look nice and colorful something like 1.2 I think I like so I'm just going to type that in 1.2 yeah much better if you want to see what effect that's having you can use that to toggle it on and off so it just brings the colors back in a little bit so I'm happy with that the next thing I don't like if we just go into the game again is we have the arrow which is still attached to the ball and we also have the kill zone being shown so we're going to get rid of both of those so we'll go into the ball blueprint to get rid of the arrow so blueprints ball nope it's not in there it's in the player paddle isn't it there we go so there's the arrow and we want that to be hidden in game compile and save we're also going to do that for the kill zone there it is so there's our box and we'll have that be hidden in game compile save I want to get rid of the print string as well because I don't want the number of blocks remaining to be printed to screen anymore so that's happening in the game mode so here's the print string here so you could just disconnect it in case you ever want to bring it back but I don't so I'm just going to delete like so and then we'll just connect that up like that and then we'll compile and save so let's have another look at this now that is looking much much cleaner we can launch the ball it's doing beautiful things yep and one last thing that I want to change I'm no longer happy with the size of the ball I want it to be bigger I want to make some kind of joke about big balls now but I'm not going to I'm too mature for that so what we'll do is go into BP underscore ball so the size of this is just set to one and what I'll do is I just want to up it to 1.5 there's a couple of reasons for this one it will make the ball easier to see and two it will mean that it hits the blocks because I'm finding that I'm not hitting the blocks often enough so this is going to make it hit them more often so we'll compile and save that and if we're just going to the viewport what I want to show you is that when we select the see-through ball that still it sizes in relation to the ball so when we made the ball bigger the see-through ball got bigger as well because you can see there's a hierarchy there so we don't need to worry about changing that so now let's have a look at the size of the ball in relation to everything else yeah that's better so it doesn't look huge but it'll just mean that it's easier to see for the player and also it's going to hit the blocks more often as well it won't miss them so that's pretty good so that brings us to the end of another step well done what we'll do next is we'll implement the touchscreen controls which is the last time that we're going to get really complicated in this tutorial so don't worry about it and it's an optional step as well you don't have to implement the touch controls but if you've come this far you probably want to so I'll see you in the next step where we'll do some touching up now it's time then to get some touchscreen controls implemented in this game we did say way back at the beginning that we were aiming this at a mobile platform so we're going to need to be able to control it in some way on screen so let's get that set up so the only thing we'll be controlling is the position of the paddle so it makes sense that the controls that are going to go in the paddle blueprint here we are first of all we'll just put this in a comment to neaten it up so play sound and then we'll just swish that over there and then down here is where we're going to put the touchscreen controls so the trigger for this is going to be touch there we go so that's a good place to start now we're only interested in the side to side so we can get where the screen was touched and it gives us that in x and y coordinates but as we're only moving side to side we only need the x coordinate so what I'll do is split this pin and that means that I can just work with the location x which is all I need and then we need to convert this from screen space to world space so that we can apply it to the paddle which is operating in world space so out of here we're going to go convert screen we'll just turn off context sensitive for this screen location to world space this is the node we want and you can see that's now going into screen x and the target for this is the player controller so we'll do get player controller there we go and we'll just put that there out of the way for now and then what we want to do is put that onto the paddle so we need to get the position of the paddle so let's get paddle and from that we're going to set the world location there we go and then what we can do is whenever this is pressed or released or moved we basically want this to be updating constantly whenever the play touches the screen I'm just going to move this down here a little bit so I can see my wires trying to get this up a touch so whenever that happens we're going to set the world location and we need to get the new location so we'll split that pin and we'll split this pin because we just want world location x to become new location and that in a nutshell is how we do it but we're not finished yet because it won't really work I will show you where we're at at the moment so let's compile that and save and what we need to do for testing purposes is make mouse clicks behaviors touch and we will do that by going into the project settings or is it the editor settings let's try project settings first yeah so what we're going to do is use mouse for touch tick and then the default touch interface we're actually going to turn off so we'll just clear that because we don't want that to show up and then that's good and now when I test if I click it will behave as a touchscreen but you can see it just can't move it far enough so what we're going to need to do is multiply the values coming out of the screen space by a bigger number to get that paddle to move further because it's just not moving far enough at the moment so back into here and this value then we are going to multiply so we're going to float multiplied by a float and then that results going to go into there and just to get started I'm going to try multiplying it by 100 and then we'll test it see for any closer so let's compile play and I'm playing it in this window because it will keep my mouse showing and so I can see if my mouse goes further than my paddle which it is doing I know that I need to multiply that by a bigger number there is probably a way of working out what this needs to be exactly if anybody knows that feel free to drop a comment down below but I'll be honest I just arrived at this through trial and error that's probably not the best way but it works for me right so I actually have already done this so I know that the number I want is 140 brilliant so we'll compile that and play and then you can see now the paddle is following the mouse pretty perfectly but it does introduce a new problem I will show you what that is if I now drag too far it's destroyed the paddle because we've hit the kill zone so that creates a problem for us we don't really want that problem do we so let's hit escape and you'll see it all it will complain that may not oh no it's not working because you destroyed the paddle that's right so we need to find a way of stopping the player from being able to do that and we're going to clamp the values so that it can't go too far left or right but first of all we need to find out what the bounds are how far the player can get and we'll do that just by doing a quick print string so let's get the paddle and we need to get the world location of that world location and with that world location we just want to do a print string and that's going to be what the printer's to screen and the trigger for that we're just going to do it on every tick because we we're only going to use this for a second so event tick so every tick it's going to print this to screen so compile and let's play so you can see we've got x and y and z showing and the y and z i'm also going to use in a minute but the x i'm interested in so with my arrow controls i'm just going to go as far as it will let me and i can see that at the full extent it's going slightly above 600 or negative 600 and then to the other way it's going slightly above 600 so they're going to be my clamp values and then i remember that y and z are also set to one so let's go back into here so we're going to clamp this value so clamp float the return value of that's going to be what goes into there so the minimum value is going to be negative 600 i think and the max value is going to be 600 which is what we just found out and we also learned that the new location of y can stay at zero but z should be set to one because that's where our paddle was previously so that now is all looking pretty darn good let's give it another try so compile and play so now when i go left and right i can no longer get to destroy the paddle so that touchscreen is working pretty well you can see that the arrow stays at the center of the paddle all the way across so that's pretty good so now if i put this into the level and it works anywhere along the screen as well i can now play a little bit of on-screen breakout oh lovely well done awesome so let's come out of there we can kill that print string that's done its job thank you print string i'll miss you and we'll compile and save again let's comment this because we're done with it and we'll call this touch controls lovely and now there's one more thing that i want to have happen and that's to launch the board instead of having to press a keyboard because that's not what we're going to have on a phone screen we're going to do it with a flick gesture and the first thing we need to do is go back into our project settings for this so window no edit project settings and we're going to search for gesture and then we're looking for this enable gesture recognizer tick that box and now we can go back into our BP player paddle and we're looking for where we fire the ball and we're going to add a flick and whenever that's pressed we're just going to do the same thing as whenever we do the input action fire so i'll place that there so they're now doing the same thing let's give that a test compile save and we will play so there we go i'm moving side to side and then if i to do a flick what i'm going to do is press move the mouse up and then let go but i have to do it a bit quicker than that so let's flick like that and you can see that now releases the ball as well we've now implemented touch controls well done everyone now these can be a little bit tricky to test but if you have a touchscreen display that makes it much easier i happen to have an app on my phone let's turn that off i happen to have an app on my phone that will turn it into a touchscreen display so i will just show you now how this works so i'll set the game playing in a window move it over to that display and try and film how that works with the touchscreen okay so here's the game now running on my makeshift touchscreen display which is my phone so the frame rate is a little bit low just because it is an app running rather than an actual display but if i now just touch that you can see that that is working we're going side to side and if i do the flick gesture that sets the ball off on its way and we can touch kind of anywhere and try and play the game oh hey what a shot so there we go we can see that that's working just fine so you can see that's all working fine and we've set up everything that we wanted to get set up so that brings us to the end of this final step well done for making it all the way through and that's it you have made it to the end well done for sticking it out for so long i realize this is a very long tutorial but you've learned loads from following it through from the beginning right through to the end so congratulations this whole tutorial series has been a bit of a labor of love so it probably took me about a year to create it from beginning to right the exercises through to recording it all and editing it took a hell of a long time so if you appreciate all of that work then please hit the like button make sure you subscribe and hit the bell and leave me a happy comment down below I would like to take this opportunity to thank my patrons whose continued support really helps me to continue to make videos like this if you're interested in becoming a patron and helping me to continue to grow the channel and put more tutorials out there then follow the link in the video description to be taken to my patreon page there's obviously a limited amount of information that I can cover in a tutorial video like this and if you want to continue learning beyond what I've covered then I recommend you check out the courses over at PluralSight they've got loads of courses lots to learn relating to Unreal Engine 4 and game development in general and I took a few of the courses on PluralSight when Unreal Engine 4 was still new to me so that I could figure the engine out if you're looking for a recommendation then I think you should take a look at Unreal Engine 4 Blueprint Fundamentals by Rob Brooks it's a really good course and it helps you to get a better handle on the functions of different blueprints so that's well well well worth a look if you use my link down below in the video description you'll also get a 10-day free trial to PluralSight so it basically means that you can take that tutorial or any others for free for 10 days so I would say that's a bit of a no-brainer free learning, why not and so this really now kind of brings us to the end of the video if you want to join the GameDev Academy community though you can join us through Discord the link for that is below you'll go through a little bit of a quiz first which is our sorting ceremony just like with the Harry Potter and it'll put you into one of the houses house Carmack, house Amano or house Miyamoto and then you can come talk to other similar people ask for help, share ideas it's a lovely little community that's continuing to grow all the time anyway thank you for watching this video please share it around if you can or just watch it again YouTube loves watch time so you know just let it run again it'll really help me out but shh don't tell anyone but seriously thank you for watching thank you for your support and i hope to see you again in a future video i believe that quality education should be available to everybody and for that reason all of the classes at GameDev Academy are completely free and we're supported by our very generous school governors over at Patreon if you'd like to become a GameDev Academy Governor and support our work as well as helping us to steer the channel in the right direction then use the link in the description to be taken to the Patreon page