 Hello there class! Welcome back to Game Dev Academy. I'm Shane. Make sure you let me know you're here by leaving a comment down below in the doobly-doo, just like these beautiful, talented, amazing people did in the last class. This class is going to focus on getting the ball to do what we want it to do. So we're going to add it to the level, we're going to fling it into the playfield and have it bouncing off of stuff, and we're going to do that by using blueprints again, and we're going to create a simple script to launch the ball. If you're ready to do that, then let's not faff about, we'll jump in, the screen thing's going to come on, it'll go ding, it'll go off, and then we'll get stuck in. Let's do it! 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 BP underscore ball. 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 want 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 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 it's 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. I'm 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 to happen 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 will go from zero to full speed without taking anything else into 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 will 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 of 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 X. So what I want to do is fling it up. And in this case, I know that's going to be minus 1000. If I just did 1000, 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 a blueprint for the ball and we've got some behavior in 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. I believe that quality education should be available to everybody. And for that reason, all of the classes at Game Dev Academy are completely free. And we're supported by our very generous school governors over at Patreon. If you'd like to become a Game Dev 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.