Once you have your Blend Shapes set up in Maya:
Export your selection to fbx ensuring the animation box is checked and blend Shapes under deformed models is checked.
Import your fbx file into Unity (assets->import new assets->[name of file].fbx).
Drag the assetAny media or data that can be used in your game or Project. An asset may come from a file created outside of Unity, such as a 3D model, an audio file or an image. You can also create some asset types in Unity, such as an Animator Controller, an Audio Mixer or a Render Texture. More info
See in Glossary into the hierarchy window. If you select your object in the hierarchy and look in 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, you will see your Blend Shapes are listed under the SkinnedMeshRenderer component. Here you can adjust the influence of the blend shape to the default shape, 0 means the blend shape has no influence and 100 means the blend shape has full influence.
It is also possible to use the Animation window in Unity to create a blend animation, here are the steps:
Open the Animation window under 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 of the window click ‘Add Curve’ and add a Blend Shape which will be under Skinned 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 Renderer.
From here you can manipulate 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 create the required animation.
Once you are finished editing your animation you can click play in the editor window or the animation window to preview your animation.
It’s also possible to set the blend weights through code using functions like GetBlendShapeWeight and SetBlendShapeWeight.
You can also check how many blend shapes a Mesh has on it by accessing the blendShapeCount variable along with other useful functions.
Here is an example of code which blends 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 that has 3 or more blend shapes:
//Using C#
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: