Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Import Animations into Unity 4 via fbx

Discussion in 'Editor & General Support' started by helmke3000, Feb 9, 2013.

  1. helmke3000

    helmke3000

    Joined:
    Feb 9, 2013
    Posts:
    1
    Please help, I am lost:

    I think I missed that the workflow to import animations via fbx
    changed completly from Unity 3.5 to 4.

    I can't find ANY tutorial on how to import animation (bone and simple translations)
    in Unity 4. (but I have tons of how to do it in Unity 3.5)

    What I know:
    In Unity 3.5 and before importing animations couldn't have been easier
    -> bake keys -> save as fbx (2010 version to get sure) -> drag&drop it in Unity-> place in hierachy -> press play -> finished

    But with Unity 4 I see the animation only in the preview.
    The animation component is gone and instead I have an animator component.
    Even when I add an animation component and load the desired animation clip nothing happens.

    Please give me a hint where to find information!!!

    And these are simply not up to date:
    http://wiki.etc.cmu.edu/unity3d/index.php/Importing_and_Exporting_Models_(Maya)
    http://docs.unity3d.com/Documentation/Manual/HOWTO-ImportObjectMaya.html

    I really would appreciate your help!!!!!

    - Kind regards
     
  2. Alf203

    Alf203

    Joined:
    Dec 7, 2012
    Posts:
    461
    It has nothing to do with the workflow of importing the animation. What you're saying happens because you are using Mecanim and not legacy system (the 3.5 and earlier animation system).

    You can always revert to legacy in Unity 4 and it will work as before. If you want to do so make sure that in the Rigs tab your character and Animations are set to Legacy and not generic or Humanoid. Then remove the animator component and it will work as before.

    Otherwise if you plan on using Mecanim, read this to understand how it works:

    http://docs.unity3d.com/Documentation/Manual/MecanimAnimationSystem.html

    and make sure you do the mecanim tutorial, it will help you understand :

    http://www.youtube.com/watch?v=Xx21y9eJq1U
     
  3. JiJoBoJaJa

    JiJoBoJaJa

    Joined:
    Feb 20, 2013
    Posts:
    11
    I noticed in watching that tutorial that FBX files are used for the pre-made animations. Not 100% sure of what questions to ask to get the answer I'm after without going through a lengthy explanation. Will try in the hopes the true reason for asking these questions is evident.

    1.) What makes those FBX files from the tutorial I mentioned above different from ones you'd export from 3DS MAX or Modo?

    2.) What if I have my own custom animations for which no pre-made animation exists and I want to use existing animations I've created in Modo but still want to use the rag doll and other physics features that the Mechanim system allows access to? Is there a process for doing this? If so what is it?

    3.) Is it accurate to say that imported animations from Modo or 3DS MAX have no way of making use of the full compliment of available Unity features for rigs(created outside Unity) and physics? Or is there some way to import animations and rigs created in Modo outside unity without having to import them as legacy animations? I guess this question is something of a repeat of question 2.

    Trying to minimize the amount of redo of animation work already done outside of Unity and stick with tools that are already familiar due to time constraints.
     
  4. JiJoBoJaJa

    JiJoBoJaJa

    Joined:
    Feb 20, 2013
    Posts:
    11
    To be clear the real reason for the questions is wanting to utilize all available features in Unity without having to use Mechanim exclusively and understand the process for doing that. Additionally to have the ability to use the rag doll features with imported rigs and be able to blend imported animation segments.
     
  5. Alf203

    Alf203

    Joined:
    Dec 7, 2012
    Posts:
    461
    If I understand this right, you want to have the flexibly and power of mecanim without learning how to use it or knowing how it works. Its the same as if you'd say: hey I want to make a great game but I don't want to learn about programming or how game development works. This type of thinking won't get you very far.

    Anyways here are the answers:

    1) There is no difference. fbx files in the tutorial are the same as before from Modo, Max or Maya etc... nothing has changed. You can use those with legacy or mecanim. You can even use the files from modo directly (I don't know the file extension but they don't need to be fbx). Any model that gets imported in unity is turned into fbx upon import.That is what Unity does when it imports a model. If you want to use legacy you will lose the control and features of mecanim only and not the rest of Unity.

    2) Its the same as before mecanim. How to import your character and the requirements are in the link that I provided in my previous post.

    3)You can use unity physics or ragdoll without mecanim if you choose (then it would have to be with legacy) or with mecanim if you want. Its up to you. Here's a the example: not using mecanim will not prevent you from using physics, audio, or ragdoll in your game. Yep they're totally unrelated.

    Now a few notes :

    - Mecanim is not an animation creation tool. You do not create animations inside Unity with it. Judging from your questions, I'm pretty sure you are confused about this and think that you will now have to do your animations inside Unity. Nope you still do that in your 3D modelling app.

    -Mecanim simply offers more control than with legacy when blending animations and offers retargeting which allows you to reuse an animation you made from one character in Modo to another if they are humanoid characters thus saving you time by not having to recreate the same animation for different characters.

    -You import the animations and models from Modo or other packages just like with the legacy. Nothing has changed on that end, its just like it was before unless you want to use the retargeting feature. In that case the extra requirement is that your bone structure has to make sense and having your model is t-pose helps but it is not always necessary. If you rigged your character correctly from the start you will not have any problems. Again read the docs provided in my link the requirements are all there.

    Bottom line: Reading the docs link provided above would have spared us both a lot of time (you writing this lengthy question and me this answer). If you want the nice new features and control, you have to invest some time learning them, there is no other way. Its like this for every system. You can't master it instantly.

    Maybe mecanim is overkill for you and you were happy with legacy then stick to legacy but keep in mind they are gradually phasing out the legacy system, you will sooner or later have to learn it.

    And please read at least the basics to know what the system is about and what it is designed to do before posting, as it will save everyone's time. Thanks.
     
  6. JiJoBoJaJa

    JiJoBoJaJa

    Joined:
    Feb 20, 2013
    Posts:
    11
    Thanks for the thorough response! Sorry I did a horrible job of explaining myself.

    I would love to learn Mechanim. Looks like a cool tool and well thought out, just cant at this point in time.

    You exaclty answered my poorly constructed question. As you pointed out and as I noticed, there are definitely some slick benefits to the Mechanim system. We wanted to use the blending for one. Will save time and the schematic UI makes it easy to visualize.

    I did read the docs link but I couldn't tell if it was part of new or old documentation and it didn't directly answer the question in the way I wanted it answered. Maybe it did and I missed it in my haste. Also I watched the tutorial from front to end and it didn't answer my specific question either.

    Thanks for taking the time to respond. Very kind of you. You're very patient. Thank you.
     
    Last edited: Feb 21, 2013
  7. Alf203

    Alf203

    Joined:
    Dec 7, 2012
    Posts:
    461
    No problem at all. There is some kind of blending in legacy but it not very good. Its nowhere near as as good as mecanim's.

    Anyways, if you have more questions don't hesitate to post them. I forgot to mention one thing, but you reminded me when you mentioned schematic UI.

    Mecanim uses a state machine which you probably saw in the tutorial. Although at first you will wonder why you must set this up, in the end this will save you a lot of time. You can for example reuse the same animator controller with different animated characters and just replace the animations while keeping the same states and logic. Anyway its a real powerful tool so if you have the chance to learn I would recommend it.
     
  8. JiJoBoJaJa

    JiJoBoJaJa

    Joined:
    Feb 20, 2013
    Posts:
    11
    Thanks.

    We did get it working using legacy. I've yet to see the blends the developer created. He says some are working okay but some might need to be extended. In testing out various FBX files I've been sending him we discovered that poses we intend to be stationary poses need to be more than one frame long otherwise Unity crashes. So I extended the stationary poses from one frame to three frames but he says the transitions are abrupt and that the solution will probably be to extend those stationary poses to yet more frames. This suggests that the blends are dependent upon the number of frames in the FBX file between the two poses that are being blended. I thought I'd seen this was controllable in Mechanim via various settings but perhaps that's only if you're NOT using legacy.

    I need to get some more info from him to find out exactly what he's tried. Since I've set up my model based on all the guidelines in the Unity documentation he should be able to use Mechanim with the FBX files I've given him based on what I'm hearing from you without having to resort to using legacy.

    We're getting it figured out. :D

    Thanks again for the info.
     
  9. Alf203

    Alf203

    Joined:
    Dec 7, 2012
    Posts:
    461
    As far as I know, using legacy making the static pose more frames will not make it blend faster or slower but I could be wrong. Please let me know if you find that adding more frames made a difference. Its also strange that it crashes with only one-frame; It should not really do that. Maybe send the model that crashes as a bug report to Unity ?

    Usually for static poses I use 4 frames and it worked well in the past for me when using legacy. With Mecanim its another story: you have the complete control over the blends so its a lot easier; one less thing to worry about. Mecanim also features blend trees which are great for blending similar types animations and having control over the blending, because you can control the blending programatically with that.

    Yes if you followed the guidelines it should work fine with Mecanim's Humanoid type, allowing you to use the cool retargeting feature :).
     
  10. scr33ner

    scr33ner

    Joined:
    May 15, 2012
    Posts:
    188
    Wow! This has been a very helpful thread, thanks for the info Alf.

    I wasn't quite sure what the deal was with Mecanim (was in same boat as JiJoBoJaJa). I started my project with Unity 3.5 (still a noob) but was able to get my animations to work through trial error, essentially figuring out I needed to keep the legacy settings.

    I was under the impression Mecanim was Unity's internal animation tool.
     
  11. JiJoBoJaJa

    JiJoBoJaJa

    Joined:
    Feb 20, 2013
    Posts:
    11
    I don't know the exact process our developer is using for hooking these up so I can't speak from that perspective. I did notice when first watching that tutorial that the closest analogy I could come up with for my own personal point of reference was that the Mechanim blends are similar to a cross fade with audio files. A cross-fade (in case you're not familiar with audio editing) takes the first audio track and attenuates the decibel level from it's level prior to the cross-fade down in a linear graph to 0 decibels while the second audio track is doing the opposite. The graph doesn't necessarily have to be linear. I can be whatever curve you like to suit your needs. This cross-fade can only be as long as the total length of both tracks minus the overlap. It can't create data for you without you adding it. ;)

    I assume this same basic principle is used in Mechanim blends and is the reason for the need for the number of frames in the FBX file to be at least as long as the length of the blend you want. You can make that blend time shorter if you want by clipping it in the Mechanim editor but not longer without stretching the original "tracks" or animations over time. Stretching the animations across time would have the effect of slow-motion and not a desirable effect in our instance hence the need for the animation length to be at least as long as the blend you want.

    Again, I'm making assumptions based on partial info and personal analogies but seems like a reasonable hypothesis to me.

    I'm not sure he's gotten into the retargeting but I might try it out for my own edification if I get time. The lack of which is what prompted me to ask this question in the first place. ;)

    Thanks again for the continued feedback!
     
  12. JiJoBoJaJa

    JiJoBoJaJa

    Joined:
    Feb 20, 2013
    Posts:
    11
    So did we. We thought it had the ability to add keyframes and reposition the rig's posture. We know now. :D Thanks again Alf203.
     
  13. ANTROPO

    ANTROPO

    Joined:
    May 26, 2010
    Posts:
    51
    Hi guys, I would like to add to the question posted here, as I can't seem to find a straight answer anywhere....

    How are the animation only FBX files configured? I would like to have my files sent to me from a mocap studio in mecanim ready state, so that I can simply drop them into unity. Therefore, the FBX would need to be exported in some specific way (skeleton animation I quess). Is there any requirement for the FBX file to have? Thanks.

    I used modo to create a rig that works fine with mecanim, and I am able to export animations to mecanim too, but only in an fbx that also contains the model. I will have to investigate upon this yet, as to how to export animation only files from modo... :(

    Anyways, If anyone knows of some specific specs for the fbx (animation only) file to use with mechanim, would be very nice of you to post them here for all of us to see ;) thanks.
     
  14. JiJoBoJaJa

    JiJoBoJaJa

    Joined:
    Feb 20, 2013
    Posts:
    11
    I'm not familiar with motion capture so I can't help with that aspect. I've used Modo semi-regularly for the past 3 years though. I'd expect that as with all Modo animations you've been animating locators and your rig rather than animating the mesh itself. You're probably familiar with the "Bake..." menu item under the Animate menu. This will take all your transforms for an locator item and bake them into keyframes. Anything more specific than that is going to be dependent upon how you've set up your animation (if there are deformations, if mesh is animated, etc.) and what you need the output to be. I hesitate to give more advice beyond this because of my relative inexperience and not knowing specifically what you're needing the output to be. I wanted to make sure you at least got a reply. We all know how it is to have to wait on something you need help with when you're under a deadline.

    Since this is a Unity forum and part of this conversation has the potential to drill down into Modo details I'd suggest asking the Modo portion of your questions at the Luxology forums then come back here for the questions that overlap with Unity. They're a great community and very helpful and many folks also have experience with Unity as well and will also have info on how to configure Modo files for export to Unity. http://forums.luxology.com

    Hoping one of the Unity folks here will have an answer for you about the Unity side of your question.
     
  15. ANTROPO

    ANTROPO

    Joined:
    May 26, 2010
    Posts:
    51
    Thanks for the reply, I will only quickly reply to clarify a bit and then fully respond to you a bit later.
    I am not so much interested in modo related stuff, but what is the most friendly animation only fbx file setup/specs for usage with mecanim, that the animation may then be used within unity.
     
  16. ANTROPO

    ANTROPO

    Joined:
    May 26, 2010
    Posts:
    51
    OK, so I have finally read your answer thoroughly. Therefore I repeat my question.

    What is the most friendly configuration of an animation only fbx file, that the mecanim system in unity takes in without error?
    What needs to be exported in the file, that it can then be used on any mecanim avatar?
    I think, that this is an absolutely DCC software independent question, it relates directly to the mecanim system.

    I've had previously experienced various incompatibilities, which made me wonder how are the files for example from unity starter pack configured. I had an opportunity to examine the files through a friend, who had motionbuilder and we tried to mimic the setting of this file during export of our own mocap data. I think there should be a guideline as to how the animation file should look for use with mecanim, but there isn't any :( If this is just something obvious I am missing and a person should know, please let me know. Thanks.

    By the way mecanim is wonderful.
     
  17. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    The Starter pack is unfortunately badly configured. You need to change all the fbx files to use the Dude avatar as reference to get the proper results.

    Any humanoid animation or mocap data should work fine with Mecanim, as long as you have one model that can be configured as an avatar with exactly the same bone structure as your mocap data.

    So they key isn't to mimic our setup as much as provide ANY model that displays the animation correctly and then make an avatar out of that one.
     
    Last edited: Mar 6, 2013
  18. ANTROPO

    ANTROPO

    Joined:
    May 26, 2010
    Posts:
    51
    Hi, thanks for your answer, I am beginning to understand. I am now going to ask a bit more, so maybe if you could spare some time and expand your answer, I will be able to understand fully...

    You say that the animation can be of any humanoid type of any configuration or convention for the bone structure, as long as the model/avatar combo that it is going to be used with within mecanim is (regardless of mecanim's retargeting capabilities) of the same (exactly) bone structure? That would probably be the mistake I have been making. If I want to use differently configured animation with a different model, what do I do? Use a model/avatar with the same structure as the animation as reference, as you say? Thanks. If so, this is something I have missed probably.

    From reading your last sentence, I am starting to feel that mecanim not just retargets anything you throw at it unto anything, that was my false impression, but the animations can be used unto any other avatar as long as the animations provide a model (that I turn into an avatar) and use it somehow as a reference? If so, could you please confirm, i will then continue exploring this functionality myself. Your explanation was very helpful so far. Thanks.
     
    Last edited: Mar 7, 2013
  19. ANTROPO

    ANTROPO

    Joined:
    May 26, 2010
    Posts:
    51
    Today I received this message in a Xsens newsletter (mocap suit system)

    "Xsens joined forces with Unity to give developers easy access to Xsens MVN motion capture data in Unity. With an upcoming release of the new tools, developers can get motion capture data into Unity even quicker.

    The Unity tool set allows artists to view live or pre-recorded motions in real-time on character. Next to the real-time tool there is also a file based approach based on FBX to import Xsens MVN data into Unity.

    The MVN Unity Tools will be first shown at the Unity Unite events in Tokyo, Shanghai and Seoul in April."

    Very good news indeed for bringing animation into mecanim/unity. Thanks guys.
     
    Last edited: Mar 7, 2013
  20. duencil

    duencil

    Joined:
    Dec 17, 2012
    Posts:
    91
    I've been experimenting with animation recently and can add some suggestions

    I can confirm that mecanim has problems with single frame "pose" type animations. The crossfade interpolation from one state to another can only be as long as the shortest animation involved. And the blend tree states normalize the duration of the clips they blend, so having significantly different length clips involved will produce noticeable stretching. Also the animator controller editor sometimes hangs calculating the motion of still animations. They call the clips "motions" for a reason I guess.

    For the fbx format I'm not sure if specifying fbx version 2011 is necessary, but we did have problems with the 2013 one and dropped to 2012, which looks to be working okay for now.

    The character@anim file naming convention does not seem to do anything in unity 4 for me. So separate animation fbx files need to be set up one by one in unity to use a shared avatar in the rig tab if they are to be used in mecanim.

    As for the rig, I believe that using max's Biped automatically produces a mecanim compatible skeleton, but the unity help contains advice on creating bones manually.
     
  21. Alf203

    Alf203

    Joined:
    Dec 7, 2012
    Posts:
    461
    You can multi edit them so its not that bad. I wished they would expose the properties in the API so we can do it from code.
     
  22. duencil

    duencil

    Joined:
    Dec 17, 2012
    Posts:
    91
    Ah. Thanks for the tip
     
  23. uclatommy

    uclatommy

    Joined:
    May 9, 2013
    Posts:
    2
    Let me just state something that everyone knows, but needs to be stated in order to focus your question a little bit better.

    As I understand it, Mechanim animates a "template" mechanim rig. Mechanim understands this "template" rig and can blend different animations together. An example of this are the starter pack animations with the Dude avatar. Mechanim then defines how to map the bones in its template rig to the bones in your custom rig. It uses this mapping to translate the template rig animations to your custom rig and presto! your custom rig can be animated with Mechanim. You do this by setting up a humanoid animation controller and identifying the bones in your custom rig. Mechanim can now control your custom rig with the Dude rig because it knows which bones in the Dude rig correspond to the bones in your custom rig.

    So to summarize:
    Input --(moves)--> Mechanim Rig Animations --(maps to)--> Your Custom Rig Bones --(moves)-->Your Custom Mesh

    Now on to the question:

    How do you make new template mechanim animations and rigs? I believe that is what you're asking. Lets say you don't like the run animation on the Dude avatar. Let's say you want him to run like a girl. How do you replace the run animation with "run-like-a-girl.fbx" so that any custom rig can be made to run like a girl? Is that what you're asking?

    My answer is I don't know, but would also like to know. Can anyone point us to more specific info on this topic?
     
    Last edited: Jul 15, 2013