 Hi there, welcome back to Gamedev Academy. I'm Shane. Please let me know you're here by leaving a comment down below Just like these fine human beings did in the last one and remember to let me know Which house you're in if you've joined us on discord. In the last class We made it so that when a new ball is spawned it will follow the paddle until it is shot into the level and Now in this class what we're going to be doing is making it so that we can shoot the ball off into the level So without any further messing about let's get stuck in Now that we've got the ball following the paddle at the beginning of the game What we need to do now is get 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 And 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. I say 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 to 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 going to 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 Now 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 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 And not boolean because we're only going to work with this if active is not true So there's the 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 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. I'm gonna 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. 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