‫Hello and welcome.
‫This lecture.
‫We're going to be looking at how we can use the anim graph of an animation blueprint.
‫This whole new concept, whole to new concepts to blend animations together using a series of variables.
‫As you can see, I'm changing the variables.
‫It's changing the blend of animation.
‫Let's dive in and see how this works.
‫So we've got some semblance of animation here.
‫But obviously it's not dynamic.
‫It's not particularly interesting.
‫We need to be able to do animations that are far more complicated than this, and Unreal has many great
‫built in systems to do this, the main one being the animation blueprint, which is a blueprint, obviously.
‫So we're not going to be doing this in C++ because animations just make sense to be done in Blueprint.
‫And the main point of the animation blueprint is to bring together all that animation logic and allow
‫us to kind of blend and merge and switch between animations such that our game logic can then drive
‫that animation blueprint.
‫So without further ado, let's try and create an animation blueprint.
‫So in the content browser, either add new or right click, and we're going to go to animation and select
‫animation blueprint here and you'll see right off the bat is asking us to maybe have a parent class.
‫We don't need a parent class.
‫We can just use the default.
‫But it does need a skeleton because like the animations, like the skeletal meshes, they both rely
‫on the skeleton.
‫So does the animation blueprint, which means that then it can use all the animations of that skeleton
‫and it can be used on any of the meshes that relate to that skeleton.
‫Now, obviously, we want the Wraith skeleton here, so let's go ahead and select that and click, okay?
‫And that's going to go ahead and create an animation blueprint based off of the Wraith skeleton.
‫And then for naming convention, we start with a BP underscore and I'm going to call this the just shooter
‫character, basically, because we've got that different prefix.
‫I think it's clear enough it's the animation blueprint for the shoot of character.
‫So if we go ahead and open up that animation blueprint and dock it to our main window, then we're going
‫to see an animation blueprint editor, which in many ways looks similar to your usual blueprint editor.
‫It's got this main graph area in the middle, but in some ways it's different.
‫So we've got the graph area that's similar.
‫This is a slightly different graph to what we used to.
‫It's called the anim graph.
‫You can see there's also an event graph just like your regular blueprint.
‫They have an event graph, but there's also something called an anim graph.
‫We'll get to that in a second.
‫There's a details pane which gives you details about the animation blueprint.
‫So the class itself, you've got the details on that.
‫Notice, we don't have any components against an animation blueprint.
‫That's one difference to note already.
‫We've got this animate preview editor, which allows us to do some stuff with this preview window over
‫here.
‫Why they're not closer to each other by default.
‫I don't know.
‫Asset browser, just like on the animations allows us to look through animations easily bring them in
‫to our editor and here at the top right again, same as animations and meshes, we have this view that
‫allows us to quickly switch between the skeleton, the mesh and the animations and the blueprints that
‫all rely upon that same skeleton.
‫Then over in the bottom left, we've got that my blueprint pane, which is very much the same as my
‫blueprints.
‫On your standard blueprint, you've got your functions, your variables, macros, that sort of stuff
‫is the same.
‫What's different?
‫Oh yeah, we've got the graphs as well.
‫That's also the same.
‫But what's different is this animation graphs and animation layers.
‫Now we're not really going to touch upon animation layers.
‫That's a bit more of an advanced feature that we don't need.
‫But the graph, that is what is very important indeed, because the graph is kind of like blueprints,
‫except we have no execution node or we've got is the data that flows through the graph and what does
‫flow through the graph?
‫Well, basically, we're trying to get to this output pose this output animation pose that we should
‫model our character into.
‫And we do that by connecting up lots of different nodes to this result node.
‫And flowing through that, we end up getting the data that is our output.
‫One simple output that we can go with is, for example, just dragging in an animation into this anim
‫graph and you can see that it creates a node and it has an output pin, which is an animation pose.
‫And if we drag that pose onto the output pose and hit compile, you can see that it's just going to
‫show in our preview what this animation blueprint does.
‫It essentially just plays this ability animation, and that's pretty much what we're doing at the moment,
‫except now we've put an extra layer in between we're putting a blueprint in instead of just playing
‫the animation directly.
‫That's not particularly useful in and of itself, but the different kinds of operations we can do on
‫these poses.
‫Now that is useful.
‫If we right click in the anim graph, you can see there's a lot of stuff going on here.
‫I want to search for something called a blend and there's a few different things in here.
‫Let's see if I can find the most useful one we want at the top.
‫There is a few here, I think blend blend boned by channel, blend multi.
‫We want just the standard blend node.
‫Let's bring that in.
‫And you can see here we've got a value, we've got two input poses and one output pose.
‫So what we can do is we can drag in two different animations.
‫And we can stick that.
‫This one's an additive animation.
‫I don't want to bring that in.
‫That's going to confuse us.
‫Let's use some animations that we might actually use.
‫So we were looking at the forward movement.
‫We've got jog.
‫A jog might be more what we want rather than walking.
‫So let's have a little look at our jog forward.
‫That might be one thing that we can blend and then the other thing we could blend is a jog back.
‫So let's just look for jog and we've got jog, jog b, which I think is stands for Backwards, Forward,
‫Backwards.
‫Let's bring those into our blend node and then output them and see what the results are going to be.
‫When I hit compile, you can see I'm jogging forward if I stick my alpha over to one and then recompile.
‫You can see that now I'm jogging backwards and you can see also as the preview runs, you can see which
‫nodes which where the data is flowing basically from the jog backwards through the blend node and there's
‫nothing coming through that pin.
‫A because alpha blends between the two.
‫Now I can do a 0.5 on the alpha or anywhere in between, and that's going to try and play both of the
‫animations and layer them on top of each other, half of both them.
‫And obviously when you're dealing with jogging forward and backwards at the same time, that starts
‫to look a little bit funny, doesn't it?
‫So what I'm going to do here is I'm going to remove the jog backwards and put in an idle animation instead.
‫So where do we have idle?
‫I'm going to select this idle non-combat and bring that in here.
‫So that now what should happen is if we're at 50%, it's kind of doing this idle non-combat.
‫Half of that or half and then half of the jog.
‫Whereas if I put it at one, it's going to do 100%.
‫Idle.
‫Zero.
‫It's going to do 100% jog.
‫Now, this is not ideal.
‫The fact that I keep changing this alpha, having to hit recompile.
‫So what we can do is we can add in a variable to our blueprint.
‫It needs to be a float so we can go ahead and change the variable type in the details pane to float.
‫And I'm going to change this to blend amount.
‫So and then we can drag that in so we can drag in any variables from our blueprint into the anim graph
‫and hook it up to some of the pins hit compile.
‫And now we go back to our anim preview editor.
‫You can see that it's showing up.
‫These variables like that we've created over here the blend amount.
‫And that means that now if I can just shift that at runtime, I can see and preview what would be happening.
‫And then basically what's going to happen is our game is going to drive these variables in the animation
‫blueprint to get the right sort of animation at any particular point during playing.
‫That's what we're going to deal with a little bit later on in this section.
‫But for now, we're going to try and get this animation looking right when we have the right sort of
‫variables in here.
‫So it's time for a bit of a challenge.
‫See if you can get set up with an animation blueprint and play around with the anim graph.
‫So I'd like you to add another blend.
‫We're going to add them up in sequence.
‫So first you're going to do one blend.
‫It's output is going to go into the input of the next blend, then select an animation that makes sense,
‫such maybe as moving right or left and add some variables that also make sense so that you can tweak
‫them and look at the preview and you can blend between all of the animations, the idle, the moving
‫forward and your animation of choice, whether it's moving left or right, something like that.
‫Pause the video and have a go.
‫Just play with these blends, see if you can make sense of the anim graph.
‫Hey, welcome back.
‫So hopefully you've had a little go.
‫We're going to go and add in another blend node.
‫So search for blend and then scroll up.
‫For some reason this might be to do with my screen scaling.
‫Let's go to the blend and bring across that.
‫See these idle animations?
‫What do I want to do?
‫I think I want to have it move a left.
‫So I'm going to look in my asset browser for jogging and we're going to look for a jogging left animation.
‫Now, by the way, I do know that blends are not the ideal way to do this.
‫In the next lecture, we're going to look at a better way of doing this, which is going to be to use
‫something called a blend space, which automatically allows us to blend movement animations in a very
‫nice way.
‫But we're doing this just to get the idea of the anim graph before we dive into more complicated things.
‫So we're going to blend between, let's see, left and forward, I think.
‫So left here and we're going to copy, cut or move the forward over to be here.
‫And then we're going to patch that in the output of the blend into the input to the next blend, the
‫one that does idle or not.
‫Does this actually make sense?
‫Let's think about the variables.
‫What should the variables be called?
‫I'm going to have one which is called forward.
‫Just forward, that's quite simple and one which is called right or left because we're choosing a left
‫animation.
‫It's also going to be a float.
‫So one of the blends needs to choose between forward and not moving.
‫So that's going to be let's try and make that our first blend.
‫We will hook in the idol combat to a so that at zero alpha it is going to be not moving at one where
‫forward is one.
‫Let's hook up that forward variable to the alpha at one.
‫It's going to move forward and then we're going to bring that in to zero of moving left.
‫Hook that left variable up zero of moving left and at one of moving left were going to hook up at B
‫basically we're going to hook up the jog left.
‫So if we compile that, that's a little bit scatterbrained.
‫But hopefully you get the idea.
‫If we go over to the anim preview editor and we move forward, you can see that we start jogging, reset
‫that and if we move left, you can see that we start moving left.
‫And crucially, if we do both move left and start jogging.
‫We should see a blend, a little bit of both here.
‫We got that forward being blended.
‫If I need to have a little bit less of the left, 50% of the left, you can see I'm kind of moving.
‫It's a weird looking animation.
‫It's not blending it particularly well, but you can see that it's playing both the jog left and the
‫jog forward.
‫Now, as I said, we're going to leave these variables more or less intact, but we're going to change
‫the mechanism by which we actually do the blending to make more sense and use more of those animations
‫that we're seeing in the asset browser for jogging forward, jogging backwards, jogging left, etc..
‫But that's all the subject of the next lecture.
‫This one we have covered more or less the animation blueprints and how the anim graph works and why
‫we have it there in the first place.
‫So I'll see you in the next lecture for more animations.