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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

No luck importing animations separately from mesh

Discussion in 'Animation' started by MaxYari, Feb 20, 2018.

  1. MaxYari

    MaxYari

    Joined:
    Feb 20, 2018
    Posts:
    13
    Hi everyone, i'm new to Unity (2017.3.1f1 ver) and i'm trying to wrap my head around importing skeletal mesh and animations for it separately. Mesh and anims are done in Blender and exported to FBX.

    From what i've thought and read - following workflow was in my mind.

    1) Import skeletal mesh without animations
    2) Import animations for the same skeleton
    3) Since skeleton is the same - animations just work in Unity

    As you may have guessed, 3 is where i'm stuck.
    After importing both - i'm dragging mesh on to animation preview, but mesh just lies flat in rest pose and animations aren't affecting it.



    On the Rig tab of imported animation Avatar Definition is set to Copy From Other Avatar, and previously mesh's imported avatar is selected.

    Note: despite character being humanoid - i'm trying to use Generic rig for the sake of learning and being able to import any type of rig.

    Mesh and animations that i'm exporting from blender are literally from the same file, I just uncheck mesh and check "baked animations" for the latter.
    While exported together with mesh - animation do work, but doing that doesn't look like a correct workflow and still will not solve an issue of adding new animations to already imported characters.

    What am I doing wrong? hoping for advise, thanks!

    I've posted this question on https://answers.unity.com/questions...sh-t.html?childToView=1469444#comment-1469444 as well, but got zero attention in the past week :(
     
  2. StickyHoneybuns

    StickyHoneybuns

    Joined:
    Jan 16, 2018
    Posts:
    207
    Did you weight paint your character in Blender to tell it how to deform the mesh? If not that is what you are missing. Also, you do not need to export as FBX as Unity will do that for you. I learned all of my rigging from Darren Lile on youtube. I highly recommend watching all 10 rigging videos. Darren will make you a pro by the end of the series.

     
    MaxYari and theANMATOR2b like this.
  3. MaxYari

    MaxYari

    Joined:
    Feb 20, 2018
    Posts:
    13
    Thanks for reply. Yes, character is weighted, I've used this exact skeletal mesh to actually make those animations, i'm just trying to export them separately. Again if exported all together - it works fine.
    Re importing blender files - it seems that i have more control of what is getting imported into unity by doing manual FBX exports, since i usually have a bunch of different layers holding the stuff that i dont really want to import.
     
    Last edited: Feb 20, 2018
  4. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Humanoid rig setup is required for retargeting. Generic does not retarget.
    Worth mentioning - if you haven't already done so - review the animation learning material. It walks new users through the humanoid rig process, to include setting up a proper avatar, retargeting and other related material.

    You mention several time above - mesh -
    The export out of 3D requires mesh and skeleton. So - to make sure - the 'character' needs mesh and skeleton, not just mesh data. (I'm sure you are exporting mesh and skeleton - but never hurts to make sure)

    Common workflow for generic is to import animations with rig and skin.
    There is a process to 'copy/paste transforms per bone' to get animations transferred onto a generic rig, but I do not know this process - so can't assist with it. Better (imo) to use humanoid and retarget animations - as is the suggested workflow for humanoid characters.
     
  5. MaxYari

    MaxYari

    Joined:
    Feb 20, 2018
    Posts:
    13
    I've mentioned "Skeletal mesh" by which i've meant that this character have both mesh and skeleton, and mesh is weighted to the skeleton, and this exact character was used to create animations, then i'm attempting to import same character and animations separately. There shouldn't be any retargeting required since i'm importing animations made for exact skeleton that this character has.

    Again, right now i don't care for humanoid rig, this character is only an experiment, i need to figure out generic to be able to import non-humanoid things.

    Assuming that importing animations together with skelmesh is a way to go, what would I do about importing additional animations to already imported skelmesh with initial anims. Am i suppose to repackage it all in one file and reimport again? Imo this sounds quite wrong. Makes much more sense for animations to work with skeleton they are compatible with no matter what, i don't really see a reason for them to not to.

    Now what if i can't use humanoid, need to do a bunch of different horses for ex, so i'll be bound to repackaging each horse file with full animations set, and then if i'll need to add a single new anim to all horses i will have to go and repackage them all? This simply couldnt be so bad, this sounds so illogical to me :(
     
    Last edited: Feb 20, 2018
  6. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Retargeting is applying animations from one rig to another. fbx files contain rig and animation data. If you are exporting animation data separately it requires retargeting onto a separate imported rig without animation data.
    This is supported with the humanoid setup. Generic workflow is to import rig and animations together, or perform the copy/paste bone transform from one skeleton to another. As I stated - I do not know this workflow so I can not assist, but I know it exists.
    I have not performed updates to an exported fbx without having to export the entire timeline with all animation cycles (setup as generic). It might update the animations with the new existing animation at the end of the timeline without having to update the entire setup.
    A simple test is to export with only one animation setup in Unity as generic, and then create a new animation for it - reexport with new animation to see if this process works or not.

    I always export the animations with the rig and skin. I test export with one animation to assure the setup works properly - then create the other animations and export the final model with all animations. This is my own personal workflow as a solo developer. If you are working in a team with a programmer - they can dig into the documentation and figure the solution for copying the bone transforms onto the same rig in engine. Without a programmer - this workflow is not available in editor.
     
    MaxYari likes this.
  7. teutonicus

    teutonicus

    Joined:
    Jul 4, 2012
    Posts:
    67
    Remapping animations between "generic" rigs should just work so long as their hierarchies and names match up. I use this workflow for all of my characters. A quick check for this is to just drag your rig and one of your anims into a scene and compare their structures. If something in your export process is exporting your animation data with a different structure to your rig (maybe the root of your hierarchy is different for some reason, or your export process is adding a namespace prefix to your animated joints, etc.), then you'll run into problems.
     
    MaxYari and theANMATOR2b like this.
  8. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,204
    Also note that generic remapping only makes sense if it's pretty much exactly the same rig. Humanoid retargeting handles the bone structure being a bit different - so you can play a walking animation for an averagely sized character on a small character and a large character, and the system will compensate pretty well to make the animation still make sense. If you do this on a generic rig, the bones will just be moved, so the large character will be squished and the small character will be stretched.

    For kicks and laughs, try to duplicate a generic character, set the duplicate's scale to .5, put the duplicate in the scene, and play an animation from the original model on it. Congratulations, you just made Dead Space.
     
    MaxYari and theANMATOR2b like this.
  9. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Thanks for clarifying - I forgot about the requirement for bone names. That may have been OPs original issue.
     
    MaxYari likes this.
  10. MaxYari

    MaxYari

    Joined:
    Feb 20, 2018
    Posts:
    13
    Here's a comparison:



    Animations are in blue, character is in red. Seems like everything in character is nested under "Armature" but in animations it just lists the bones without wraping in "Armature". Is that the reason? I've actually made that comparison before but assumed that it works as intended.

    Also how do I make this "remapping", do I need to do something specific? Only thing that I have done is set Avatar inside animations rig to Copy From Other Avatar -> Character's avatar.

    Update: What i did now, imported character (mesh+skel) with animations and attempted to use those animations on previously imported character without animations, works flawlessly. It seems each time i attempt to import skeleton (without mesh) with animations only - bones are imported without being wrapped in "Armature" object, and i guess this screws compatibility :(. So which of those two is a proper behaviour, should bones be wrapped in own object upon import or not?
     
    Last edited: Feb 21, 2018
    remption and theANMATOR2b like this.
  11. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,204
    If the hierarchy of deforming bones are identical in the two rigs, you shouldn't need to set "Copy From Other Avatar". "Create From This Model" should generate equal Avatars, and be able to play the same animations. It might be that Copying is better (it definitely makes fewer objects), but check if switching that option fixes things, just to be sure.

    For generic animation retargeting, the bone path must match relative to the animator. So the problem is definitely that one has an "Armature" bone that's the root of the other bones. The animation on "anims" targets "Arm_IK.L", while the same bone would be "Armature/Arm_IK.L" in animations for "sectant_mesh".

    You could work around this on sectant_mesh if you place the animator on the Armature object, since it looks like the bone paths are similar under those two parent objects. But I would expect anims to have an Armature, not the other way around, so there seems to be something fishy going on.
     
    remption, MaxYari and theANMATOR2b like this.
  12. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    @MaxYari worth checking into - other dev who use blender as primary 3D app have mentioned the armature when posting issues in the past. Might be worth flipping back through animation sub-forum to see what issues others had/solved related to animations from blender.
     
    MaxYari likes this.
  13. MaxYari

    MaxYari

    Joined:
    Feb 20, 2018
    Posts:
    13
    remption and theANMATOR2b like this.
  14. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,145
    I am using v2018.1 b13 and can't get exported animation from Blender to work as well. If you download animation packs from mixamo it looks like they are working but i can not export the armature only without the meshes from Blender and have the animation working in Unity as well. I have never experienced a smooth importing of characters and had troubles correctly import animations even using 3ds max before !
    Pretty unpleasant and annoying !

    P.S. - skinning a dummy object like a simple box to the bone hierarchy and export with it seems to fix it - yep - again have to trick the things in order to get it to work !
     
    Last edited: Apr 4, 2018
  15. Tramplex

    Tramplex

    Joined:
    Dec 10, 2016
    Posts:
    15
    So i was struggling over those animations and rigs. I searched whole internet but no luck.
    And somehow i got it working.
    So if anyone needs help my setup is:
    Exporting from blender:
    Model - Armature, Mesh, Only Deform Bones - checked. Add Leaf Bones, Bake Animation - unchecked.
    Animation - Armature, Only Deform Bones, Bake Animation - checked. Add Leaf Bones - unchecked.
    MAKE SURE MESHES DONT HAVE MATCHING NAMES WITH BONES!!! This wasted 3 hours for me.
    In Unity:
    For Mesh. Import settings, Model - Preserve Hierarchy - checked. Create Avatar from this.
    For Animation. Import settings, Model - Preserve Hierarchy - checked. Copy Avatar From mesh that has it generated previously
     
  16. WiseAX

    WiseAX

    Joined:
    Dec 28, 2016
    Posts:
    2
    Tramplex, you have my thanks! I was about to resign myself to fully re-exporting to FBX (mesh, rig and ALL animation) each time I required a new animation or any other change.

    Clarification on my specific use-case (for others struggling with this):

    I created a fairly complex non-humanoid object (a folding security gate) in Blender 2.92 - complete with mesh, rig and animations. The process to export all of these assets from Blender as a single FBX file then import them into Unity 2021.3 was involved but fairly straight forward. However, if changes or additions to any one of these assets are required (with an emphasis on adding new animation), a full re-export / import of all data would be required and many seemingly unnecessary steps would have to be repeated each and every time a new animation is required. This is cumbersome, to say the least. For my case, it would be most ideal to export/import the completed mesh and rig first then import new animations independently after the fact.

    And this is exactly what Tramplex's above workflow has allowed me to do. That said, I still don't understand the: "make sure meshes don't have matching names with bones!!!" comment and I have yet to experience issues that relate to this (and I hope I never do!).
     
    Odd_Doc likes this.