Additional Blend Tree Options
Animator Override Controllers
Working with blend shapes
Preparing the artwork
Once you have your blend shapes set up in your 3D modeling application (such as Autodesk® Maya®):
- In your 3D modeling application, enable these export settings:
- Enable exporting animation.
- Enable exporting blend shapes for deformed models.
-
Export your selection to an FBX file.
-
Import your FBX file into Unity.
- Select the newly imported Model in the Hierarchy window. The InspectorA Unity window that displays information about the currently selected GameObject, Asset or Project Settings, alowing you to inspect and edit the values. More info
See in Glossary window displays the BlendShapes section containing all the blend shapes under the SkinnedMeshRenderer component.
- For each of the blend shapes listed, you can change its influence (weighting) to the default shape, where:
-
0
means the blend shape has no influence.
-
100
means the blend shape has full influence.
Create animations In Unity
To create a blend animation:
- Open the Animation window (from the main Unity menu: Window > AnimationA collection of images that create a moving image when played sequentially. In Unity, an animation is the result of adding two different animation keys, at two different times, for the same animatable property. More info
See in Glossary > Animation).
- On the left side of the window, click Add Curve and add a blend shape. The Inspector window displays the new blend shape in the BlendShapes section under the SkinnedMeshRenderer component.
Create the animation you want by adjusting the keyframesA frame that marks the start or end point of a transition in an animation. Frames in between the keyframes are called inbetweens.
See in Glossary and blend weights.
To preview your animation, click Play in the Editor window or the Animation window.
Scripting access
You can also set the blend weights through scripting using functions like GetBlendShapeWeight and SetBlendShapeWeight.
To check how many blend shapes a MeshThe main graphics primitive of Unity. Meshes make up a large part of your 3D worlds. Unity supports triangulated or Quadrangulated polygon meshes. Nurbs, Nurms, Subdiv surfaces must be converted to polygons. More info
See in Glossary has, use the blendShapeCount variable.
This code example demonstrates how to blend a default shape into two other blend shapes over time when attached to a GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary with three or more blend shapes:
using UnityEngine;
using System.Collections;
public class BlendShapeExample : MonoBehaviour
{
int blendShapeCount;
SkinnedMeshRenderer skinnedMeshRenderer;
Mesh skinnedMesh;
float blendOne = 0f;
float blendTwo = 0f;
float blendSpeed = 1f;
bool blendOneFinished = false;
void Awake ()
{
skinnedMeshRenderer = GetComponent<SkinnedMeshRenderer> ();
skinnedMesh = GetComponent<SkinnedMeshRenderer> ().sharedMesh;
}
void Start ()
{
blendShapeCount = skinnedMesh.blendShapeCount;
}
void Update ()
{
if (blendShapeCount > 2) {
if (blendOne < 100f) {
skinnedMeshRenderer.SetBlendShapeWeight (0, blendOne);
blendOne += blendSpeed;
} else {
blendOneFinished = true;
}
if (blendOneFinished == true && blendTwo < 100f) {
skinnedMeshRenderer.SetBlendShapeWeight (1, blendTwo);
blendTwo += blendSpeed;
}
}
}
}
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thanks for helping to make the Unity documentation better!
Additional Blend Tree Options
Animator Override Controllers