BlendShapes from Blender to Unity not working?

Hello everyone!
Do you know if there is a way to get Blender’s BlendShapes into Unity?
Because I have been trying to do so for a while now and it just doesn’t seem to work.
I am using Blender 2.76 and Unity 5.2.2 and both .blend and .fbx files won’t play the animation.
However, when opening the subcategories of the .fbx, I can see Unity recognizes that there is some sort of animation.
Do I need to have a special setup for this? I just tried to set keyframes for the BlendShapes, but those can’t be seen in Blender’s Action Editor. Maybe this is the problem?

Thanks for any suggestions,
Greetings,
Shu

Summary… Object & skeletal animation can be exported. Blendshapes mesh data can be exported but you have to script it in Unity. Custom controls used in your 3D tools which you use to drive you shape animations won’t cross over in the export. There were a few solid tools suggested in that thread which should help your setup inside Unity.

Hope that threads helps!

1 Like

@_GimbalLock
Thanks for your reply! So this seems to be more complicated now than it was in Unity 4.x, though.
Because in Unity 4.x, it could be imported without any further work.
(for example, take a look:

)

I have not Blender , but if I made with my cheap easy to use tools an Animation where every frame presented a 100% Morph , Unity will listed all Morph separately in the skinned mesh render. No big deal actually

Maybe you need bake your morphs as a animation too ?

1 Like

I didn’t have time to watch the video so may have been covered but Blender won’t export the blendshapes if there are any modifiers such as mirror or edge split on the object.

10 Likes

Are you exporting from Blender using the fbx export or simply dragging in the .blend to Unity? In the video you posted it matches up with what I was describing. I believe the morphs will be imported, what is missing is the key frames on custom controls. So the key frames driving the morph value(animation) in Blender is what’s missing inside Unity. That’s what the they keep changing the morph “Key 1” value in Unity to show you the change in Unity.

So you either need to create a custom script or a simple animation inside Unity controlling that value. Something they didn’t show in that video but holds true here, I think.
.
Also, as EiknarF mentioned. Modifiers need baked(applied) for their affect to carry into Unity.

If you want post your assets and I’ll see if I can get the morph working on my end.

1 Like

Thanks a lot for your replies!
I don’t know why, but after testing it once again, it worked. Maybe I did have some sort of modifier on one of the meshes? I really don’t know. Now it even works with the .blend files. So I can save the data directly into the assets and keep editing right away.
Also, accessing the animation by script was pretty straightforward.
Here is the code for a simple animation between the two BlendShape states:

using UnityEngine;
using System.Collections;

public class blendshapetest : MonoBehaviour {

void Start () {
    thisSkinnedMeshRenderer = this.gameObject.GetComponent<SkinnedMeshRenderer>();
    StartCoroutine(ShapeKeyAnimation());
}

SkinnedMeshRenderer thisSkinnedMeshRenderer;
IEnumerator ShapeKeyAnimation () {
    for (float i = 0.0f; i < 100.0f; i+=1.0f) {
        thisSkinnedMeshRenderer.SetBlendShapeWeight(0,i);
        yield return new WaitForSeconds(0.02f);}
    for (float i = 0.0f; i < 100.0f; i+=1.0f) {
        thisSkinnedMeshRenderer.SetBlendShapeWeight(0,100-i);
        yield return new WaitForSeconds(0.02f);}
    StartCoroutine(ShapeKeyAnimation());
}


}

Also, see the .zip for the .blend that I used to test this.

2549458–177249–blendshapetest.zip (75.7 KB)

3 Likes

I spent a good hour looking for this answer, thank you!

Just a point of clarification: You are allowed to have the armature modifier, but basically nothing else.

Also, if you already added Shapekeys, you’re not allowed to apply any modifiers, even though you need to. You have to delete them, apply the modifiers, and them recreate them, basically scrapping a big part of your work. Very tedious and confusing (as with most things in Blender).

3 Likes

There’s a workaround about this last issue (applying modifiers on a mesh with shape keys in Blender): create as many copies of the mesh as the number of shapekeys, apply one shape to each mesh, apply all modifiers, then rejoin the meshes using the function “Join as shapes”.

1 Like

Yes thank you, I had left a Data transfer Modifier on and it worked perfectly after removed them

1 Like