Search Unity

Import blendshapes keyframes from maya into unity

Discussion in 'Animation' started by Stranger-Games, Jul 28, 2014.

  1. Stranger-Games

    Stranger-Games

    Joined:
    May 10, 2014
    Posts:
    393
    Hello,

    I have a rigged character animated and also blendshapes animation is included to the head.
    All done in Maya and exported as fbx.
    Everything imports correctly into unity including the blend shapes slider when I select the head mesh.
    The problem is that the keyframed animation on the blend shapes is not imported.
    When I play the animation, the skeleton animation is working correctly but the blend shapes are not moving.

    Any help is greatly appreciated.
     
  2. RichardKain

    RichardKain

    Joined:
    Oct 1, 2012
    Posts:
    1,261
    Unity does not allow for importing blend shape animations. It only handles the blend shapes themselves.

    Your best option is to import the blend shapes into Unity, and then create your blend-shape based animations in Unity's animation editor window.
     
  3. Stranger-Games

    Stranger-Games

    Joined:
    May 10, 2014
    Posts:
    393
    Thank you for your reply. I found the option to create a bone in maya and copy the keys of the blendshapes to that bone rotation or translation.x was very useful. Then I wrote very small script in unity to take that value into blendshape parameter again.
     
  4. Sixus1Media

    Sixus1Media

    Joined:
    Aug 26, 2013
    Posts:
    5
    Just caught this thread; would it be possible for you to share the script you made? It sounds like it could be very useful.
     
  5. sstadelman

    sstadelman

    Joined:
    Dec 17, 2013
    Posts:
    12
    @RichardKain is this still accurate? I've been working with the Mixamo Maya AutoControlRig plugin, and did the same: keyframe the blend shape animations in Maya, then try to export as *.fbx into Unity. The frames with only blend shape animations are not even showing up in the Take 001 animation.
     
  6. RichardKain

    RichardKain

    Joined:
    Oct 1, 2012
    Posts:
    1,261
    http://docs.unity3d.com/Manual/BlendShapes.html

    As far as I know, it is still not possible to import the animations into Unity via the .fbx file. You can successfully export the blend shapes themselves, but animations using those blend shapes in Maya will not transfer over.

    You can create animations using the blend shapes in Unity, using the Unity animation window. But I wouldn't expect to be able to import pre-scripted blend shape animations from Maya, or any other 3D program.
     
  7. sstadelman

    sstadelman

    Joined:
    Dec 17, 2013
    Posts:
    12
    @RichardKain, thanks for pinging back on this, but I think I have some good news. I found a thread that shared that Unity is pegged to the FBX2011 specification, and things tend to get lost on FBX2012+. In Maya, I switched my FBX export settings to FBX2011, and I was successfully able to export the animations related to the keyed blend shape controls.

    Specifically, using the Mixamo Maya AutoControlRig, I was able to auto-rig the skeleton, manipulate the facial blend shape controls--keying the controls directly--then export to FBX. I was required to include the mesh in the export. Then in Unity 4.6.1R1, I imported the FBX normally, completed the Mechanim configuration, and I was able to define an animation clip which plays my blink / mouth open animations, then blend it in with the AnimatorController.

    One note here is that I've been told to not expect the blend shape animations to be portable. That seems reasonable, though I'm verifying it now.

    Here's the thread, and a blog post describing a fix for Maya Plugins:
    http://adammechtley.com/2014/01/help-my-blendshapes-arent-working/
    http://forum.unity3d.com/threads/using-blend-shapes-in-4-3.210412/#post-1482805

    BR/Stan
     
    Stranger-Games likes this.
  8. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    Small tip about this, since we ran into this issue with so many animations taking up lots of data due to having to contain the meshes for the blendshape anims.... Just create a script in Maya that deletes all the faces on your meshes, and hit that when you are exporting for an animation. This way you still have the meshes that retain the Blendshape key linking, but they are only a single poly and take up basically no data.
     
  9. BIG_TEXAS_PETE1

    BIG_TEXAS_PETE1

    Joined:
    Jan 25, 2016
    Posts:
    2

    Hello Invertex. Could you please share the scrip to do this? it would be a great help!

    Cheers

    Pete
     
  10. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    I don't believe in just handing out working code when asked... especially by a first post. But I will direct you on how you can figure out how to do it instead.

    First look up the MEL code to get all the Transforms in your scene. It is the "ls" command with an optional parameter. You want to store the result in a string array.

    Then you want to make another string array that uses filterExpand to convert your Transforms string array to polyMeshes.

    Afterwards, you can do a 'select -r $polyMeshes', call the command that converts your selection to "Faces", and finally call "delete", which will delete all selected faces except for one on each object.

    If you do some searching around, you'll find various complete MEL and Python code examples for automatically selecting all polymeshes in a Maya scene.
     
    theANMATOR2b likes this.
  11. BIG_TEXAS_PETE1

    BIG_TEXAS_PETE1

    Joined:
    Jan 25, 2016
    Posts:
    2
    Thanks Invertex,

    But deleting the faces reorders the vertex numbering the reference to the positions are being messed up as the verts are removed when the delete function is used.
     

    Attached Files:

  12. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    To remove faces, verts must be removed. You only do this on the animations you want to export, but you still need your complete character model with its working blendshapes in Unity. You then assign the exported animation that had the faces deleted to your rigged character model in Unity, and the animation will be able to drive the Blendshape values on the model. The vertex order on the geometry in the animation file does not effect anything.
     
  13. VijetaR

    VijetaR

    Joined:
    Mar 11, 2021
    Posts:
    2
    sstadelman I did it but the problem is still not solved .I rigged character from mixamo and create blends in maya then export it in .fbx format.
    before export everything is fine and good. but after export when i ON blendshapes ,
    The head moves out of its place,
    This is happening in both Maya and Unity
    .