Homework 3b: Character Skeleton Skinning

Goal To skin a humanoid character and import from Maya into a Unity demo scene.
Prerequisite Exercises

Character rigging involves a lot of complexity and a certain amount of indirection. To allow a character to animate, you place a set of joints inside which act similar to bones in a human skeleton. When a joint rotates, it will deform the mesh around it like you might expect. However, animators typically will not be touching the joints directly. Instead they will animate cons (For "controls", also called "anims" or sometimes "muscles") that will control the bones that will deform the mesh. These multiple layers of indirection between the controls and the mesh geometry give high level but flexible control needed to produce compelling animations.

In this assignment we will focus on building a skeleton for a humanoid character of your own design, importing this rig from Maya into Unity and applying pre-defined animations. If you are interested in learning how to build more advanced character animation controls in Maya, I would suggest taking a look at the assignment here.

Unlike most of what you've done in Maya so far, many results of rigging aren't necessarily visualized in the viewport. You'll make extensive use of the Outline editor (see Hierarchy exercise above).

  1. Design a 3D model for a humanoid figure. Humanoid in this case means that it has two arms, two legs and a head but doesn't have to be a human. You should make use of the same types of techniques you used in Project 1b when modeling the hand. Important points to keep in mind:

    • Your character should be significantly more developed than the very simple example shown below. In particular, you should aim to create a specific character with some recognizable traits. Please include an image of the character (or your own sketch if it is a character of your own design) so I have an idea of what you are going for. You may want to think ahead to the final assignment which will be a chance to use your character model as part of an interactive environment. You don't necessarily have to model fine scale detail such as individual fingers but you should plan to spend enough time to get the overall body shape reasonably accurate.

    • A good technique for making accurate models is to employ both a front view and a side view image reference. Here is an example tutorial Character Modeling Tutorial which demonstrates modeling from a reference. Here are a couple more tutorials that move a bit slower here.

    • You character should generally be bilaterally symmetric unless your design specifically calls for some significant asymmetry. One way to accomplish this is to model only the left side of your character (or model both sides but then delete one half and then mirror to get a final model that is symmetric). Select the mesh for the half object and then use Edit - Duplicate Special and fill in a value of -1 for the X-scale in order to make it mirrored. After you create the duplicate instance you can translate it over to line up the two halves.

      While you are modeling the shape, you can select the Instance option in Duplicate Special to create a duplicate left half that follows any edits you make on the right half. You will notice that when you edit the original the instance will track exactly the same edits.

      When you are done modeling, delete the instance and duplicate again but without Instance checked to create a second half, align the two parts and combine them into a single mesh and merge corresponding vertices.

    • In order to rig your character later, it is useful for the character to be posed in a standard T-pose standing upright with arms stretched out horizontally.

  2. Once you have finished designing the geometry for your humanoid, the next step is to create an articulated skeleton that the mesh "skin" will be attached to. For this you will want to switch to the Animation menu set.

    • Starting in the Front view, from Rigging menu set, use the Skeleton → Create Joints to create a joint chain along the spine. Start at the base of and work up, following the picture below. If the joints appear too big or small, you can adjust their size by going to Display → Animation → Joint Size... (this only affects how they are displayed, and not any internal structure).

    • While in the joint tool:
      • Backspace will undo the last joint.
      • Enter will complete the joint chain and exit the joint tool.
      • To add additional branches to a chain of joints, you can select a joint in the Outliner and then use the joint tool to extend a chain from that point. Alternately, if you create two chains of joints, you can parent one other the other in the hierarchy.
      • The easiest way to select a particular Joint after you have created it is often to just use the Outliner.

    • Create additional joints corresponding to shoulders, hips, knees and elbows following the layout shown in the figure below. In the Outliner, click on these components and rename them with informative names. This will be very useful later on when we import the rig into Unity.

    • At this point, it is important that the joints of the skeleton you are creating actually line up with the geometry. For example, the elbow joint should be inside the arm mesh and centered where the elbow joint would be for the character. In order to place the joints precisely, it is often useful to flip back and forth between the different orthographic views, selecting joints in the Outliner and focusing on them to zoom in and adjust their position.

  3. The final step in modeling is to bind the geometry to the skeleton and then do some touch up.

    • Two housekeeping items to take care of:
      • If you have been visualizing the smooth proxy for your mesh, you will likely want to actually apply Mesh - Smooth at this point to produce a higher subdivision version of the mesh before you bind it to the skeleton.

      • Now that you have the joints all positioned relative to the mesh, now is also a good time to select the whole joint hierarchy and apply Modify - Freeze Transforms. This will zero out the transforms of your chain of joints in their current position, making it the default and easy to return to at any time.

    • Select the body geometry and the root joint in your skeleton and from Rigging menu set, go to Skin → Bind Skin (Options).

    • Reset the settings to the defaults and then set Normalize Weights to Interactive, Max influences to 2, turn off Maintain max influences and create. (NOTE: If you are experiencing issues using the "Flood" operation, try rebinding with max influences set to a larger value. To unbind an old skin select the bound mesh and go to Skin -> Detach Skin.)

    Now select a joint in the Outliner and try rotating it. You should see the mesh geometry deform with it. You will probably notice that some of the deformations don't look that great.

    To refine the binding of the mesh to the joints you must go through a process called weight painting. This takes a little bit to get the hang of so if you get totally stuck, you can always undo or Detach Skin and start over with the previous step.

    • Selecting the mesh and going to Skin → Paint Skin Weights Tool.
    • In the Tool Settings, double check that Normalize Weights is set to Interactive.
    • In the Tool Settings, you can select a joint and then you can paint what that joint affects on the mesh. IMPORTANT: For the Painter operation, you should use Add or Smooth. The Replace operation can give some strange results and so should be avoided. (Explanation: Basically every vertex needs weights from different joints totaling up to one. So if Replace causes the total joint weights to fall below that value, Maya will attempt to distribute those unassigned weight values to what it believes are the correct joints. In this, Maya is usually wrong.)
    • Hold b and click and drag to adjust the brush size.
    • To save time, you can use the Skin → Mirror Skin Weights(Options). Make sure Mirror Across YZ and Closest point on surface are selected. Choose positive to negative if you weight painted the left side of the character, leave unchecked if you painted the right.

    Tip: The flooding option is useful with Smooth operation to blend weights over a long chain of joints. Make sure the Smooth radio button is selected, then push the Flood button. This will apply smooth to the entire mesh for that joint's weights. Don't use flood with the Add operation, otherwise the joint you have selected will start affecting ALL of your geometry.

    Save your final model to ready it for import into Unity. There are several important details to remember:
    • Prior to doing any animation, select the skeleton and your mesh and select Modify - Freeze Transforms. This will zero out the transforms of your chain of joints in whatever their current (default position) is.
    • Select the mesh and skeleton and Edit - Delete All by Type - Non-Deformer History. This guarantees that the history of tweaks you have made to the mesh are all flattened down into the geometry. Caution: Don't delete all the history or you will loose the skin binding
  4. Now that we have a humanoid character, let's make a quick demo that shows it animated. A key advantage of using a standard skeleton is that generic animations designed, e.g. for walking humanoids will immediately apply (although they may not have a lot of personality as a custom animation). To begin, we will import our new asset into Unity where we can build a quick demo.

    • Download and install Unity 5. Make sure you also download the standard asset package. Create a new 3D project and import the "Characters" asset package which includes character controllers and some animations we will utilize

    • Click in the Project Assets window and select Import New Asset.... Choose the Maya file corresponding to your humanoid character model. Unity can directly import Maya's file format as long as Maya is installed on the same machine you are using.

    • Select your humanoid model asset. In the Inspector-Model tab you will see the various attributes for your model. For now the only thing you may need to change here is the model scale since your model in Maya may not be in the same units as other assets you are working with. In my case, I set the scale to 0.1 in order for the default physics gravity to make sense.

    • Switch to the Inspector-Rig tab. Choose Humanoid for the Animation Type. Click "Apply" and then click "Configure". At this point you should see your model and skeleton visualized in the main viewport. If you have built your skeleton correctly, Unity can usually guess which joints in your skeleton correspond to the standard humanoid model it uses. If there are any mistakes you can fix the mapping by hand. At this point you can select one of the joints in the Hierarchy and manipulate it in the Scene (e.g. rotate an elbow). You should see your mesh deform as it did in Maya. If the mesh does not deform, you should double check your model in Maya and try reimporting it. Once you have verified the mapping, click done.

  5. To make a demo, we will use a 3rd person controller and animations already included in the standard Unity assets.
    • Create an instance of your humanoid by dragging the asset into the scene. Create some terrain for your character to stand on. The simplest option is to select GameObject - 3D Object - Plane and scale the plane up. If you are more adventurous, you can import a terrain mesh generated from your Maya plugin in the previous assignment or use Unity's own Terrain tool to model a nice terrain.

    • Depending on where you instanced your humanoid, you may need to position the camera to make sure it is visible. Select the "Main Camera" in the hierarchy and move and rotate it until your figure is visible in the Camera preview. At this point you should be able to hit play and see your character

    • Select your humanoid in the hierarchy. In the inspector window you need to add 3 components. Click "Add Component" and add a Rigidbody, Capsule Collider, and Third Person User Control. Your character already has an Animator component. Edit the Animator - Controller field to be "ThirdPersonAnimatorController".

    • You will need to modify the Capsule Collider component, adjusting the Center Y, Radius and Height until the capsule nicely encloses the mesh. This may be easiest to do by switching to the 2D Scene View. A key detail here is that you want the bottom of the capsule collider to coincide exactly with the transform origin for you model (see figure below).

      NOTE: If the capsule is too far below or above the actual transform origin, the code in the Character Controller that checks to see if the character is standing on the ground will not correctly determine when the character hits the terrain and continue to play the jumping animation.

    • At this point you should be done. Hit play and use the arrow keys to move the character around the terrain, space bar to jump. You may wish to experiment with gravity, jump and material properties to get more interesting behaviors.

    • In order to submit your Unity result, select File - Build Settings... Choose "Web Player" as the platform and click "Build". You will be prompted for a directory where the resulting build will be stored. Please submit a zip file containing this directory so that I can run your build. Rather than uploading your whole Unity project, please upload the web player build which should only be 1-2MB.

Turn In You will be graded on the following: Please turn in a single zip file containing the following components: