- Home /
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)
To clarify, in the above screen, the Root Y is set to Feet. First the grip location is too low, then the character moves up from that position, and gets onto the platform. When Root Y is set to Original, it's somewhat similar. When set to Center of $$anonymous$$ass, the character gets even funkier, moving up several extra meters throughout the anim, including again at the very end.
Root motion is applied in the custom controller in OnAnimator$$anonymous$$ove with Vector3 newPosition = anim.deltaPosition;
And then the $$anonymous$$ove() function in update, moves the character to this new position.
Answer by jwinn · Jan 21, 2013 at 12:32 AM
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.