- Home /
Can Animator.MatchTarget and AvatarTarget be used for generic rigs?
Hi,
I want to "MatchTarget" an animation to a target point using Animator.MatchTarget and AvatarTarget, like this (according to the mecanim animation tutorial):
var anim:Animator = GetComponent(Animator);
[...]
anim.MatchTarget(hitInfo.point, Quaternion.identity, AvatarTarget.Root, new MatchTargetWeightMask(new Vector3(0,1,0), 0), 0.6, 0.76);
I am doing this for a model that was imported as "generic rig", i.e. the Avatar is only a generic one, with no specific bone assignments inside Unity.
MatchTarget doesn't seem to be doing anything: My animation just runs to its end, no matter where the object is located in relation to the target point.
Is this a natural limitation for generic rigs? Or am I doing someting wrong?
I've already checked the following:
hintInfo.point seems to be valid and the expected position (according to the debugger)
start and end points (0.6 and 0.76) are also valid (I tried to change them to arbitrary other values between 0 and 1, which makes no difference at all)
Any helpful ideas highly appreciated!
Update: $$anonymous$$eanwhile I've tried defining my rig as "humanoid" (which is possible, basically, except for some $$anonymous$$or movement flaws). But the result is still the same: $$anonymous$$atchTarget doesn't seem to be doing anything!
However, I am asking myself now whether I've correctly understood the role of $$anonymous$$atchTarget: I want a jumping animation to lengthen/stretch/slow down towards its end during longer falls, so that its final "landing" part is exactly timed with the moment of "touch down". But is this really what $$anonymous$$atchTarget is meant for? Or should it simply sync object rotation?
When you use $$anonymous$$atchTarget the animation speed doesn't change, but the position and rotation of the AvatarTarget should adjust to meet your target. It essentially adjusts the physics for you. Have you got the "animate physics" option turned on for your animator component?
Thanks, EHogger, for the clarification. So I've misunderstood the role of $$anonymous$$atchTarget. In other words: The answer to my original question is: Yes, one can use $$anonymous$$atchTarget both for generic rigs. But I've expected it to do things which it is not meant for. In my case, it seems to be doing exactly what it should, only I didn't realize.
BTW: Yes, I checked both with and without Animate Physics enabled, but to no difference.
Answer by coffiarts · Mar 02, 2013 at 08:49 AM
An answer to my own question, as described in the comments above (thanks to EHogger for helping me):
Yes, MatchTarget seems to work for generic rigs.
I only misunderstood its function: It is meant for adjusting an AvtarTarget's position and rotation, not for slowimg down an animation.