0
\$\begingroup\$

I'm having very weird problems with my player's vertical movement. I'm using a Character Controller component with a capsule collider and no rigidbody. For testing purposes, I've ended reducing my jump script to just this line:

    owner.CharacterController.Move(new Vector3(0, 0.01f, 0));

When executing this script, the player should just fly upwards at a constant speed, right? Well, what ends up happening is that the player starts jumping in place repeatedly. The jumps are smooth, as if the movement was being affected by gravity. I thought that the standard Character Controller doesn't handle gravity automatically and you have to do it yourself, so I can't understand what's going on here. There is no other code affecting the player, if I comment that line it just rests in place. If I try a different direction (like (0.01f, 0, 0)) the player moves in a straight line in the provided direction as expected. But when moving vertically, weird stuff happens :S

\$\endgroup\$
2
  • \$\begingroup\$ My guess would be that you have another script which is moving the player at the same time. Note that SimpleMove() applies gravity, so if you're calling CharacterController.SimpleMove() from some other script, the gravity is getting applied there even if you're passing in a zero vector. You said if you comment that code out, the player doesn't move. What if you place the character in the air instead of starting them on the ground? \$\endgroup\$
    – Kevin
    Apr 20 '21 at 22:24
  • \$\begingroup\$ Thanks a lot! I tried disabling all scripts and finally discovered that it was my animator causing the issue: Unchecking the "Apply root motion" option made everything work again as normal. \$\endgroup\$
    – correojon
    Apr 21 '21 at 18:49
2
\$\begingroup\$

The problem was that the animator controller had checked the "Apply root motion" option. After unchecking it everything went back to normal. It seems my idle animation was not correctly defined.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .