Welcome back everyone. In this video, our goal is to edit our existing jump script to allow our player the ability to double jump, we've gotten to a point where we can interact with all of these diocese and collect a skill but the skill that we collect is actually not functional yet our player so these next bunch of videos are going to be making some of these skills actually function. So the first thing you should do is find your BP player located inside of our Metroidvania blueprints characters folder. Double click on her to open her up. And the first thing I'm going to do is I'm going to create a few more variables. I know we've got a lot of variables in here, but we got a few more to create.
So I'm just going to click this plus variables button. And the first variable I'm going to create is going to be called B lowercase b is double jumping question mark. Now with that created, I am going to move this into the category of our skill jump, skill double jump right there. So you can see that it is in our skill double jump category just because I'm super anal like that. I'm gonna just reorganize this by dragging and dropping it to be next to our other Boolean variable. Now, what are we going to be using this one for we're actually going to be using this in a little bit of our scripts here in a little bit.
But what this one is going to be doing is it is going to be a variable that gets passed on to something called an animation blueprint to make or to instruct our character to actually play another jumping animation. So this is laying some of the groundwork for that. Okay, with that one created, I'm going to create a nother variable here, plus variable This one I am going to call jump count. This coming up over my Details panel will be in integer whole number. And I'm going to put this into our skill double jump category as well. And I'm going to drag this above my double jump data just to be organized.
Next I'm going to add another variable, this one is going to be called double jump velocity. And this is going to be a vector variable. And I will also put this in the same category of skilled double jump going to drag and drop it above like so. And then I am going to compile because I've got some default values I need to set in here. I'm going to start with our double jump velocity since we already have it selected here. I'm going to set our z velocity here to be 1200.
And you're going to see this variable coming to play here in just a little bit. Our jump count we want that to be at zero by default in our is double jumping, not has double jump, but our B is double jumping, that is going to be false by default. Okay, so next what you need to do is we are going to jump over to our jump script that we already have existing. And again, we're inside of our BP player and we are in our move set tab. If you remember from earlier in the course we move some of our jump functionality over to this move set tab. If you can't find this, it is located just going to scroll up in my My Blueprint panel if you come under graphs, move set that is where you should be able to find this bit of jump script that we currently have existing.
Okay, so what I need to do is give our A little bit more space here. So I'm going to move my landing script on down a little bit. And I'm going to take my comment box for our jump script. I'm just going to expand this out because we're gonna add some more scripts inside of here. I'm gonna move this stop jumping a little bit further down like this. Okay, so the first thing that I'm going to do is I'm going to move this off to the right, and I'm going to bring in a branch node right about here, and I'm going to hold down the B key B as in boy, left click.
And I'm going to say once we press our jump button, we're going to go into our branch. And now the first question I want to ask is, do we have our skill double jump. So here we've got this variable has double jump, and by default, it is false. But when we interact with our blueprint actor, which one is our skilled double jump, double jump right they're gonna double click on this guy inside of our BP skilled double jump when we interact with this thing. This is where we are going to find out Hey, do we already have double jump? Sorry, that's the wrong area.
Let me just scroll on down here a little bit. It is in our player acquires double jump within here we are setting our has double jump to true. Okay, so jumping back over to our BP player. That's the question we're asking when we jump, hey, do we even have the ability to double jump, so make sure that you're plugging in the appropriate Boolean variable here, our B has double jump. We're gonna drag and drop that on top of our condition like so. And out of the false branch, from here, we can plug this into the branch that we already Had existing previously.
This was checking to see if we were falling. And if that was false, we would allow the player to jump in play the jump up FX. Okay. off of the true branch, what I want to do is drag out a wire and search for a switch on int node, you can type that into the search bar here and this is the one you're looking for switch on int. Now what this node does, it takes an input here, it takes an integer input. And depending on what the value of this integer input is, we can fire out of different pins and we can add more pins along the right hand side here by clicking one time by clicking a second time because I'm gonna have what to do on our first jump and then second jump.
Now for our selection here, I want to plug in our jump count. Drag and drop that right on top of there. Okay, so we're going to be working off of our zero pin here, if our jump count is currently zero, which it is by default, then what I want to do is a bunch of this stuff down here, I can literally copy all these nodes right here, our character movement are is falling our branch, our jump function and our jump up FX. So I'm gonna hit Ctrl C. And then I'm gonna come up here and do Ctrl V. And so if our jump count is zero, I'm going to wire this in like so. And then what I'm going to do is I'm going to take our jump count here, bring it on over, I'm going to get the jump count. And then I'm going to drag off of our jump count and I'm going to hit the plus symbol, not plus six, but just plus.
And you've got this node here called increment int. This is kind of a special node in that, when it will automatically do is it's going to add one to our jump count. There's another way that you could do this. And I could say jump count, plus, and I could do integer plus integer. And then I could say plus one, and then I could drag our jump count right here to set that. And I could do something like this.
Instead, if I just unhook this, this is this setup right here will give you the exact same result. As this increments, int node right here is just kind of like a shortcut. Okay, so that is going to then make our jump count be one. And if we then press our input action jump again, it's gonna say hey, do we have the ability to double jump if we do and our jump count? Now one, after we've jumped one time over here, we can then fire out of here. Now note that even at this point if I was to jump in and play, and I was to interact with our Dyess here to learn our double jump skill exiting out of there and then I hit the spacebar.
If I try to double jump, it is not going to allow me to So note that that is still going to be broken at this point because we're not finished. Okay, the next thing we need to do is work off of our one branch here and we're going to let me flip over my page a notes. The first thing well, I'm actually going to move this little bit of scripts out of the way a little bit more. Okay, the first thing we're going to do off of this one branches, I'm gonna get another reference to our jump count. We're gonna get that And then just like we did before, I'm going to drag off of that hit the plus symbol, and I'm going to do an increment int. So immediately after we've jumped one time, and we come through here, we're going to say, hey, increment our jump count to be two.
And off of doing this, I'm going to bring in our B is double jumping, we're going to drag that in, make sure that it's the appropriate Boolean is double jumping, and I'm going to set this and I'm going to set this to be true. Now this is going to come into play a little bit later on the importance of this, but what this is going to instruct our character to do is to play another jumping animation. Okay, so it actually looks like they're kind of jumping off of midair. So that's going to come into play in a little bit. Okay, next what I'm going to do is I'm going to bring in our character movement component, you can drag and drop that guy in here in office, of this you're gonna drag off of here and you're gonna say get velocity. It's at the very bottom when you type in get velocity.
Inside of our character movement component, if I select that in, in the details panels, do a search for velocity. You've got these velocity settings right here. So all I'm doing here is I'm saying, hey, character movement, I want to access your velocity settings. So what I can do with this is I can right click on this velocity pan right here, if you right click on that, you can split this struct pin, like so. And what that'll do is transform the nodes look like this. And now you have access to the velocity x, y and the Z. I'm going to bring this up a little bit because off of my character movement component, once again I want to drag off and I want to set velocity And make sure that this execution wire is hooked in like so.
But off of this velocity input here, too, I'm going to right click, and I'm going to split the struct pin. What I want to do is I want to say, hey, I want the X to remain the same, I want the Y to remain the same, although the Z i want to zero that out in order to make this double jump work, like I want it to. I want to zero out the characters, z velocity, that's the speed at which they're, they're falling or rising. And the reason I am doing this is in order to make this look right, I experiments, this retesting, you have to zero out the Z velocity. Then what we can do is we can do this cool thing by dragging off of here, called launching the character there's a function called launching the character. And all we need to do here.
Since our target is ourselves, our VP player is feed it a launch velocity. Well that's why I created this double jump velocity variable because I want to make our z launch velocity be 1200. So I can drag and drop that right on top of our launch launch velocity right there. And then the rest of this I'm just gonna extend this out a little bit more is going to be a little artistic flair, some VFX and sound effects. So off of our launch character, I'm going to drag out a wire, type in a play sound. We'll do a 2d sound Sure.
Even though we could do a localized down to the sounds are easier. And the sound that I want to put in here is going to be called start. simulate q That guy right there. The tooltip will show you the path that it's in. It's in some of the engine content folder. So I'm going to slot this in.
But if you don't have access to this and wondering how did I get that if you come under your view options right here in your drop down, you can check show engine content on and that'll make sure that this sound effect is available to you. Okay, so then after that, I'm going to spawn emitter at location. I want a little particle effects play. And I want this to play. The emitter that I want to play here is going to be p underscore hammer sparks. And that was located in my Infinity Blade effects pack if you're wondering where that one came from, And the place that I want this effect to play is going to be essentially at my character's feet.
So if I jump over to my viewport here, and I've got this jump VFX spawn point that's basically at my my character's feet right there. So I'm going to jump back over to my moveset tab, I'm going to bring in a reference to that, that I'm going to drag off of here and say I want to get the world location of that. That's where I want to be spawning this visual effect. Okay, and then in addition to that I want to do like I did before, where I'm going to call our jump effects function that we created earlier. Flipping my page Oh notes. Then what I'm going to do is I'm going to put in a very, very short delay, very tiny delay Drag off here, do a search for delay node.
I'm going to set a delay of point 05 seconds. And then this is double jumping center that I had before. Well, I set it to true right here. And I'm doing this again just to make it so that our character can eventually play another jumping animation. Over here, I'm going to make it so that our is double jumping, we're going to set that one more time. I'm going to set it to be false.
So again, make sure that you've got this Boolean, appropriately set to false and that it is the B is double jumping. And let's jump in and play and test this out. So our characters going to currently Well, I can jump, I cannot double jump. Right? But I'm going to interact with our skill dice here to learn double jump. Okay, now it says that I've Learn double jump.
Now you'll notice something I will be able to double jump now, one, two, but you'll notice a couple things. One when I did that my character didn't play an animation on that second jump and secondly, if I hit the spacebar, I cannot double jump. Again. No worries on that we are going to fix that up very, very soon here. Let me give you one last look at the script here before we close this out so you can see where our jump script is currently at if you need to slow down the video or pause it. This is where our jump script is currently at.
Make sure that you've got the has double jump in this branch has double jump. We're switching on in here our dump jump count is zero by default. Off the zero branch we're checking to see if our character is falling. Here we are incrementing our jump count Coming back to our switch on and off the one branch, we're going to increment our jump count again. Here we are setting our is double jumping Boolean that we created earlier. Again, this is going to come into play for calling a second jump animation.
Here we're briefly zeroing out our characters z velocity, and then launching the character up into the air. If you really want to have some fun and see how high you can set your or make your character double jump, fiddle with that Z value to make your character double jump as high as you want her to jump. Then we're playing a 2d sound. Start simulate, there is our hammer spark VFX we're spawning that at our jump VFX spawn point. Then we're calling our jump up effects function delaying and then setting our is double jump here to false Alright, and then off of this first branch if we don't have the double jump, all we're going to do is just see if our characters falling and then jump in playing the jump effects. Okay guys, that is going to do it for now.
We will see you all in the next video.