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

Animating with a Referenced Model in Maya

Discussion in 'Formats & External Tools' started by shinymark, Nov 9, 2011.

  1. shinymark

    shinymark

    Joined:
    Aug 7, 2011
    Posts:
    66
    Hello,

    After a lot of searching I've seen similar questions asked repeatedly but I haven't seen an answer. I'm asking this again because I think it's very important and I haven't been able to find a solution after searching and trying numerous ideas.

    What I'm trying to accomplish is:

    1. Have a base model and rig stored in its own Maya file. No animations are created in this file.
    2. Create multiple separate animation Maya files that reference the base model and rig.
    3. Animate in the individual animation files.
    4. Export FBX files for use in Unity, using the <basemodel>@<animname> convention outlined in the documentation here: http://unity3d.com/support/documentation/Manual/Character-Animation.html#ImportFile
    Here's what happens:

    1. I make a base model / rig file. Let's call it "<basemodel>". I export this as an FBX into my Unity asset folder.
    2. I make a new Maya file for animating and reference in <basemodel>.
    3. Maya adds a namespace prefix, "<basemodel>:", to the referenced elements in the DAG.
    4. I animate some bones in that file.
    5. I export to FBX, using the <basemodel>@<animname> convention.
    6. Unity picks up on the fact that the animation from the animation FBX file should be associated with <basemodel>, just like the documentation says. The animation clip is added to the prefab for <basemodel>.
    7. At runtime, playing the animation on <basemodel> does nothing.
    Why is this happening? Is there any way to use Maya references in this way with Unity?

    Copying and pasting the model and rig into each individual animation file is unacceptable on a large project with many animations where the rig may have to change. My team really doesn't like the workflow of doing all animations in one file using different frame ranges. That method doesn't scale to multiple animators.

    I dropped both the <basemodel> prefab and the <basemodel>@<animname> prefab into the scene. The latter animates while the former does not. Both of them have the same animation clip set in their animation component. Here's what a simple test hierarchy looks like.


    I would expect that "test" would be animating, since it is referencing the animation clip from "test@bounce" in its animation component. Unfortunately, it isn't. On the other hand, "test@bounce" is animating. (Normally I would never put "test@bounce" in the scene hierarchy. I'm only doing that as a test to compare the two.)

    If I had to guess, is this being caused by the namespace in the reference? Does the animation clip exported no longer know how to find the correct transforms on <basemodel>? Is there some secret FBX export voodoo to make this work?

    Any help is greatly appreciated.

    Mark
     
    Last edited: Nov 9, 2011
  2. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,734
    In the model file you need to remove the rig and keep joints + model only.
    And in the animations file, only joints left keeping the exact same joint hierarchy.

    It works just fine in this way.
     
  3. shinymark

    shinymark

    Joined:
    Aug 7, 2011
    Posts:
    66
    I made a super simple test using two joints and parenting. If you or anyone else has a few minutes, could you please take a look and give me an idea of what is wrong? Again, any help appreciated.

    I'm using Unity 3.4.2 and Maya 2011. In this test I skipped manual export of FBXs and just used the MB file directly.

    Here's the download for my test project: View attachment $ReferenceTest.zip
     
    Last edited: Nov 10, 2011
  4. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,734
    Hmmm well, many people use their MB file directly into Unity but I am definitely against :)

    I am sorry, are you trying to export References?
    Into the ...@...mb file, the skinned models seems to be a Reference.... isn't it?

    I understand now your title "Referenced Model in Maya".

    But I am not sure you can deal with, that could be a very important source of problem if you have to change the referenced model o_O...
    All your animations could be broken!!!!

    As you can see, Maya renames all the joint hierarchy using the XXX:XXX form.
    This provide different names from the main model.

    That is very important the name of your hierarchy from your skinned model and animation data only keep the same name flow.

    If you still want to deal with References into Maya, you can for sure to write a mel script that is break the reference and rename joints before to do a FBXExport; That shouldn't be difficult o_<
     
  5. profanicus

    profanicus

    Joined:
    Nov 23, 2009
    Posts:
    295
    Your guess is correct, this is caused by the different names on your base and your references. Maya is a real pain this way. :)

    What you need to do is export your Unity base model from one of your referenced animations, for example just make an empty animation and use that as the "<basemodel>" in Unity. This way they all have the same namespace.
     
    wangziqing97 and orreborre like this.
  6. shinymark

    shinymark

    Joined:
    Aug 7, 2011
    Posts:
    66
    Thanks for the help guys.

    Profanicus - that fixed it for me. I wish I had thought of that earlier! It's a little bit weird as a work around but it's simple and only one extra file to manage. Thanks again!
     
  7. Kerihobo

    Kerihobo

    Joined:
    Jun 26, 2013
    Posts:
    65
    I realize this thread is very old now, but just in case someone else gets stuck on this and finds themselves here... you can resolve the naming issue when you create your reference simply by going to the option box in maya next to "Create Reference".

    Scroll down to the Namespaces section and choose the option to "Merge into selected namespace and rename incoming objects that match".

    upload_2014-12-19_4-18-7.png
     

    Attached Files:

  8. martinezalonso

    martinezalonso

    Joined:
    Nov 9, 2018
    Posts:
    5
    Kerihobo, you are a SAINT!! That totally worked!!

    Alonso