Search Unity

MatchTarget Rotating Character

Discussion in 'Animation' started by artplayer, Nov 2, 2018.

  1. artplayer

    artplayer

    Joined:
    Apr 16, 2016
    Posts:
    18
    Hello everyone, I need help with MatchTarget.
    Regardless of the animation I use the end of the way, my character ends with an unwanted X-axis rotation.
    I'm trying to make an escalation where the right hand ends up on the target. I'd like help finding what I'm doing wrong.

    This is my code:
    Code (CSharp):
    1. private void Update()
    2.     {
    3.         if(anim.GetCurrentAnimatorStateInfo(0).IsTag("Climb") && !anim.IsInTransition(0))
    4.         {
    5.             anim.MatchTarget(target.position, target.rotation, AvatarTarget.RightHand, new MatchTargetWeightMask(Vector3.one, 1f), StartMatch, EndMatch);
    6.  
    7.         }
    8.     }






    Unity 2018.2.14.f1
     
  2. qwiboo

    qwiboo

    Joined:
    Nov 20, 2013
    Posts:
    10
    Hey,
    it's because when you create MatchTargetWeightMask, you set the second parameter to 1f, which means the target matching will try to match the rotation of the right hand to match the rotation of the target as well. You most likely only want to match the position so your definition should be
    new MatchTargetWeightMask(Vector3.one, 0f)