Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Mirror Humanoid Animation with Extra Bone

Discussion in 'Animation' started by super-wind, Nov 11, 2016.

  1. super-wind

    super-wind

    Joined:
    Jan 6, 2015
    Posts:
    3
    Hi, i'm trying to mirror a humanoid animaiton with extra bones, as shown
    upload_2016-11-11_15-22-23.png
    I've kept the bone name in animation exactly the same as the model, and i've enabled them in the mask. The animation seems normal in the game, but once i enabled Mirror, the extra bone's animation is really weird while the human animation mirrored correctly.

    so did I get something wrong? or these is another way to mirror an extra bone animation in the humanoid mode?

    any clue will do lots of help, thanks.
     
  2. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,661
    Mirror animation will only work for human transform.

    there is no way for us to know which transform map as a mirror for extra bone, you will need to mirror extra bone animation by yourself
     
  3. super-wind

    super-wind

    Joined:
    Jan 6, 2015
    Posts:
    3
    Got it, Thanks for the reply.
     
  4. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,293
    Is there system for this on the horizon? Mirroring in mechanim is super handy but it's a pain and kinda clunky to have to make your own system for mirroring any animated bone objects that might be attached to the player.
    Surely most characters in games will be holding or carrying weapons and all sorts of things so I imagine this is a problem that will pop up constantly with animations in Unity.
    Perhaps you could have the user set which axis should be mirrored for each of the extra bones transforms?
     
  5. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,661
    No it not on the roadmap, it not something that was asked very often.

    We would need to specify the mirror transform and the mirror plane for each extra bone
     
  6. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,293
    I must be one of the few people using the mirror feature :) It's awesome, such a time saver!
    But yeah, I think if the user supplied the mirror plane it might not be too crazy to implement.
    Currently I am just baking out a mirror bone for each extra bone and blending to that as I blend the character to it's mirror pose.
     
  7. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,283
    I need this also. Mirroring is great.... until it doesn't work, then it's useless.
     
  8. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,293
    Yeah it’s such a shame!
    Maybe this is something for Playables API? I still really have no clue about that :)
     
  9. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    857
    I've looked up this topic extensively and found plenty of people requesting this -- I'm not sure why nobody asks for this, but I have a feeling that many people just roll their own animation system instead -- I think it's terrible it's not included. D:

    Regarding the mirror plane being specified on a per-bone basis -- I would even be satisfied if you could simply specify a global mirror plane (i.e. the root transform). This would be enough for 99% of anything I do.
     
  10. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,293
    Hey @awesomedata, I totally agree, to me it’s just weird that no one else needs it.

    In my setup, for every item I need to mirror, I add another bone that is set up in Houdini to be mirrored in transform.
    Then in the avatar mask I add those bones (you only have to do that once because you can save the mask). So you end up always having a mirrored version kicking around that you can use.
    Unfortunately you still have to manage it a bit which can get confusing, and for every bone you want to mirror, you need an extra just for that.

    It would be just great to have it built in though and not have to hack around. I feel like it could be achieved pretty easily at a basic level maybe they are over complicating it? It’s definitely been an easy task in any 3d program I’ve used through constraints or even basic scripting to a degree.
     
    theANMATOR2b likes this.
  11. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    857
    I totally agree with this -- all one has to do is provide a custom gameobject/transform/vector for the bones they want to have a "special" mirror plane for. All others could use the basic x/z mirror plane in the case one wasn't specified for a particular bone.


    With the implementation of the new Animation "Jobs" system, I feel like this is a great opportunity to finally "fix" the l'ittle' under-the-radar issues with bone-based stuff (such as mirroring). I just hope we get the low-level control we need to roll our own answer to Mecanim -- including things like blendshapes and other kinds of animation as well (for example, we might want to piggy-back off of some existing systems like the Humanoid avatar retargeting system).

    Unfortunately Mecanim was overcomplicated by the "Humanoid" concept becoming too centralized to the API design, and the AnimationController (and its respective EditorWindow) driving the logic of all things animation made what could be done with Mecanim so restrictive. Might be nice to piggyback off the Humanoid mapping, but also be able to extend that into a sort of "shortcut" retargeting system (i.e. selecting chains of bones to map to other bone chains via attaching shortcut labels to said bone chains). Seems like this Humanoid mapping system could easily be modified to be more general -- and also support easy mirroring through such a shortcut system.
     
  12. manutoo

    manutoo

    Joined:
    Jul 13, 2010
    Posts:
    323
    Same issue here. :(

    Is it possible to mirror the prop in the hand only by code ? (ie: doing some stuff on in LateUpdate() to change the quaternion of its gameobject)

    Note : my extra bone is animated.
     
    Last edited: Oct 20, 2019
  13. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    251
    I am wondering the exact same thing right now. I'll look into it, lets share what we find.
     
  14. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    251
    Ok... here is what we can do. Let's say our extra bones are called ExtraLeft and ExtraRight.

    In the import setting of the animations make sure your extra bones are enabled. Only enable the bones with animation data on them. In my case ExtraLeft has no animation data, so I left it disabled.

    Then, create a script on ExtraRight that has a reference to ExtraLeft. In LateUpdate() read the transform of both extra bones, rotate them and write the left to the right and right to the left. Voilà!

    In my case I want to switch which extra bone (between left and right) is animated at the same time I mirror the animation via an animation parameter, so I monitor that in the script. Also, I only have to read from ExtraRight, mirror the transform and apply it to ExtraLeft.

    I'm going to test that now.