Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Mecanim Target Matching for Generic Rig Issue

Discussion in 'Editor & General Support' started by Liveon, Jun 5, 2013.

  1. Liveon

    Liveon

    Joined:
    Jul 9, 2012
    Posts:
    13
    I am unable to use target matching for my quadruped which uses a generic rig rather than a humanoid. This question is similar to the post http://answers.unity3d.com/questions/386593/mecanim-matchtarget-generic-rig.html which haven't been answered at all so I will try on this forum instead.

    For testing purposes, I have swapped out my quadruped and replaced it with a simple cube animation fbx going from world 0,0,0 to say 0,0,1 and have 2 bones for root motion purposes. I have followed (more or less) the target matching example scene provided by Unity. I have also created an empty object called "target" so that instead of just moving to 0,0,1, it would move and rotate to the target's position + orientation. I have attached the script and the target matching line to the cube:

    Code (csharp):
    1. // Update is called once per frame
    2.     void Update () {
    3.         if(animator) {
    4.             animator.MatchTarget(target.position, target.rotation, AvatarTarget.Root, new MatchTargetWeightMask(new Vector3(1,1,1), 1), 0f, 1f);   
    5.         }
    6.     }
    Nothing works apart from the animation going towards the Z axis and not the target. Any idea what could be wrong with it? Does target matching works with a generic rig?
     
  2. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Target Matching only work with Humanoid rig for now.
     
  3. LessThanEpic

    LessThanEpic

    Joined:
    Aug 22, 2014
    Posts:
    13
    Did this ever change, or does it still only work for Humanoid rigs?
     
  4. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Still only work on Humanoid. We are working on the generic version but it not yet ready.
     
  5. arturmandas

    arturmandas

    Joined:
    Sep 29, 2012
    Posts:
    240
    Is it ready yet? I have some spiders waiting for retargetting... ;)
     
  6. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    not yet sorry
     
  7. arturmandas

    arturmandas

    Joined:
    Sep 29, 2012
    Posts:
    240
    Thanks for info anyway!
     
  8. UsmanAbbasi

    UsmanAbbasi

    Joined:
    Dec 29, 2015
    Posts:
    2
    @Mecanim.Dev Is it available now or still we can't use target matching for non-humanoid?
     
  9. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    match targeting for generic rig should be available in 5.4 which is in beta right now.
    Enjoy!
     
  10. TitaniumBrendan

    TitaniumBrendan

    Joined:
    Jul 1, 2019
    Posts:
    2
    Sorry for the forum necro but - i'm assuming that
    Animator.MatchTarget
    only allows for RootMotion matching (
    AvatarTarget.Root
    ) ?

    Should it be generating an error if another joint is matched (it looks like it silently only does the matchtarget on rootmotion?)
     
  11. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
  12. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    @TitaniumBrendan Sorry my bad I didn't read the whole thread, but since this question is about generic rig then yes in this case it expected that it will only work for the root
     
  13. jacasch

    jacasch

    Joined:
    Jan 20, 2017
    Posts:
    16
    @Mecanim-Dev So is there any other way to do target matching on generic rigs with other bones than root?
    as far as I could find out, its not even possible to look at an animaiton clip and extract the bone rotations at a certain time, and then calculate the transform matrices myself.