Search Unity

Getting crazy with MatchTarget

Discussion in 'Animation' started by Nicolas-Liatti, May 11, 2016.

  1. Nicolas-Liatti

    Nicolas-Liatti

    Joined:
    Jun 19, 2013
    Posts:
    89
    Hi all,

    I've been trying to use MatchTarget for days now, but I really don't get it working...

    My code is pretty simple:
    Code (CSharp):
    1.  
    2.  
    3. animator.SetTrigger ("climb_top");
    4.    
    5. if(!animator.IsInTransition(0))
    6.             animator.MatchTarget (grabHandLeft, Quaternion.identity, AvatarTarget.LeftFoot, new MatchTargetWeightMask (Vector3.one, 1f), 0.1f, 0.2f);
    7.  
    grabHandLeft is the position at the top of the wall, with a white ball on the screenshot.
    Now, when I run it in the editor, it puts the green widget the match target ALWAYS at the same place, which corresponds to the left foot at the end of the animation (why ??), no matter the parameters that I can put. I really don't get how it works...
     

    Attached Files:

  2. Nicolas-Liatti

    Nicolas-Liatti

    Joined:
    Jun 19, 2013
    Posts:
    89
    I think I found something:
    - if I put this code in an Enumerator, that does not work.... why??
    - If I put it in Update(), it seems to work

    Is there any reason that MatchTarget works only if called in Update?