Welcome back, everyone. In the last video we went about passing along some variable information from our BP player over to our counters animation BP. In this video, we're going to be learning about what a state machine is and how it works, we're going to be utilizing some of that variable information that we pass along. So these state machines are going to enable our player to transition appropriately into and out of different states. In this case, we're concerned about making our character double jumps. So let's get right to it.
Last video we left off in this event graph here inside of our counters Anam BP. We're going to be concerning ourselves with this other graph known as the anim graph over here in the My Blueprint panel, before I click on that, I should specify where this asset lives in the Content Browser if you took a break between videos I am right here in content Metroidvania there is our Countess annum bps of double click on that to open it up. Okay, so we are within the Event Graph tab, I'm going to jump on over to the anim Graph tab. Now the animal graph is how in where we tell our player character what animation they should play, and we can dictate which animal is played based on rules. We specify through using a state machine, you can see that there's a node right here, and on it, it says state machine, you can double click on this node.
And this is what determines which animation our characters should play and when. So we've got an idle run state, we've got a jump start state jump loop and a jump and that's it's pretty basic state machine. Now the added state, all you would need to do is right click in this graph here and you've got an option to add a state and then you can name I could name this like crouch, for example, but I wanted to add a crutch state. And then once you have a state in here, you can double click on that state and determine which animation should play when that state is called. And you can hook up an animation to that state by simply coming down here in the lower right, you've got this Asset Browser here. These are a list of different animations.
So if I wanted to have a state called crouch, and you know my player starts a jump actually, during that state, I could do that. Obviously, that's ridiculous, but I can do it. So I want to back up here and I can back up to where we were with our state machine overview right here by clicking default. And I'm just gonna delete out this crouch state because I don't actually want that. Okay, so flipping my page and else making sure I'm on task here. Okay, between our states here you see these little, these little circular things with kind of a two way arrow on it, you can actually double click on these, these are the rules that determine how we transition from one state to another.
So for example, we have a rule that determines when we transition from an idle or run into our jumpstart, if I double click on this, our rule is is our character in the air, and we're determining if our characters in the air if I jump over to my Event Graph. Here in the Event Graph where we're constantly updating, we're trying to get our pawn owner, we're getting the movement component, we're seeing if they're falling and we're passing that along to setting is in air if they're falling, they are in the air right now, falling is is not necessarily doesn't necessarily mean that they're falling it just means that they're in the air essentially but they is how we determine whether or not they are walking and running versus if they should be getting airborne. I'm going to jump back to our default state right here. So we have rules that run from idle run to jumpstart to jumpstart to jump loop and etc.
It just kind of goes in a wheel right here. Note, however, that you can have states that run back to one another. So for example, if I wanted to have a jump loop, run back to an idle run, I could simply drag a wire by left clicking right here and dragging it over to my idle run. And once I release, it's going to create this little transition note here where I can now double click on this and bring in some rule that should determine when we can transition to that state. Now, again, I don't actually want to place one there, so I'm gonna delete that out. But that's essentially what we got going on here is we've got these different states that our character can be in each state corresponds to a different animation that should be played.
And each of these right here is a rule that determines when we should enter into that state. Okay, so let's get on to trying to hook up a double jump state. What I want to do is drag off of our jump loop right here. And you want to drag kind of towards the top end of this right about here. I'm going to left click and drag. And when I release, it's gonna say, Hey, what do you want to add, I want to add a state.
And I'm going to call this double jump, start. Okay, and I want this to be placed right up here, because I want to be able to not only transition from a jump loop to a double jump start I also want to be able to transition back from a double jumpstart to a jump loop. Now that transition rule did not pop in there, there it is. I just zoomed back in there was my transition note I didn't see it right away. So if you don't see it right away you can you your mouse wheel to scroll in and out, there's my transition role. Okay, and additionally, I am also going to want to be able to transition into a double jump straight from a jumpstart.
Now the jumpstart phase if you will, is really, really brief but technically we want to be able to double jump even if we do a really rapid double tapping of our spacebar or you know the jump button. So I'm going to drag from here our jumpstart over to double jumpstart and create a transition like so. I'm not going to worry about gonna be worried about creating a transition back from this because this happens so rapidly. Okay, so first thing I want to do here is I want to double click on my double jumpstart and I want to determine what animation do I want to play when our character double jumps? Well, that's gonna be relatively easy for me. I like the third person jumpstart.
That is this animation right there. And the cool thing about this is as you kind of mouse over it, it shows you a preview of what that animation looks like. So, here my Asset Browser, my third person jumpstart, I can left click and drag this into the graph here. And then I can simply drag off of here and plug this into the result. That's all I need to do there. That part was easy.
Now what I need to do is add some transition rules. When do I want my player to actually go in to a double jump? Well, I will start off, let's start from our jump starts to our double jump this transition rule right up here. Let's double click on this. That's gonna jump me to a new tab up here. And the rule I want to have for this is simply is double jumping.
We've got this variable right down here is double jumping that we're updating constantly. I can drag and drop that right onto my transition. So The moment we detect our character is double jumping, the moment that that is set to true inside of our BP player, that is going to be passed along to our animation blueprint here in our Event Graph right there, and that's going to be the rule that we use to determine if I'm clicking back on the default write up here, if we should transition from a jumpstart to our double jumpstart. Okay, so that transition is all taken care of the next rule that I'm going to focus on is transitioning from our jump loop to a double jump start. So right here, we're going to double click on that. And I'm going to have the same rule right here double is double jumping.
Gonna plug that right on top of there. Same rule applies for that. And I can jump back out of here by clicking default right up along the top here to jump back To where I was. Last but not least, I've got this transition from double jump start going back to my jump loop, I'm going to double click right here. This one's going to be a little bit more intricate. What I'm going to do is I'm going to right click and some empty space here.
And I can search for a node and I'm going to search for one called time Remaining Remaining. It's going to be Time remaining ratio, third person jump start. Now you had similar options there so make sure that this is the one you got time remaining ratio, third person jumpstart Now how did it know third person jumpstart because it knew that I had the third person jumpstart in my double jump state that is jumping back to my default, a double jump start right here. It knew that I had that animation slot in there. Okay, so jumping back to default. And coming back to where we were this transition rule right here, I'm gonna double click on that, that's where we were.
So I'm going to drag away out of this. And I'm going to bring in a less than symbol, we're going to do float less than float like so. And I'm going to set this to be a point five. And this you can see it needs a Boolean input for there. I'm going to take the result of this and plug it into my can enter transition. So what this means is that when the animal associated with our double jumpstart, in this case, our third person jumpstart annum, when it has less than half of its time remaining, we can transition back to our jump loop animation.
Okay, so we should have an animation associated with our double jumpstart and we've got transition rules that here here and here. I'm going to Compile and Save. And we'll do a quick play test here all right, and there should be a little weirdness that happens. jump in and play. Firstly I need to get my double jump skill so make sure that you collect your double jump skill right there. I'm interacting with it says we've learned double jump.
Okay, so now I'm gonna jump once and then when I'm when I'm airborne. I will jump again once. Okay. Well, the good news is is I was not getting the problem I was expecting to have I was expecting a little bit of hitching there in our jumping. And the reason I was expecting some of that hitching is because with some of our animation retargeting I did a lot of that manually and through imperfections you can get some hitching in If you are having problems with your double jump actually firing off, I would suggest selecting this rule right here. And if it is hitting a little bit over in the Details panel with that rule selected, you have this option for automatic rule based on sequence player state.
You can check that if you are having problems with your character kind of hitching while they double jump, just keep that in mind. If it looked like minded and it worked pretty good, then just leave it alone. But if you are having problems, select that rule right there and check this box. I'm going to leave it unchecked for the time being. Now one thing I noticed that I didn't like though, is that when I double jumps, I was not getting the desired particle effect playing at my character's feet. So I'm going to jump on over to my BP player blueprint quickly.
And here's where we modified our jump script over in our move set graph right over here. And moving right along here we got our spawning emitter at location I was using this hammer spark from the Infinity Blade effects pack. Ah, the scale I had set to 111. I artificially bump this up in my testing, let's go to five, five and five. I'm going to compile, save and let's try this all over again here. Going to collect my skill, hitting my interact button.
There we go. There's my double jump. And here we go. One jump to jump. There we go. See that little kind of explosion.
My controller is going nuts right now. There we go. But you can see that nice beefy particle effect playing in my character's feet upon double jumping. All right, not bad, so we have a double jump skill in place. That'll do it all for this video guys. We will see you in the next one.