Search Unity

Problems importing rigged character into unity

Discussion in 'Asset Importing & Exporting' started by Alan.L.Guy, May 4, 2010.

  1. Alan.L.Guy

    Alan.L.Guy

    Joined:
    Apr 28, 2010
    Posts:
    9
    My team and I have been having some trouble getting our animated characters into our Unity. Our characters seem to collapse every time we try to import the .fbx file.

    However, If we import the .ma file rather than the .fbx the mesh does not collapse in on itself.

    The problem I have run into now though is we are creating animations in a separate maya file that references our rig into the scene. When we import this .ma file into unity it seems that nothing else comes in along with it. No mesh, No animations.

    I have read some of the other posts involving issues importing from maya and I have seen where others suggest removing all constraints, controls, and IKhandle. Hoping to fix our issues I created a cleaned version of the skeleton that has only the joints, groups, and mesh.

    Even when referencing this file and converting to .fbx the mesh still collapses in on itself.

    This is for a school project and we have a presentation next week, I'm hoping we can get our animations working by then so any advice is appreciated. Let me know if screen shots or files or anything else will help.

    It would be extremely helpful to other members if we were able to successfully convert files to fbx. But failing that is it possible to import an animation file with a referenced rig/mesh into unity without first converting to an fbx?

    Thanks!
     
  2. Deleted User

    Deleted User

    Guest

  3. Alan.L.Guy

    Alan.L.Guy

    Joined:
    Apr 28, 2010
    Posts:
    9
    Thanks for the tip. I had seen that post earlier which was let me to get rid of the IK handles and such before exporting. I have baked all animation on the joints themselves and still get the collapse.

    I'm unsure how to go about exporting the bones separately and then applying the mesh in unity though
     
  4. Alan.L.Guy

    Alan.L.Guy

    Joined:
    Apr 28, 2010
    Posts:
    9
    I'm trying to add a zipped unity project along with my maya files but every time I hit the add attachment button I get a page that says no post mode specified and my post disappears????
     
  5. Deleted User

    Deleted User

    Guest

    Are you trying to scale your model up inside of unity on the raw fbx import?

    Try not scaling it up and see if it collapses... if it doesn't then you're animation bake wasn't done correctly and it might be that you selected controls/constraints rather than JUST joints - you need to drop down the join heirarchy all the way to the bottom of each level and Ctrl-select them in maya then highlight the transform/rotation fields and Bake as per the link..

    That's what I had to do personally anyhow so try that and see how it goes, good luck ;)
     
  6. Alan.L.Guy

    Alan.L.Guy

    Joined:
    Apr 28, 2010
    Posts:
    9
    The model has the default scale that unity gave it during the import. The animations cannot be baked to the controls/constraints because they do not exist in the maya scene. I deleted them all and baked the rotations to the bones.

    I'd like to upload the unity and maya files but I am having issues with the forums file attachment.

    *I changed the unity scale factor to 1.0 instead of the default .01 the mesh still collapses in on itself.
     

    Attached Files:

  7. Alan.L.Guy

    Alan.L.Guy

    Joined:
    Apr 28, 2010
    Posts:
    9
    Here is the project file as well
     

    Attached Files:

  8. Paulius-Liekis

    Paulius-Liekis

    Joined:
    Aug 31, 2009
    Posts:
    672
    I can reproduce your problem - I can't import it properly into Unity, but at the time I can't import it successfully into 3dsMax (which usually indicates problems with fbx export). During export I get some warning messages about missing bind pose for some bones (the list seems to be similar to a list of bones which are collapsed). Can you get rid of these warning messages?
     
  9. Paulius-Liekis

    Paulius-Liekis

    Joined:
    Aug 31, 2009
    Posts:
    672
    I can import your mesh with animation directly once I fix the reference (I put the rig mesh into same Unity project folder too, but I don't think it's necessary).

    And I have another workaround: you can export your mesh to fbx, then import back to Maya. If you export this mesh again to fbx it doesn't complain about skin/bind pose problems and Unity loads it correctly. So you could just export to fbx, import back to maya and continue work on that.
     
  10. Alan.L.Guy

    Alan.L.Guy

    Joined:
    Apr 28, 2010
    Posts:
    9
    I'll try that workaround today. Thanks for the help I really appreciate it!

    Can anyone post of a screen shot or even just list what settings they use for the fbx exporter?

    Thanks for all the help Paulius and Marinius!
     
  11. Alan.L.Guy

    Alan.L.Guy

    Joined:
    Apr 28, 2010
    Posts:
    9
    Paulius, I did as you suggested and exported the model to fbx then imported to maya, then exported to fbx again. This did strip the error about skin/bind pose problems but the model still collapses when I import it into unity.

    I still have one warning about FC curves being converted to type user, not sure if it is related to the collapse
     
  12. WinningGuy

    WinningGuy

    Joined:
    Aug 10, 2009
    Posts:
    884
    I'm not in a position to download your file right now, but I do have some questions.

    In Maya...

    Is the mesh scaled or are its attributes at 0?

    How about your skeleton? Is the top node scaled or at 0?

    If your skeleton and your mesh end up importing at different sizes, it could make your mesh look like it either imploded or exploded.
     
  13. Alan.L.Guy

    Alan.L.Guy

    Joined:
    Apr 28, 2010
    Posts:
    9
    All mesh attributes are zero and joints are not scaled. File imports correctly into unity as an .ma file now. It Only collapses when I convert it to fbx manually in maya. If I export without deformations the mesh imports correctly but is of course no longer bound to the skeleton. Since unity imports the .ma correctly I'm inclined to think the problem is with my fbx export settings.
     
  14. WinningGuy

    WinningGuy

    Joined:
    Aug 10, 2009
    Posts:
    884
    Browse to your Unity folder in Windows Explorer.
    In Unity/Editor/Data/Tools you'll see a file called FBXMayaExport.mel

    That's the mel script that Unity uses to do the .fbx conversion. You might want to look at the settings there and see how they compare to yours.

    Or you could always just use that script or a customized version of it if you need to make a few changes.
     
  15. Alan.L.Guy

    Alan.L.Guy

    Joined:
    Apr 28, 2010
    Posts:
    9
    Thanks for all the help guys.

    I managed to successfully convert to fbx in maya with our file. I made a bunch of small changes that were suggested but it turns out that the only thing needed to get our original file not to crupple up was to set the fbx exporter to centimeters rather than meters. I won't pretend to understand why setting the option to meters destroys it, but its all good as long as it works
     
  16. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,734
    If your unit in Maya is not the same with unity this is normal you are getting some error issue.

    I added the following code in my exporter before exporting datas to Unity :

    Code (csharp):
    1. // Unity Hack
    2. string $unit = "m";
    3. optionVar -sv "workingUnitLinear" $unit;
    4. optionVar -sv "workingUnitLinearDefault" $unit;
    I also set my default FBx paramater to meter with :

    Code (csharp):
    1. FBXConvertUnitString m;
    If you add this 2 parts in your code, you will never got scale problem in Unity when importing your datas.
     
  17. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Sorry to dig this thread up, but there should really be a big warning somewhere in the docs about this scaling issue. I just went through a 48 hour game jam using Unity, and spent at least 6 hours on this issue alone.

    It's very unintuitive. You can export an FBX with a Mesh and Animation in the scene. The mesh exports at a different scale than the animation causing the mesh to collapse on itself once the animation is applied. It took us a very long time to figure out what was going wrong and only stumbled on this post after the fact (since I searched for Centimeters as the keyword to see if anyone else had run into this issue).

    An import fix in the engine would be the best solution, but a kind word of warning in the Unity animation documentation would have worked just as well.
     
  18. Paulius-Liekis

    Paulius-Liekis

    Joined:
    Aug 31, 2009
    Posts:
    672
    Sorry to hear that. I think I've seen this this issue (mismatch between animation and mesh), but didn't have proper repro-case so far. Could you submit a bug with your files attached and give me the case number?


    I wanted to fix this issue, but ran into bugs on FBX exporters: IIRC, FBXConvertUnitString doesn't work on Maya FBX 2010 plugins. It is one of the issue that I want to fix for Unity 3.1.
     
  19. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,734
    I always use it when it comes to export to Unity...

    Did you send a bug to FBX support team?
    They are usually faster to resolver bug from FBX export than Maya and 3dsmax...
    And they are very cool people, give it a try :wink: !

    http://area.autodesk.com/forum/autodesk-fbx/fbx-plug-ins-import-export-discussions/

    Also I found that... Not the best way but...

    http://forum.unity3d.com/viewtopic.php?p=311826
     
  20. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    Sorry, I was away for a while. I've just reported the bug via the Unity menu. The bug still appears in Unity 3.0. The attached file I submitted is called BrokenSeagull.fbx.

    Cheers.
     
  21. Paulius-Liekis

    Paulius-Liekis

    Joined:
    Aug 31, 2009
    Posts:
    672
    Yes, I did (I submit quite a lot of bug reports/support issues to Autodesk ;)). We actually have more direct way to submit bugs as developers on SDK. Autodesk support is great! :D
     
  22. Beloudest

    Beloudest

    Joined:
    Mar 13, 2015
    Posts:
    247
    This issue still exists, like a bad smell. Thanks all for working hard to show me the cause.
     
  23. Justin-Wasilenko

    Justin-Wasilenko

    Joined:
    Mar 10, 2015
    Posts:
    104
    Luckily I found this thread and found out my problem was the same.

    I have a script:

    Code (CSharp):
    1.     public const float importScale= 1.0f;
    2.     void OnPreprocessModel()
    3.     {
    4.         //Sets FBX Mesh Scale Factor to 1
    5.         ModelImporter importer = assetImporter as ModelImporter;
    6.         importer.globalScale = importScale;
    7.     }
    That would change the scale of everything to 1 on import instead of the default 0.1. This changes how the rigs / animations are scaled and causes problems.

    For anyone else who finds this thread, the problem lies with the Import settings of your character and the differences in scale between Unity and your 3D package.
     
  24. Beloudest

    Beloudest

    Joined:
    Mar 13, 2015
    Posts:
    247
    Good answer
     
  25. dmlightup

    dmlightup

    Joined:
    Jun 7, 2017
    Posts:
    15
    Doesn't turning Segment Scale Compensation on your Maya joints solve this problem?
     
  26. jake46116

    jake46116

    Joined:
    Jun 27, 2018
    Posts:
    4
    hi guys im having a trouble , my model in blender is not a T-pose , when i added it to unity it showed red on the hips , and shoulder so i selected a forced T-Pose and every thing showed Green Then i added the Third person controller to the character The head is backwards the legs and abdomen are in reverse and the hands are in the correct direction