Rigging a Character for Animation in Blender

Now we've made a character in Blender, we can start adding bones to them in a process called "rigging". We can move around these bones to move around parts of the character's body. We animate our character by moving these bones around into a pose, saving the pose then moving the bones again to create another pose. We can put these poses into a precise order to make them play one after the other, creating an animation.

First of all, we need to add bones to our character. In Object mode, hit Shift+A to bring up the Add menu, go down to "Armature" (an "armature" is what Blender calls a skeleton), then select "single bone" to add a bone. 


(Blender does come with a pre-made skeleton for human animations, but I haven't got the hang of working it yet. Plus, the template is designed to be facing down the Y axis - I made my character facing the X axis, so it won't attach the bones to my mesh so well. Unless I, y'know, rotate the mesh around so it's facing the Y axis. But I'll stick with making my own skeleton for now.)


A bone in Blender is a weird spiky thing that spawns at the 3D cursor. If you go into Edit mode and click on one of the spheres at either end of the bone, you can move them with G for grab to stretch the bone around.


This first bone is going to be my character's pelvis bone. With the whole bone selected, I'll hit G for grab to move it upwards into the character's body...


...and now I can't see it, since the character mesh is in the way. I could hit the Z key to activate wireframe mode so I can see the bones, but there's another way.

 In the right-hand inspector menu, there's a tab for "Data" that looks like a green stick person. If I click it and look under "Viewport Display", there's a check box labelled "In Front". This makes it so the object (in this case, the bone) appears to be in front of other objects, even when it's inside of them.


If I check this In Front box, then go back to moving my bone, I'll be able to see where it is even when it's inside of the mesh. I'm going to move it so it's bottom is right at the unmentionable area of my character, and the top is roughly where the belly button would be.


It helps to name your bones as you go along. Beneath the Data tab in the inspector is another tab for bone properties - it looks like a green bone. If you click on it, you can change the name of your bone at the top of the menu.


To create another bone, I can click on one of the spheres at either end and press E to extrude out another bone from the first. I'll drag out this new bone so it's top touches roughly where the bottom of the ribcage would be.


I've also given this new bone a new name. You'll see why I'm taking care to name all my bones soon enough.


Now I've extruded out a third bone. This one goes all the way to the bottom of the character's neck. I've called it the "ribcage".




Finally, I've extruded and named by neck bone, which goes up to the top of the neck.



Now's a good time to make sure all the bones follow along the mesh from side view. I've added a slight bend to them, since spines tend to bend a little when we're standing up.


Rigging the Arm

Now I want to add the bones for my character's left arm. However, if I were to just extrude a bone out from the sphere at the bottom of the neck, the result would look weird.


Instead, I want to duplicate one of these bones with Shift+D and drag it over to form the start of the arm. Which bone do I want to duplicate? Well, I want my arm to be attached to the ribcage. What other bone do I have already that's attached to the ribcage? The neck - so I'll select the neck, hit Shift+D to duplicate it, and move it down to the start of my arm.


The black dotted line shows that this bone is parented to the chest bone, just like the original neck bone. I'll grab the spheres at either end and move it around so it fill up the shoulder area.


Since this is the shoulder bone, I'll name it so, and since it's the character's left shoulder, I'll put .L at the end to name it "Shoulder.L". This is Blender's naming convention for left and right bones - when we go on to flip the names, Blender will automatically change this ".L" to ".R" for right.


Now to extrude out the left arm. I've extruded one bone down to where the elbow is and called it "UpperArm.L", then I've extruded another down to where the hand begins and called it "LowerArm.L".


Now I've extruded a bone for the palm of my hand, going down to where the fingers start, and called it Hand.L.


Rigging the Fingers

Now to begin forming the fingers. Obviously, if I were to just try and extrude them all from the bottom of the hand bone, the result would look weird. Instead, I'll add a new bone with Shift+A, then move it into the position I want it to be in.



Now with this finger bone selected, if I shift-click on the hand bone, then right-click and go down to Parent, I can make the finger bone a child of the hand bone, connecting them to each other. When it asks you to click either "Keep Offset" or "Connect", just click "Keep Offset", since we don't want to actually fuse the two bones together.


Now a black dotted like will indicate that these bones are connected to each other.


I can hit Shift+D to duplicate this connected finger bone three more times to form the rest of the fingers.



Now I can extrude out the second half of the fingers on each finger bone. Remember to name each bone as you go, making sure that they end with ".L".

We can use the same method of duplicating the top finger bone to create the top of the thumb bone, then extruding that one out to form the rest of the thumb.



Rigging the Leg

Now we're going to do the leg bones. Since we want our leg bone to be parented to the pelvis bone, and the abdomen bone is already parented to it, we can just hit Shift+D to duplicate the abdomen bone and move it down to form the upper leg bone.


The upper leg goes down to where the knee is, the extruded-out lower leg goes down to the start of the foot. Remember to name them, and since they're on the left side of our character's body, put ".L" at the end of their names.


My feet here are quite simple - one extrusion down for the foot bone, another one out to the toes for the toe bone.


Now let’s get these bones all facing forwards. Hit A to select all the bones, then Shift+N to bring up the Recalculate Roll menu. Select “View Axis” to make the bones straighten themselves up facing where the camera is.


Making IK Bones

Before I do anything else – I could just keep the bones like this and animate them by pressing R to rotate them in pose mode, but I think it would be easier if I could just grab the foot bone, and move the whole leg around along with it. This is called IK (short for inverse-kinematics) - if I grab a bone at the end of a chain, the others should follow along where I move it.

First, I’ll use E for extrude to drag out a new IK bone backwards from the ankle joint (the ball at the bottom of the lower leg bone). I'll name this "LegIK.L", since it's on the left leg.


With this new bone selected, I’ll hit alt+P and select Clear Parent to make it a free independent bone.


Now I’m going to hit Shift+A to make another bone, and move it way out in front of the whole model, keeping it level with the knee, so it looks like it’s pointing away from it. This will help keep our knee pointing forward when we come to posing it. I'll name this bone "PoleTarget.L" (a pole target is the proper name of this kind of guiding bone).


These two bones are our “control bone”, which will direct the movement of the other bones without changing around the geometry of the mesh. So, to stop them affecting the mesh, I’m going to uncheck the "Deform" box at the bottom of the the side menu for both of these bones.


Now I'm going to go into Pose mode. This can be accessed from the top-left of the screen.


Now, in pose mode, I’ll click on the backwards-facing ankle-bone (my LegIK.L), then shift-click on the lower leg bone, then hit Shift+CTRL+C to bring up the constraints menu, from which I’ll select Inverse Kinematics. This should make the lower leg bone turn yellow.


Now if I hit G to grab and move around the ankle bone, it will move around the lower leg, and from there the whole mesh. But it’ll look kind of wonky, so I’ll click on the yellow lower leg bone and go into bone constraints - it's the second tab from the bottom in the side menu, and it looks like a blue bone going through a pulley. There’s an empty box there called “Pole Target”. Click it and select the armature, then in the new “bone” box that appears beneath it, select the bone facing in front of the knee.


This will immediately bend the whole skeleton out-of-whack. Change the chain length to 2 and, if you have to, the pole angle to 90 degrees (to put the foot back in front).


Now try clicking on the backwards-ankle bone and hitting G to grab it and move it around. The whole leg bone structure should now be moving around with it (we'll make the mesh move with it later).


Mirroring the Bones

Now we have all the bones we need for one side of the body, we can now copy them over to the other side. First, now's a good time to make sure all your bones are named, with ".L" at the end of them if they need to be (if they're on the legs or arms).

Now, what I'm going to do is select all the arm and leg bones, duplicate them and move them over to the other side of the body. First things first, I want to change the pivot option at the top of the screen from Bounding Box Center to 3D Cursor - so my objects rotate around the 3D cursor at the bottom.


Now, to duplicate the bones, I'll go into Edit mode, select all the bones on the arm and the leg, and hit shift-D to duplicate. Then, to flip them, I'll hit S for scale, Y to lock the scaling to the Y axis, then type "-1" on my keyboard. That's Shift+D, S for scale, lock to the Y, then -1.


This will place the dupliacted bones on the opposite side of the body. Before you click anything else, at the bottom of the screen will be a box, and at the top of it will be a check box for "Flip Names". Check this box, then click on any of the character's new bones to see what happens.


If you look at their names in the side inspector menu, you can see that the .Ls have all been changed to .Rs. Now Blender can tell which arm and leg bone is for the left and which is for the right.


Now all that's left to do is extrude out the head bone from the top of the character's neck.


I'll also make sure all the bones are facing forward by hitting A to select all the bones, then Shift-N, then selecting "View Axis".


Adding the Rig to the Mesh

To make it so that the bones move around the mesh, go into Object Mode, click on the mesh, shift-click on the bones, then hit CTRL+P to bring up parenting options. Go down to "With Automatic Weights" and click it to attach the bones to the body.


Now go into pose mode and try moving some of the bones around. If all goes well, the mesh should be carried along with the bones as you move them.


To undo any movements in pose mode you've made, you can right-click and go down to "Clear User Transforms" to restore the bones to their original positions.


Weight Painting

You might notice that when we move our bones around, the mesh might deform a little strangely. For example, if we rotate the upper arm bone, some of the armpit is carried along with it, which doesn't look very realistic.


We can fine-tune these deformations with weight paint mode. Weight paint mode allows you to select a bone, then paint in the areas of the mesh that you want that bone to move.

To access weight paint mode, go into Object Mode, click on the armature, then shift-click on the body mesh. Then, press CTRL+TAB to bring up a mode selection wheel. Click on "Weight Paint" to go into weight painting mode.


The character mesh should turn blue. Hold down CTRL and click on any bone to bring up its weights.


You'll see the part of the mesh around the selected bone turn different colors. These colors indicate how much of that mesh will move along with that bone. The red part of the mesh will move directly wherever the bone goes, while the blue parts of the mesh won't be influenced by that bone at all. The yellowy-green parts are in between the red and blue areas, and will move slightly with the bone but not as much as the red area.


Try using G for grab to move around this bone, to see which parts of the mesh move with it.


You can click on the mesh to paint weight on it. At the top of the screen are three bars, and one of them says "Weight". If you drag it all the way to the right, you'll increase the intensity of the weight painting and turn anything you click on red, meaning it will move along with the currently-selected bone.


If you turn this bar the other way, all the way to zero, you'll paint the mesh blue by clicking on it, meaning less of it will be impacted by the current bone.


Now, I'm going to be honest - this is about as much as I know about weight painting. There's probably a much easier way of assigning specific areas of the mesh to specific bones - selecting all the vertices in that area and filling them all in red, for instance - but I don't know how to do that yet. So, my work here is really just a lot of guessing and moving the mesh around to see which bits look too weird when they're bent or moved.



After posing the character like the Vitruvian Man, I can see the armpits and the hips are being squashed and stretched around by the upper arm and leg bones, so I'll have to make those areas more blue with those bones selected.

...you know, looking back, it would've probably saved me a lot of grief if I just modelled the character with their arms outstretched in a T-pose rather than hanging by their sides.


If you want to reset your pose, you can go back into pose mode by selecting the armature in object mode, then select all the bones with A, right-clicking and selecting "Clear User Transforms".

If you want to go back into weight painting mode, you'll have to select the armature in object mode, shift-click the mesh, then change the mode to "Weight Paint" in the top-left.


By the way, my weight painting is symmetrical because I've still got the mirror modifier on my body mesh and haven't applied it yet. This means I can only paint on the one side, but everything I paint on that side is copied over to the other side. If you don't have an active mirror modifier on your mesh but want it to be symmetrical, there's a little arrow you can click on at the top-right of the viewport in weight paint mode that opens up brush options.


In the new menu that appears, click on the "Tools" tab, go down to where it says "Symmetry", then tick the box that says "Mirror Vertex Groups". Clicking the X, Y or Z buttons below it determines which axis the weight painting will mirror itself on.

 Attaching Clothes to the Rig

One more thing - if you've given your character clothes (which we looked at doing in the last blog post), you may find that they don't move around along with the mesh when you move the bones.


In object mode, click on the clothing, then shift-click on the armature. Hit CTRL+P to parent and select "with automatic weights". This will attach the shirt to the armature just like the mesh, so it will move around when you move the bones around...


...but it will do it quite weirdly.


You could go into weight-paint mode to rectify this deformation problem, but I think it would be easier to just copy the weight-painting already on our character over to the shirt. So, I'll hit CTRL-Z a few times to undo back to before we attached the bones to the shirt, click the shirt, shift-click the bones, hit CTRL+P for parenting, and this time select "with empty groups". This will make it so the shirt starts with no weight painting (i.e. completely blue).


Now, click on the body mesh, shift-click on the shirt, then go from object mode into weight paint mode. This should turn the shirt blue.


Somewhere in the top-left of the screen will be a button called "Weights". Click on it and select "Transfer Weights" from the drop-down list. This will copy the weight painting from the body mesh over to the shirt mesh.


In the box that pops up at the bottom-left of the screen, click by where it says "Source Layers Sel..." and change it from "Active Layer" to "By Name".


Now the shirt mesh follows along the armature just like the body mesh does.


That's enough about rigging for now. Next time we'll look at pose mode in more detail and talk about turning our poses into keyframes to create animations.

Comments

Popular posts from this blog

Waiting for Godot (to Work)

Help with Writing - Story and Scene Structure

Making a TileSet for Godot