- Home /
Mecanim Target Matching isn't working!!
I've been working on a climb script. Ive been looking at the Mecanim Example for it and tried to remake it, But for some reason it isn't working!!! When I go in the trigger, it plays the animation but doesnt move to the target. It won't even work when I add Input.GetKey(Keycode.R) so I had to just make it do it automatically OnTriggerEnter. I'm not sure if i'm missing something or not but here's my script:
using UnityEngine; using System.Collections;
public class Climb : MonoBehaviour {
public Animator animator;
//the platform object in the scene
public Transform RightHand;
void Start () {
}
void Update () {
}
void OnTriggerEnter(Collider other) {
if(other.tag ==("Player")){
animator = other.GetComponent<Animator>();
if (animator)
{
AnimatorStateInfo state = animator.GetCurrentAnimatorStateInfo(0);
//if(Input.GetKey(KeyCode.R)){
animator.SetTrigger("Climb");
if (state.IsName("Base Layer.Climb")){
MatchTarget();
}
//}
}
}
}
void MatchTarget(){
animator.MatchTarget(RightHand.position, RightHand.rotation, AvatarTarget.RightHand, new MatchTargetWeightMask(new Vector3(1, 1, 1), 0f), animator.GetFloat("MatchStart"), animator.GetFloat("MatchEnd"));
}
}
Has anyone met this problem or know of an easier way to achieve climbing??
Your answer
Follow this Question
Related Questions
Animator.MatchTarget 0 Answers
Get in car - Target Match 1 Answer
Coding equivalent of Draging an Object into the Inspector (Solved) 1 Answer
Set clone as target 0 Answers
How to move camera target smoothly? 1 Answer