I’m trying to fangle my way through target matching with Mecanim. When I perform “attack” I wanted the Player hand to migrate towards the specified point “enemyHead”. Everything is working at the required points except that instead of the hand moving it pulls the entire model, sliding across the floor until the hand is located close to the specified point.
Is this all I’m going to get out of it? I don’t see a way to mask the rig for specific bones. Am I being too hopeful or am I missing something?
The ideal situation I was hoping to see is that the attack swing would happen as normal except the hand would go through the desired point. Of course, it seems this is far from the case.
I’ve set up a scene with a functioning Mecanim rigged character and another object which is simply an enemy model. In the following script for simplicity I drag the enemy “Head” bone object to the inspector field.
private var matchAnimator : Animator;
public var enemyHead : Transform;
function Start ()
{
matchAnimator = GetComponent(Animator);
}
function Update ()
{
if(matchAnimator)
{
if(matchAnimator.GetCurrentAnimatorStateInfo(1).IsName("attack"))
{
Debug.Log("Attacking!!");
matchAnimator.MatchTarget(enemyHead.position, enemyHead.rotation, AvatarTarget.RightHand,new MatchTargetWeightMask(Vector3(1.0,1.0,1.0), 0), 0.44, 0.55);
}
}
}