Problem with CharacterController, Climb Animation, and Root Transform Position Y

I’m working with a CharacterController and Mecanim, where root motion is driven by the script (no rigidbodies). The problem is that the climb animation is causing the character to move upwards in parts of the animation where it shouldn’t. Particularly when pulling up onto the ledge.

I’m using the JumpUpHigh animation provided by Unity, and was attempting to copy the technique presented at 37:00 during this keynote. It’s the bit about climbing onto the shipping container. This is also found in the script “TargetMatching” that comes with Mecanim demo files. The MatchTarget is actually working correctly, besides the bad extra Y movement at the top of the animation.

  • Tried every darn setting on the clip. Root Y based upon Original, Body Mass, and Feet.
  • Of note: When I test the bake Y into the pose option, it animates correctly (does not move upwards after hands grip and pull up)

I figured out a solution.

1- During the animation, I was disabling gravity. By re-enabling gravity as soon as the feet touch the ledge, there is no longer a noticeable extra upwards movement. I check the following to disable gravity on the climb up:

    if ( currentBaseState.nameHash == climbUpState 
         && currentBaseState.normalizedTime < 0.680 )

2- Making “MatchEnd” a lower number helped to align the hands at the initial part of the jump.