Animator.MatchTarget broken with low fps

Hi everyone,
i have a matchtarget controlled animation for climbing ledges.
I just realized that it’s not framerate indipendent, and when i have low FPS it does not work anymore.

Any suggestion?
Thank you in advance.

These are the gifs of the behaviour, is easier to show than to explain:

WITH GOOD FPS

WITH BAD FPS

I’m using a rigidbody character and this is the code i am using in FixedUpdate:

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), anim.GetFloat("MatchStart"),anim.GetFloat("MatchEnd"));
                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;
            }
        }

Seems like flagging “Animate Physics” in the animator solved the problem.
I’ll do more testing and in case i’ll update here.

2 Likes