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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Animate multiple Humanoid Meshes with 1 Animator

Discussion in 'Animation' started by WolfoOld, Jun 15, 2017.

  1. WolfoOld

    WolfoOld

    Joined:
    Jan 12, 2014
    Posts:
    22
    I have two Skinned Mesh Renderers sharing the same bone structure, practically speaking I have
    Mesh A: Player model
    Mesh B: Clothing model being an invisible "Mesh A" with clothing attached (model-wise)


    How do I animate these meshes simultaneously?
    I thought of either syncing two identical Animators on each Mesh or making the main Animator recognize multiple identical meshes but couldn't get any of that to work.
    Please, help me out! I've been losing my head over this, it feels so simple yet unattainable.

    Thanks for your time.
     
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Hmm - there are several threads about this topic. Have you dug through the animation archive threads?

    What happens when you export all the meshes and rig together in 1 fbx. Doesn't the model come in as one rig, with multiple meshes, with individual skinned mesh renderers?


    I might be wrong - but it looks like your hierarchy is wrong, although I remember other devs talking about having all the bones included in swappable outfits.

    A model I'm currently working with (not my own) is set up differently.
    upload_2017-6-15_1-16-59.png

    Basically all the mesh pieces are not parented to any bone but combined in the prefab. The bone structure only consists of bones, not mesh pieces, and there is only one bone rig/bone hierarchy.
     
  3. WolfoOld

    WolfoOld

    Joined:
    Jan 12, 2014
    Posts:
    22
    I did dig through the animation archives, I found all sort of stuff about mesh combining and animating multiple objects with different rigs but nothing like this.

    I tried setting the root bone of the 'boots' Mesh the same as the character's root but instead it just disappeared.
    I've worked with models with the same structure as the one you posted, although the secondary meshes position didn't really matter, they still had their root transform set as the same as the character's one.

    This is the boots model Rig:


    This is the animator working on the character's model



    I was hoping to animate both meshes simultaneously, but if that's impossible then how should I operate? Should I combine the meshes at run-time?(I tried that with some different scripts but it didn't work out well) Should I somehow attach all these clothing objects to the character's model through Blender and activate/deactivate them at run-time?(Sounds a bit too inefficient)
    I have no idea how to proceed.







    EDIT:
    Just as I had given up hope, I tried one more thing, I copied the character's SkinnedMeshRenderer component, pasted its values onto the boots one, and changed the mesh. It worked.
     
    theANMATOR2b likes this.
  4. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Does the game need swappable clothes?

    If the character will be changing clothes - I believe you want to have bones included in each mesh object - kinda like how you are trying to set it up - but with it working of course. So each mesh object will have the same bone structure - but I have not worked with a system like that before.
    The other option is to rig all clothing pieces to the same skeleton/rig/hierarchy and export them from blender as one big model with all mesh pieces separate. Then in Unity set up a system to hide/unhide all the pieces. I have seen this before - but I do not know the code "controller" behind it - probably something that just turns on/off the skinned mesh renderers.

    If the character will not be changing clothes (in game) you have options. Skin weight all the clothes to the same rig but keep them separate meshes and export from blender all at once. Then you can hide/unhide the clothing items in Unity by turning on/off the skinned mesh renderer of each piece.
    Option 2 - combine all the meshes and reskin them to the rig. So no issues with clothes not animating. but they will not be separate after that - so not swappability.
    Option 3 - the same separate clothing meshes with identical bone hierarchies. This solution has been mentioned by us and is recorded here in the forum. Just gotta find it. ;) Sorry I don't have a link for you.