Hi everyone,
i realized that Animator.MatchTarget behaves correctly when FPS are decent, but when i have low fps it wont work anymore, landing the character in different positions while the animation is playing (eg. i am using a third person view with the character with rigidbody, and the animations some time make the character fall through the floor, or makes it “enter” the mesh it should climb, when fps are low).
I know is a matter of time when it’s faking the right hand and foot positions, but even if i move the controller in FixedUpdate, it behaves bad in low fps contitions.
This is the code i am using:
if (anim)
{
AnimatorStateInfo state = anim.GetCurrentAnimatorStateInfo(0);
if (Input.GetButtonDown("ps4_X") && climbHandPos != null && !hasJumped ) {
anim.SetBool("Climb",true);
}
if (Input.GetButtonDown("ps4_analog_button") ) {
GetComponent<IKControl>().lampActive = !GetComponent<IKControl>().lampActive;
}
if ( state.IsName("Base Layer.Climb") && !anim.IsInTransition(0) && climbHandPos != null )
{
anim.SetBool("Climb",false);
transform.rotation = climbHandPos.transform.rotation;
GetComponent<IKControl>().ikLookActive = false;
GetComponent<IKControl>().lookObj = null;
GetComponent<IKControl>().ikRHandActive = false;
GetComponent<IKControl>().ikLookActive = false;
GetComponent<IKControl>().rightHandObj = null;
GetComponent<IKControl>().leftHandObj = null;
GetComponent<Collider>().enabled = false;
anim.MatchTarget(climbHandPos.position, climbHandPos.rotation, AvatarTarget.RightHand, new MatchTargetWeightMask(new Vector3(1, 1, 1), 0), 0.2f, 0.3f);
anim.MatchTarget(climbHandPos.position, climbHandPos.rotation, AvatarTarget.RightFoot, new MatchTargetWeightMask(new Vector3(1, 1, 1), 0), 0.4f, 0.7f);
hasJumped = true;
} else {
GetComponent<Collider>().enabled = true;
climbHandPos = null;
}
if (hasJumped && state.normalizedTime > 0.6f)
{
GetComponent<Collider>().enabled = true;
hasJumped = false;
}
}
EDIT:
Thank you for help.