GET CONNECTED WITH US
Sign up for our newsletter and keep up on the latest updates.
This is part 4 of a 4 part series where we’ll explore character creation and animation using MakeHuman, Blender, and Unreal Engine 4 (UE4) with the help of rigging and blueprints. In this tutorial we continue with Unreal Engine 4 and the implementation of Blueprints.
1. While still inside the Animation Blueprint, click on the Event Graph tab to go to the Event Graph. Right now there is nothing in here because we haven’t added anything yet. We have all these animations but Unreal doesn’t know yet when we want them to play. This is where those Inputs we set up earlier will be coming in handy.
The first couple of things we’re going to do are more program-y than anything, and don’t have a whole lot to do with the animation itself, but it will help keep the log free of errors.
2. So the first thing we want to do is right click inside the graph and in the search bar at the top of the pop-up menu, we want to type “update”. An option should appear in the list under “Add Event” that says “Event Blueprint Update Animation”.
3. Click on that and it will appear in our graph as a node.
4. Click and drag a wire from the execution pin, which is the white triangle inside the node, out into an empty space and release the mouse button. You will see another menu come up.
5. This time you will want to do a search for “Is Valid”.
6. Click on it and it will appear inside our graph, now connected to our Blueprint Update Animation Event.
7. Now drag out a wire from the “Input Object” pin on the Is Valid node and search for the word Pawn. The option Try Get Pawn Owner should appear.
8. Click on it and it will appear and connect to the Is Valid node. This is doing a check to see if our character pawn is valid.
9. Now drag a wire from the execution pin next to “Is Valid” in the “Is Valid node and when you release the mouse button, search for “speed” and click on “Set Speed”. This tells Unreal to go ahead and set our speed if the pawn is valid. Now we just need to tell it what to set it to so that it can drive our animations.
10. Drag out another wire from the “Try Get Pawn Owner’s” execution pin and type “velocity”.
11. Click on “Get Velocity” in the list and it will appear in the graph. This is what Unreal uses to keep track of how fast something is moving. Using this node we are given a vector with information about direction and magnitude. Since we want to know the speed, we won’t really need to know the direction, but we do need to know the magnitude. For that, we need to know the length of the vector that we get from “Get Velocity”.
12. Drag out a wire from the return value of the “Get Velocity” node. in the search bar, type Length. Click on “Vector Length” and hook up the Return Value to the Set Speed node. It should look something like this when you are done.
13. Compile and save your work. Our Animation Blueprint is done!
Now that we have our Animation Blueprint done, we need to set up our Character Blueprint which will serve as our pawn that we will use to move around in the world. But there is a cool time saving trick we can use for this, and that is…. we don’t have to pretend that we are not using a 3rd Person Template Level editor here! We can embrace it! All we need to do is make a copy of the default Character Blueprint, Hero TTP, and replace the character mesh and Animation Blueprint for the ones we made for our character.
1. Go to the Blueprints folder inside the Content Browser and find the Blueprint named “My Character”.
2. Right click on it and click “Create Copy”. Name this Character Blueprint after your character and double click on it to open it. If you are not in the Components portion then click on “Components” at the top.
3. In the Details panel in the left column of the Character Blueprint, under the “Animation” heading, use the drop-down menu next to “Anim Blueprint Generated Class” to select the name of the Animation Blueprint we made.
4. Under the “Mesh” heading, use the drop-down menu to select the name of our Skeletal Mesh.
(it’s a little large because I expanded it a little so you could see it better.)
Here is what we should have by this point.
Above the Details panel you should see the Components panel.
5. Inside the Components panel, click on the [ROOT]Capsule Component.
6. Under the “Shape” heading in the Details panel use the Capsule Half Height and Capsule Radius options to shape the capsule to be about the right size for our character.
7. Once you have it at about the right size, select the character and move him/her up or down so that they are right in the middle of the capsule component.
We can also translate the camera closer or farther from the character as needed. Same with the “CameraBoom” component which the camera is parented to. Depending on how short your character is (mine is pretty short) you may want to move the Camera Boom component up a little. Other that that, our Character Blueprint is done!
8. Compile and save it! See? That wasn’t so hard right?
One last thing…
Now there is just one last thing we have to do. We need to tell Unreal to use this character as our playable character.
1. In the Blueprints folder inside the Content Browser in the main screen, you should see a Blueprint called “My Game”. Double click on it to open it.
2. If you are not in the defaults tab, you should click on it at the top right.
3. Under the “Game Mode” heading, in the box next to “Default Pawn Class”, choose your character from the drop-down list.
4. Compile and save it!
5. Now all that’s left is to close the Blueprint and press the “Play” button at the top of the level viewport.
Tada! Now if you’ll notice, if you try to jump, your character just runs in midair. We anticipated this a while back, because our State Machine in our Animation Blueprint doesn’t have a Jump state. This is a simple enough fix, as you should be able to take a look at the Animation Blueprint of the default character and get an idea of how that works. I decided to skip over it for this round, because I knew that this was going to be a long tutorial already and I wanted to make it as simple and easy as possible.
Remember that you can go back into your Blueprints and change anything that needs to be changed to tweak anything that you don’t like.
I hope this has been helpful to you, especially if you are just starting out with character animation in Unreal Engine 4. If you are having any trouble learning, please take a look at the tutorials I mentioned at the beginning of this document. They were what helped to learn this much. Good luck with your character animating endeavors!
Written by Ariana Alexander for TimefireVR
Sign up for our newsletter and keep up on the latest updates.