 Hi there everyone, welcome back to Game Dev Academy. I'm Shane. Remember to let me know you're here by putting a comment down there somewhere just like these beautiful human beings did last time and remember to let me know which house you're in if you are in the Discord group so that I can color code it and make it look smart on the register. In the last video what we did is made it so that we can shoot the ball into the level but now we've got a problem in that if the ball leaves the level when we should be able to kill it it doesn't die, it will just keep flying off in the distance forever. So what we're going to do in this video is create a box collision so that when the ball hits our overlaps with it, it will be destroyed and allow us to spawn a new ball. So let's get stuck into that now. 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 they'll lose a ball, the player is going to lose a 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 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. I'm not even close. Destroy. Why can't I spell? Destroying. I did it. Destroy actor. That's 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 simply. If anything overlaps with it, kill it. So let's compile that. I'll just drag 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 outer bounds area, or 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 we'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. Yeah. 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 balance 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 app, 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 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 that outside of the game balance, 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. 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.