Search Unity

One Rig Many Bodies

Discussion in 'Animation' started by Nihil688, Feb 10, 2015.

  1. Nihil688

    Nihil688

    Joined:
    Mar 12, 2013
    Posts:
    503
    So we are trying to make a game where all the models use the same rig so that they can share animations. They are all humanoids so we are thinking of using Unity's humanoid system. The problem we are getting is that if we get a guy with wide shoulders, thin pelvis and a girl with thin shoulders and wider pelvis is the way the animation needs to be made.

    Example: Hold with both hands a sword, if the animation is made using the skeleton for the little girl, the wider shoulder guy instead of clasping his hands together he will instead have open arms as if hugging.

    Any ideas? We've already spent weeks trying a lot of different things
     
  2. Nihil688

    Nihil688

    Joined:
    Mar 12, 2013
    Posts:
    503
  3. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Do you have Unity Pro or the free version.

    With Unity Pro you could enable both wrist IK and use the IK goal computed by the engine based on the original clip.
    When you import your clip as humanoid, Unity keep both ankle and wrist position/rotation in the clip as IK goal to allow user to match perfectly the original motion.

    Simply create an monoBehaviour on your GameObject and define the OnAnimatorIK callback
    http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnAnimatorIK.html

    Code (CSharp):
    1.  
    2. void OnAnimatorIK(int layerIndex)
    3. {
    4.     if(layerIndex == 0)
    5.     {
    6.         animator.SetIKPositionWeight(AvatarIKGoal.LeftHand, 1.0f);
    7.         animator.SetIKRotationWeight(AvatarIKGoal.LeftHand, 1.0f);
    8.         animator.SetIKPositionWeight(AvatarIKGoal.RightHand, 1.0f);
    9.         animator.SetIKRotationWeight(AvatarIKGoal.RightHand, 1.0f);
    10.     }
    11. }
    12.  
     
  4. Nihil688

    Nihil688

    Joined:
    Mar 12, 2013
    Posts:
    503
    Yep we have pro, ok so that means that we definitely need IK for such cases then? We tried IK for a bit but it looks like it could mess with the end result a bit, obviously there are the weighted results .
     
  5. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Yes, IK is your friend in this case.

    So either you use the IK goal data from the orignal source motion like I proposed in my previous post or you could set your own IK goal based on some handle object parented to your sword. I prefer to use the second solution because once you have it in place you can swap weapon and still have good hand contact on your weapon.

    If your character proportion are too different than yes it can look bad.
     
    theANMATOR2b likes this.
  6. Nihil688

    Nihil688

    Joined:
    Mar 12, 2013
    Posts:
    503
    Yep basically first aim is 30 characters then 100 and 150 so they'll be diverse