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

Translation Animation in the humanoid rig?

Discussion in 'Animation' started by Nanako, Mar 30, 2015.

  1. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    so i have my character, and i'd like to use the animation retargeting features of the humanoid rig since i'll be making more characters in future.

    the humanoid rig doesn't support translation in animation, but i need it. Not for any of the standard humanoid bones, but for one of my additional ones, the weapon bone. i need it to be able to translate relative to the hand, and i really want to still use the humanoid rig. So give me suggestions.

    As it stands, i see two possible ways forward:

    1. I import the weapon seperately with a generic avatar isntead of humanoid. then give it a second instance of the character's animator, and put the generic avatar on that. I'm not fond of this solution, it sounds like performance might be an issue.

    2. I read the position values from the animation clip by script, and set the offset of the weapon (or ideally the weapon bone) every frame to match. I like the sound of this for the sake of transparency, but is it possible?


    So questions:
    Is option 2 possible? Is that translation data still kept and imported in the animation file, even though its not used?

    are there any other possible methods that might accomplish my needs?
     
  2. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    any thoughts?
     
  3. Yakkahboo

    Yakkahboo

    Joined:
    Mar 31, 2015
    Posts:
    3
    How are you currently adding the weapon bone into the humanoid avatar?
     
  4. K1ttyCha0s

    K1ttyCha0s

    Joined:
    Jun 10, 2013
    Posts:
    5
    Hey, Ive been through similar problems with the humanoid rig and using props and weapons. I went with a very simplistic approach in the end :)
    I can tell you that when you are using a humanoid avatar you can have 'additional' bones ( bones that are outside of the avatar template and that are not 'in between' avatar bones) in the rig then these will support translation.
    Humanoid Avatar bones except the hips don't support translation.
    So you can have an additional bone this can just be an empty object in your 3d package as a child of the wrist for example.
    You can parent a prop/weapon model to it in your 3d package for reference and then animate this additional bone.
    Export out the animation including the additional bone animations to fbx and when you import into using making sure to have additional bones ticked and no masking applied in the individual fbx clips.
    The weapon mesh can be added to the appropriate bone manually by parenting it under the character prefab hierarchy or through a script.

    This will allow the weapon/ prop to animate freely so if you wanted to animate change of grip or move the prop independent of the hand you can animate this bone to achieve that. This works well form most character animations.

    There are some issues with this method however which I cant solve:
    Re targeting animation can be a bit messy doing this as the humanoid bones will re target well but the additional joints don't get processed the same well and will just rely on the translation and rotation values in the original animation clip.
    if all the characters hands are identical it wont be noticeable but if there's a big size shape difference it wont look good.
    If a characters holding a weapon/ prop with two hands and you re target you will probably need to look into using the ik features to pin the hand to the correct location as it will most likely be off.
    Also be wary of moving the weapon too far way from the wrist, stuff like holstering can be a problem because of this.

    Id love to know if there are ways around these issues as it makes using weapons with a humanoid rig really frustrating.

    Hope that helps at all.

    :)
     
    theANMATOR2b likes this.
  5. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    I'm not?

    how would i go about doing that?
     
  6. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    okay, i've found a solution:



    in the animation settings, mask section, the weapon bone is unticked (and a few other minor ones like eyebrows)

    Ticking this makes it work, hooray.

    So why is this not ticked by default? Situations where i'd want to not use it are fairly few, imo. How can i make this toggle on by default ?
     
  7. K1ttyCha0s

    K1ttyCha0s

    Joined:
    Jun 10, 2013
    Posts:
    5
    As far as i know you cant. its a pain. You have to do it for every animation clip. :(

    A few versions of unity ago i had an issue where the additional bones in the masking settings you have an image of above were ticked on by default on import. but the additional bones did not animate. I had to turn them off, hit apply and then turn them on again to force them to work. ( Just a warning in case this happens to you, but they may have fixed this recently)
     
  8. vvaris

    vvaris

    Joined:
    May 23, 2013
    Posts:
    26
    Here is how I do it: I export one animation at a time from Blender, tick the boxes, change lengt etc. Then I rip the animation out of fbx using CTRL+D and put it in animations folder. Then I export next animation on top of the old fbx file, ticked boxes remains ticked. Then I adjust the lenght of the animation if nessecary. You need to use 6.1 exporter in Blender for this to work, because 7.4 adds "|" to the animation name, which prevents duplicating in Unity:
     
    nxrighthere and Nanako like this.
  9. vvaris

    vvaris

    Joined:
    May 23, 2013
    Posts:
    26
    I do the holstering using bone constraints in Blender.
     
  10. K1ttyCha0s

    K1ttyCha0s

    Joined:
    Jun 10, 2013
    Posts:
    5
    haha. wow, never realized you can just ctrl+d..... and it makes the file a .anim file and removes the fbx read-only problem. Well thank you. learned something new!! :D
     
  11. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    wow, and what?

    i don't understand why or how 7.4 prevents this?
     
  12. vvaris

    vvaris

    Joined:
    May 23, 2013
    Posts:
    26
    Its explained in the gif. 7.4 exporter adds "|" character to the animation name. Its forbidden character in Unity. Its more Blender problem than Unity problem. My method is pain when you want to iterate animations. Importing animations in Unity is hellish click fest in any case. :D