- Home /
Floating Mecanim Player with Character Controller
I am using a character controller attached to my mecanim animations to control my player in the game world. I have experienced two cases, both related to the same problem.
Firstly, if the character controller and animator are attached to the same object: The character moves up and down as he walks. This moves the character controller off the ground and it detects itself as not being grounded which breaks our jumping logic (only jump while on ground). This occurs at a rapid pace and is more or less completely random.
The second case is when the animated player is a child to the character controller. In this case, I move the character controller by the animated players local XZ coordinates every frame and then reset those to 0. This fixes the issue of not being grounded. However, it introduces two more issues. Firstly, if I reset the Y axis to 0 it causes the player to stutter up and down slightly (just noticeable). If I do not reset the Y axis due to some noise from the axis the player moves slightly up or down. After a minute or two this becomes significant (half a unit or more).
Is there some way to account for this without having to do all of this? If not, is there a better way that I am not using?
"The character moves up and down as he walks" - do you mean during animation his origin or actual transform.y was modified?
The players movement in game is linked to the movement in the animation. So as he moves in the animation he does as well in the world. The transform changing is what is causing the issues as the character controller is using that for it's Capsule Collider.