Hello!
I am trying to create the climb up part for my ledge climbing system using the MatchTarget function on the animator. Here is the code within my ledgeClimbing.cs script inside the Update() function:
if(stateManager.IsClimbingUp)
{
GetComponent<Animator>().MatchTarget(aimPoint, transform.rotation, AvatarTarget.RightHand, new MatchTargetWeightMask(Vector3.one, 1.0f), 0.0f, 0.2f);
Debug.Log("Matching target");
}
aimPoint is the point on the ledge above that the player should reach.
And this is the code inside the animation manager in the LateUpdate() function. I used LateUpdate so I could be sure that the climbUp trigger had been set (tells animator to perform climb up anim) before I set the MatchTarget in the next frame:
if(Input.GetKeyDown(KeyCode.Space) && stateManager.CanClimbUp)
{
anim.SetTrigger("ClimbUp");
charControl.enabled = false;
stateManager.IsClimbingUp = true;
stateManager.IsClimbing = false;
StartCoroutine(WaitForAnim(2.933f));
}
The debug log indicates that the first if statement has been executed, so that is not the issue. I know this code will also execute it every frame, but I tried it just as soon as the space key is pressed but it didn’t do anything.
The animation plays as if I hadn’t called the MatchTarget function at all. Am I calling it in the wrong place?
The climb up animation has no root motion and is completely on the spot if that makes a difference.