THIS is how To use ANIMATION BLUEPRINTS in Unreal Engine

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in order to have a character that can walk around like this and jump and stuff you'll have to be able to make an animation blueprint and from there eventually you'll be able to add things like attacking animations and things like this hanging and jumping animation of the ledge all that kind of stuff which we'll do in future videos today we're going over the basics of the animation blueprint system and the state machines we're going to start in a entirely empty project I'm using the third person game template that epic game provides you with Unreal Engine you can make your own or follow along Down Below in the description you'll also find a link to my patreon where you can download the finished project there's not much going on today but if you want to just compare your project to my project to see where things might be going wrong that is a possibility so first things first I'm going to make a separate folder for the player character assets so that we can organize that fail easily and then I'm going to just drag in my player character fbx which is a 3D model file I'm going to import these colors of mesh and I'm also going to be importing the animations simply import all and we've got everything imported here there's a lot of animations that we're not going to be using right now today in future videos I might end up using them if you're down at the project file it's going to include these assets as well including the animations that we're actually going to be using well we have a character imported now so if we go into the third person blueprint here we can go into the mesh which is the skeletal mesh and then we can change out the skeleton mesh assets and if we look through here we'll see our player assets as an option if we go into the viewport we'll be able to see that number one this thing is way too big so let's scale it down a bit until it fits in the capsule component but now when we walk around we have this thing just in the t-pos because it doesn't know what animations to play and when to play those animations so that's where the animation blueprint comes in if you look here we can see in the animation tab we have the animation mode we can either use a custom mode which we're not going to get into right now A animation asset so if you've got a character report that only needs to have one animation playing at all times this will do but we have something a little more dynamic because we're making a player character so we're going to be using a animation blueprint which allows you to put in a animation class in here which we'll be doing in a moment because we need to make that one first so pressing Ctrl and space will pop up this folder structure over here and we're going to go back into my character assets and we're going to go over to the skeleton here which is called player skeleton I'll right click and I can create a anim blueprint we can just keep the name as it is or call whatever you want then when we double click that we open up our animation blueprint so here we can start putting in all the animations that we want to put in so for instance if we just put in the idle animation and hooked it up into the output Bose we'll see that our galaxy is now doing his idle animation we'll also immediately see that there's something wrong here because it's not looping we can come over here into the right hand side and enable Loop animation now when we compile the blueprint again you'll see that the animation now properly Loops but right now it's only playing this one animation and if I put in the jumping animation for instance right and hook that up into there it'll only play the jumping animation so how do I make something that dynamically changes what animation plays well you can make a whole blueprint system for that but there's actually something pre-made in here for you and that's called a state machine so if we add a state machine we can then connect that up to our output pose and if we double click the state machine we end up with a new window right clicking here we can add comments commodes States or a state Alias for now we're going to just simply go through a couple of States so we can add a new state and we'll call this idle and walking and we'll hook up the entry points to this newly made state so whenever the state machine runs the first thing it does is go into this state so this will be the default state that our character is in which is idle and walking States from here we can add more States if we want to so we can add a state for our jumping and let's move that up here hovering over the outside borders of the states let you drag around an arrow to connect it to another state so now our default state is Idle slash walking but we can also from this state go to our jumping State we also want to add one more state which is a falling and this is a state that we want to enable from either our jumping State because after we're done jumping we're going to go into our following animation but if we fall off the edge or something without ever having jumped in the first place we want to skip the jumping so we also want to be able to go immediately from idle walk to Falling then do we ever need to go from jumping to idle slash walking there is a possibility of that but most likely not so let's just keep that the way it is however if we are falling when we stop falling so when we hit the ground we want to go back to our idle and walking so we also need to put a arrow from falling back to walking which creates this double error with two transitions right now this doesn't yet do anything because we need to put actual animations into these states so if you go to our idle slash walking we can double click that and open it up and once again we can put in a idle animation here but we have a similar problem because I called the state Idol slash walking but I only can hook up one animation outputs at a time there we actually have something very neat so if we press Ctrl and space again and we right click making a new assets we can go into animation and we can make a blend space we need to choose which skeleton we're going to go with we're going to go with just a player skeleton and we'll call this one walking idle doesn't really matter what you call it let's open it up and we see an entirely new interface yet again here we have two axes one going from zero to a hundred in the up Direction and One going from 0 to 100 in the left to right direction and we can simply drag in animations onto this grid we're going to only use the left and right Dimension here you can make blunt spaces that make use of two inputs to blend together a lot of different animations in very very cool ways it's a little beyond what we're doing here right now today so we've got our idle animation which we have put at the we're going to use the horizontal plane here at a value of zero so when we're not moving we're going to be at idle then we can put in our walking cycle and when you hold Ctrl there's a little green cursor will follow where you actually put your cursor and that will be the value that we're previewing so you can see this is our normal walking animation and then we also somewhere in here have a running animation which we can put even further along and now you'll be able to see that we can smoothly interpolate from idle to walking to eventually full on running there's a little bit of an issue in there let's open up the Running Animation because this thing is animating way too fast so we can set the rate scale to something like 0.4 and that's a lot better already now let's go back to our walking idle and now we just need to experiment with what values we actually need here and that entirely depends on how fast your character is moving and how fast the animations themselves are so I can't give you values that are going to work in every case but for the time being let's say that we're walking uh up to 50 and then from 50 to 100 we blend to to running that seems pretty good for the time being so instead of just putting in this idle animation here we can do so we can delete that and we've got this new orange Assets in here now and that's our blunt space so we can pull in that blunt space and now we can see we've got two values that we can input and that's going to influence what the actual output animation looks like but they're called none and none which is not very descriptive so let's go back to our idle animation and we can actually see here in the access settings if we go into the horizontal axis we can give it a name so let's call this velocity and now we can see that this horizontal axis is called velocity and going back here the top bin is now called the velocity so we're going to have to input our character's velocity into this top slot the way we do that is we make it into a variable so we can right click this thing and just say promote a variable it automatically makes a float variable down here in the bottom left corner of a proper type and we can use some simple blueprint code to set the value of this velocity which we can do if we come up here into the event graph if you've done any blueprint coding before this should be very familiar and if you haven't done that you probably should get familiar with that before diving into animation related stuff so what we have here is a event blueprint update animation which would be the same thing in a normal blueprint as the event tick this is just going to run continuously while you play the game and we have a Troy get born owner and this is just going to return the pawn in our case that's a character that is animation blueprint has been put on and we can just simply cast that to third person character blueprint which is the one we'll be using and from there we can get the character movement and that one has a get velocity there we go the yellow one all the way at the bottom but we're running into a bit of an issue here right because uh our velocity is a vector 3 which means that it's got three values it's a yellow pin and we're going to try and set that into a float which is a green value and that doesn't really match up so let's drag this in holding alts will get us a note that allows us to set the value of a variable and we're going to connect it up to the cast to blueprint character and luckily there's a function pre -existing in Unreal Engine that will get the magnitude or a length of a vector so if you pull off any Vector you can just say length and then you get a vector length and all that this does is just adding up the three individual numbers of the velocity and that then can go into our set velocity so now our animation will be based on our velocity and the only thing we need to do is fine tune the actual blending points of which values would be walking and which values would be running going back to our state Machine by clicking just on this new state machine up here now we need to worry about the jumping and the falling mechanics and here we get into making transitions so if you click on these little round icons double clicking will get you into the transition and you can put in some simple code here to decide whether or not things should be going into a transition more often than not what you end up doing is you end up making a new variable down here so let's just call this variable is falling and going back into the event graph we can actually get out of our character movement a is falling variable as it is that's just a function that exists on the character movements and we can simply set our newly made bull to be equal to whatever that character movement tells us whether or not it's falling so now we have a variable in our animation blueprint which can show us whether or not we are falling if we are falling so we can drag this new made Boolean in hold on Ctrl gets you a reference to it rather than setting it and we can just simply hook that up into there so that means when we are in the idle and walking State and our is following variable is getting set to true we're going to transition into our falling state so let's add the animation to that now we have a falling Loop which actually I don't think I want this one to Loop so we're going to keep Loop animation off for this but now we only ever have a transition from idle walking into falling and will never transition back so we need to set up the other transition too so let's double click that get a reference to our is falling variable and we want to transition back when is falling is no longer true so we can drag off the is falling and just type not Boolean and that just gets us the inverted value so when this is true this makes it false which means that we're not going to be transitioning so as long as we're falling we won't transition the moment it becomes false this turns it into a true and then we will transition now back in our blueprint third person character we can set our atom class to being uh whatever that was called it's player skeleton and in Blueprint that's quite a mouthful so we can also do is we can just select it and press this button over here use selected asset from content browser and that will then just import that into this field so if we go and play the game now we can see when we start moving we animate and when we stop moving we're idle and when we go up here and we fall down we go into our falling animation we don't yet have a jumping animation uh but since we when we jump also trigger the is falling to be set to true we still have a bit of a jump but there's no leading to the jumper itself so that's the last thing that we're going to be doing today is creating a simple jump and for that we're going to need to go back to our blueprint character itself to add in a tiny little bit of extra code so back in here if we go into the event graph we can see our input settings have all been set up by the template project which is amazing and we also have this jump input we're going to keep things relatively simple for now so let's just make a new variable here and just call this jumping and we're going to set that to True again dragging it while holding alt will get us a setting node and we'll just simply set this to True when we jump and we will set this to false when we stop jumping and it really is as simple as that now that we have this variable existing in this blueprint we can go back to our animation graph here and we can make a jumping variable in here as well which we will be able to set in much the same way that we did before so get that in there and then boom of our cars to BP third person character we can just get jumping and that's the variable we just made so we can pull over that move it around a little bit and hook that up into our set jumping node in our state machine we simply create this transition over here and we use the jumping variable the state itself of course needs an animation in it as well we have a jumping animation so let's hook that up now here we get into a bit of an interesting situation because now when we jump we can see that okay jumping is true but Falling will also at the same time being set to true because we're no longer ground it so which one of these will it take that's where the priority order comes in when multiple transitions are possible at the same time it's going to look at the priority order and both of those are set to one at the moment if I set this to 2 instead it will now look at both these priority orders and pick the one with the smallest value so that being one there's only one last transition that we need to do and that's going from jumping into falling and this is mostly the reason I wanted to include a jumping in this tutorial because this is a very important thing to also note and that is we don't always need to put in any sort of simple code in these transitions because when you just click on them we get a whole lot of things over on the right hand side here I'm not going to explain most of them but what we can do is we can set a automatic rule based on sequence player and state and that sounds very complicated but more or less what that does is it just looks at this state the animation that's playing and says okay so when this animation is finished playing we're going to move on to this animation and now we'll be able to see that when we jump we actually have a different animation play before our following Loop and when we fall off this thing we just straight away go into our falling loop it's a very subtle difference but it gives the character a little bit more springiness to them when he jumps and the animations themselves are kind of stiff and not amazing I know but the practice animations right so don't you worry too much about them actually looking great it's very important to understand the basics of this animation blueprint stuff as well as normal blueprint coding because it's going to come back in a lot of tutorials you're gonna watch in the future most likely so I hope this has been clear again if it hasn't been clear and you'll want to check out the project files for whatever reason there's a link Down Below in the description to my patreon where you can get the project files or if you just want to support the channel that's also much appreciated and a very big thank you to all of my patrons you can see them on screen right now if you want to help out supporting the channel there's a link Down Below in the description to the patreon page
Info
Channel: The Game Dev Cave
Views: 36,786
Rating: undefined out of 5
Keywords: unreal animation blueprint, unreal state machine, unreal animation, animation blueprint, state machine, animation state machine, unreal engine, unreal 4.27, unreal 5
Id: daNOJlX1_8g
Channel Id: undefined
Length: 19min 34sec (1174 seconds)
Published: Wed May 24 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.