Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Blender to Unity 5 Mechanim Animation problems

Discussion in 'Animation' started by adam2050, Mar 19, 2015.

  1. adam2050

    adam2050

    Joined:
    Mar 8, 2015
    Posts:
    16
    Blender animations to Unity 5.x problems


    Hi I am pretty new to the mechanim side of Unity and am having some major problems and after four days of watching tutorials and banging my head against the wall I am asking for some much appreciated help from the community.


    Since upgrading to Unity 5 I have had problems importing Blender animations into Unity. Unity 4 seemed able to take the blender fbx animations with little problem.


    I managed to get my makehuman rig into Unity mechanim and correctly animating mocap animations, after much tweaking the default rig presets, the hands in particular were rigged all wrong with the index fingers taking the thumb etc.


    But when I import the animations they go deeply wrong, as if inverted. I am using the F selector in the blender animator, exporting with -Z Forward and Y up. Importing at a scale factor of 1. I have tried numerous changes to the Mecanim animation settings but they seem to make things even worse. I have attached a link to a video - its high res 50mb, sorry, to illustrate the problems I am having. I am hoping I have missed something obvious and that it is is an easy fix.


    Many thanks in advance.


    Link is https://www.dropbox.com/s/2to0m2zn71jloiu/BlendtoUnityProbs.WMV?dl=0

    Please let me know if there is any other information that would be helpful.
     
  2. adam2050

    adam2050

    Joined:
    Mar 8, 2015
    Posts:
    16
    Quick update, I rotated my model so it faces Z+ but the problem is the same, also have noticed that Mechanim uses the ORG, not DEF or MCH bones, is this correct? What ever I seem to do mechanim seems to alter the animations, forward head roation = back head rotation, a side to side arm movement is up and down.
     
  3. medhue

    medhue

    Joined:
    Aug 24, 2014
    Posts:
    176
    I would first check that your rig, and your mesh, don't have any rotations on them. Likely, your rig or mesh is rotated 90 degrees.
     
  4. adam2050

    adam2050

    Joined:
    Mar 8, 2015
    Posts:
    16
    Thank you medhue for the suggestion the rig was rotated but, having set all rotations to 0 the same effect occures.
     
  5. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Did you set keyframes for all bones in the first frame?
     
  6. adam2050

    adam2050

    Joined:
    Mar 8, 2015
    Posts:
    16
    I set keyframes for all animated bones in the first frame but not for non animated bones. Do I need to set keframes for every bone?
     
  7. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    In my experience, that is the only way to get stable animations from Blender.
     
    theANMATOR2b likes this.
  8. adam2050

    adam2050

    Joined:
    Mar 8, 2015
    Posts:
    16
    Dantus, thank you. This seems to have sorted out the problems. Really appreciate your help. :)
     
  9. medhue

    medhue

    Joined:
    Aug 24, 2014
    Posts:
    176
    Well, there are 2 types of rotation. 1 type is the type you keyframe in pose mode. The other is the rotation of the actual object in object mode. So, just from what you have shown, I'm estimating that your objects rotation is not set to zero.
     
  10. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    That is theoretically correct. Even if you import the .blend file in Unity, it should pick the correct up direction and the correct forward direction along with it to be in the same coordinate system, that doesn't always work. Sometimes the fbx exporter in Blender is modified and I also had trouble with some updates being made in Unity some time ago. From a practical point of view, you should always have all the keyframes set in the first frame to be safe.
     
  11. medhue

    medhue

    Joined:
    Aug 24, 2014
    Posts:
    176
    Yep, and I will also mention that when you export an FBX file from Blender, you should almost always choose Selected objects, and always select on the type of objects, as in Armature, and Mesh, below the Selected Objects option. If you don't choose Selection Only , or whatever, then you could be exporting something else in the scene, possibly even hidden, which is altering your results. I also always export FBX files in ASCII, instead of binary, mostly because I usually have Blend shapes in my meshes, and they don't seem to import into Unity using binary.
     
    theANMATOR2b likes this.
  12. adam2050

    adam2050

    Joined:
    Mar 8, 2015
    Posts:
    16
    Thank you both for posting. I did as you suggested Medhue and set all object rotations to 0 but the same error occurred. Things have improved since following Dantus's advice on setting keyframes to every bone but strange issues still abound. In unity 4 I would save selected as an FBX and access the animation and it seemed to work fine, in Unity 5 that does not seem to work for me and the animation behavior is very odd, deleting everything in the blender scene and exporting the scene works better but for some reason the least strange behaviour seems to occur when I save the project as a .blend in the unity assets folder. As you pointed out Medue that might be because I am saving the fbx as binary not ASCII. What is really confusing me is that in the preview mode when I use select the avatar as the model the animation plays perfectly but in the scene it is almost like the animation stops midway through some rotations but not others. I don't think its an issue with the avatar as older animations I have seem to work ok and spent quite a while going through each unity bone allocation in the mechanim configurator (the hand bones were all wrong). Also I have given up using any ik in my animation and am just using fk. Have ordered a book specifically on Blender to Unity and its workflow. As I am self taught it is possible I am missing something obvious. Any more thoughts you have would be really appreciated. If not I will read up over Easter.
     
  13. Quartz

    Quartz

    Joined:
    May 28, 2014
    Posts:
    1
    I'm having the same issue. I know this a month later but I was just wondering if you found a solution. Thanks, I am pretty new to the programs
     
  14. adam2050

    adam2050

    Joined:
    Mar 8, 2015
    Posts:
    16
    Hi Quartz, I have found the following the best way to import from blender. One, make sure your avatar's rotation and translation is set to 0,0,0. Two, Set both keyframe 0 and 1 to an animation go to pose mode and rather than set individual joint rotations use (i) set whole character, best to do this for all animations. Three, when you export from MakeHuman DO NOT hit the export for rigify, you end up with loads of data that unity seems to have trouble with importing. It is also useful to check the naming convention of bones and if you create IK makesure you name them something like leftleg.IK so unity knows its IK. Any problems here though you can usually solve in the unity avatar configuration window after you have defined your animation as humaniod. Lastly, it seems to work best for me when you dont just try to import the animation but the avatar as well with the animation attached to it - not sure why but thats how unity 5 seems to like it, when I don't do this I get some wierd animations occuring. Hope this helps and thanks to all the help I got on the forums. Lastly in Unity sometimes you may need to set the root bone to hip, this was only needed once though.