- Home /
mecanim target maching problem, it won't work at all !
please first, take a look at this code :
public float WalkSpeed { get; set; }
public float StrafeSide { get; set; }
public GameObject Anchor { get; set; }
public static RPGAnimator Instance;
private Animator animator;
private void Start()
{
animator = GetComponent<Animator>();
animator.applyRootMotion = false;
Instance = this;
}
private void Update()
{
animator.SetFloat("Speed", WalkSpeed);
animator.SetFloat("Strafe", StrafeSide);
CheckCliffClimbState();
if (Input.GetKeyDown(PlayerInput.Instance.Jump) && !RPGPlayerMotor.Instance.IsCliffJumping)
Jump();
}
private void CheckCliffClimbState()
{
AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(0);
if (stateInfo.nameHash == Animator.StringToHash("Base Layer.Cliff Climb"))
{
Debug.DrawLine(animator.bodyPosition,Anchor.transform.position,Color.blue);
animator.MatchTarget(Anchor.transform.position,
Anchor.transform.rotation,
AvatarTarget.RightHand,
new MatchTargetWeightMask(Vector3.one, 1f),
0.4f,
0.72f);
}
}
public void Jump()
{
animator.SetTrigger("Jump");
}
i used a script from wiki called fps walker enhanced or something like that, now here is the problem, as you can see i call the cliff jump method within another script, and here, i set the trigger to play the animation and in update i call the method to do the target match 1- the character controller remains at the bottom of cliff and won't move to the position of the mesh, and at the end of cliff jump animation the character slides back to the position of the controller 2- the target match on the right hand won't work at all, i used debug message and it's called in correct time but the target match is not working 3- i get warning when the character is sliding back that the target match can not work in the transition time, and i don't know the code to check the transition, the animation state is called "Cliff Climb" in the base layer.
can anyone help me with any of these problems please?
thanks