GET CONNECTED WITH US
Sign up for our newsletter and keep up on the latest updates.
This is part 3 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.
Unreal Engine 4
1. Open up Unreal Engine and press the “Launch” button on the left side.
2. Select the “New Project” Tab.
3. Scroll down until you find the “Blueprint Third Person” option.
4. Name your project on the bottom and click the “Create Project” button.
5. In the Content Browser on the left hand side, click on the folder labeled “Characters” and click “Import” at the top of the browser.
6. Find your character file in the browser and open it. Unreal should already detect that this is the Skeletal Mesh and have it highlighted under “Select Asset Type”.
7. Expand “Advanced” and check “Use Time 0 Pose for Ref Pose”.
8. If you have textures that you would like to import with the model, simply check “Import Materials” and “Import Textures”.
9. We will leave “Choose Skeleton” at “None” for the time being which will result in Unreal automatically making one for us. That’s what we want.
10. Click “Import” at the bottom. When it comes in, you should see the mesh as well as a Skeleton and a Physics asset inside of the Content Browser in the “Characters” folder.
Now we need to import our animations.
11. Go to “Import” again, and find your animations.
12. This time when you click “open” you should see that “Animation” has been highlighted. This is a good sign! Now we need to select the skeleton that we want them to modify. There should be 2 Skeletons to choose from.
13. Choose the Skeletal Mesh that we imported earlier and click Import (Click Import All if you have multiple animations).
Now our animations are in. If you double click on any of them, you will see another screen pop up that looks like this.
This is Persona, where you would do a lot of your tweaking of skeletal meshes and animations inside of Unreal. This is my idle animation which is why she looks so bored right now. Now for the next step.
Let’s pretend for a moment that we started this whole process in Unreal with a Blank Project. We had no code whatsoever and we were introducing the scene to a character for the first time. Well before we would begin programming our character, we would need to set up the inputs for that character first so that the system will know to listen for any buttons or keys being pushed and will know that something needs to happen.
We will need to know what this is for later because we will be referencing these inputs in our Character Blueprint.
1. Go to “Edit” > Project Settings and click on “Input” underneath Engine in the left column.
2. Click on the arrow next to “Action Mappings” to expand it and you will see there is a slot that says “Jump”. That means when we press a certain button, we would like the character to jump. If you expand “Jump”, you will see that there two more slots there. These are the buttons that we want the program to be listening for in order for the character to jump. “Space Bar” is obvious, when the space bar on a keyboard is pressed, the character will jump. Same with the bottom button on a gamepad which refers to the four buttons usually found on an Xbox or Playstation controller; top, bottom, left, and right. This tells it to listen for the “A” button on an Xbox gamepad, or “X” button on a Playstation gamepad.
You’ll notice under Axis Mappings that there is no MoveBackward or MoveLeft axes. That is because these are already taken care of under MoveForward and MoveRight. If you look closely, you will see that W’s scale value is 1. Naturally that is because W is the key we would normally press to move forward. However S’s scale value is -1. This works to allow us to move backwards using the S key.
Up and Down refer to the Up and Down arrow keys on the keyboard. “Gamepad Left y” refers to the y-axis tilt of the left joystick on a gamepad controller.
“Turn” refers to the direction of the camera. In this case, we are using the x-axis location of the mouse to control this.
“Gamepad Right X” is set up to control the turn rate of the camera. So the less the Right joystick is tilted, the slower the camera will move. Left and Right refer to the Left and Right arrow keys on the keyboard.
Blend spaces are sort of mechanisms that allow for smooth blending between animations based on a value. More specifically, we are going to use this to smoothly animate the character to go from idle to walking and from walking to running based on how fast she is moving.
1. Find an empty spot inside of your “Character” folder and right click in it. You will see a menu pop up.
2. Underneath “Other Assets” hover the cursor on “Animation” and select Blend Space 1D. Now you will have to choose the skeleton that you are going to be using in this which again should be easy since we only have two choices and one of them is our character.
3. Name the Blend Space in the Content Browser “Idle_Walk_Run” or “IdletoRun”, whatever makes the most sense to you.
4. When you’re done, double click on it to open it.
When the screen comes up, your bottom center panel might appear to be blank or very squished.
1. We need to expand this a little bit, so maximize the window and try scooting the viewport up a little to make more room.
2. When you start to see it, find the check box labeled “Display Editor Vertically” and click on it. This makes our lives a little easier because now we can see what we’re doing.
3. Under “Parameters”, click inside the box beside “X Axis Label” and type “Speed” and press Enter. This will later become a variable that we will change in order to blend between her animations smoothly.
4. Change the “X Axis Range” from 0 – 100 to 0- 375 (just delete the 100 in the second box and type 375 instead).
5. Click “Apply Parameter Changes”.
6. Now take your idle animation and drag and drop it from the Asset Browser on the right into the blendspace at the very bottom. Except for the Parameter changes on your graph, because I hadn’t clicked the button yet before I took this snapshot, you should have something that looks a lot like this:
7. Next, at the first graph line from the bottom, drag and drop your walk animation. Now you’ll notice that if you slowly move your mouse between these two points on the graph, your character will slowly start to walk!
8. Now, last but not least, drag and drop your run animation at the top of the graph.
Now it should look like this:
Congratulations! You made a Blend Space!
Now comes the dreaded moment when we step into Blueprints…duh nuh nuh nuh! Actually it’s not that bad. We’re going to be doing a simple Animation Blueprint that only involves walking. That’s it! Jumping is a little more complicated. So when we’re done, instead of jumping, our character will just run in midair, but that’s okay.
1. Right click in an empty space inside the Character folder and choose “Animation” > “Animation Blueprint”.
2. In the window that pops up, select “AnimInstance” as the Parent Class and, on the bottom half, choose your character skeleton as the Target Skeleton and click “OK”.
3. Name the Blueprint in the Content Browser and double click on it to open it up. When we open it up, here is what we see.
It looks pretty similar to Persona except we have an extra tab at the top right called “Graph”. This is where we are going to set up what is called a State Machine which will control what state our character is in and the data from that will be piped into our Final Animation Pose which controls how our character animates within the game. A State Machine functions kind of like a flowchart. An “If this happens, do this, and if this happens, do this” sort of thing. Ours is going to be fairly simple, because all we’re going to be doing is walking around.
1. Right click in the empty space next to the Final Animation Pose node and in the Search Bar, type “State”. An option listed under “State Machines” should appear called “Add new State Machine”. Click on it and a new State Machine is born.
2. Name the State Machine something along the lines of “Locomotion” and press Enter. Now we have a State Machine, but it doesn’t have anything in it yet. So let’s fix that.
3. Double click on the State Machine, “Locomotion”, to open it up and you will see that this has created a new tab at the top of the graph so you can easily switch between your Anim Graph and your State Machine.
4. In the State Machine, click and drag a wire from the white triangle next to “Entry” inside the graph. When you release the mouse button you will see a menu come up.
5. Click on “Add State” and you will see another node come up. Name this node “Idle_Walk_Run” or the name that you gave your Blend Space.
6. Next, double click on the state “Idle_Walk_Run” to open up yet another tab. This where we start to do some of our first programming. The first thing we need to do is find our Blend Space in relation to this graph. At the bottom of your screen directly beneath the graph, you should see on the left that there are two tabs. One that says “My Blueprint” and the other which says “Asset Browser”.
7. Click on the “Asset Browser” tab. Here you will see a list of all your animation assets including your animations and your Blend Space.
8. Click and drag the Blend space onto the graph. It will turn into a node when you release the mouse button. Notice that there is a value in it called “Speed”. Remember how in the Blend Space we named the X Axis Label? We called it “Speed”. That is where it’s getting that name from. Fun Fact.
9. Now we are going to promote “Speed” to a variable which will drive our animations. To do this, simply right click on the green circle next to “Speed” inside the “Idle_Walk_Run” node and click “Promote to Variable”. You will see a new variable node come up that is now attached to our Blend Space node. Down in the bottom right hand corner, you will see the Details panel has changed and now displays all the information for the variable.
10. Click inside the box next to Variable Name and type “Speed”.
11. Our variable’s name inside the graph has now changed to “Speed”. Now click and drag a wire from the little man inside the “Idle_Walk_Run” node and connect it to the little man inside the “Final Animation Pose” node.
12. Now at the Top left hand corner, click on “Compile” and save your work. We are now done with the “Idle_Walk_Run” State.
13. Now if we click back on our Anim Graph tab and connect the Locomotion State Machine to the Final Animation Pose node and Compile and save it, we will see cool things happen! Our character will be animated in our Viewport for starters. You may also notice that underneath the viewport in the Anim Blueprint Editor, a new variable has been added under Default called “Speed”.
14. If we click inside the box next to “Speed” and drag our mouse to the right or left, we can increase and decrease the speed value, which allows us to do a little preliminary testing to make sure everything is working okay. As we increase the speed the character animates appropriately. Now that the State Machine is done, it’s time to move on to the Event Graph.
Written by Ariana Alexander for TimefireVR
Sign up for our newsletter and keep up on the latest updates.