CharacterController isGrounded toggles value

My character controller isGrounded toggles its value even if the movement vector magnitude is zero. And when I walk it keeps toggling its value. So, if I want to jump, sometimes it doesn't respond because it says it's not grounded. But when you're playing it looks completely grounded. What do you think is happening?

1 Reply

Actually @gnp89 and @armirblum , there is a very good reason for this,

When the charactercontroller touches a service, it shows it's grounded. When your script notices this, it sets the vertical velocity to 0, which means, there is no change in velocity. But this also means, the player get's pushed up a really tiny bit because of the ground and the collision and stuff. So when it moves up this tiny tiny bit, it get's off the ground, which makes the controller think it's not grounded anymore. When your script picks up this change, it will force it down because you implemented fake gravity. And then it happens again and again.

To fix this issue, you simply set the downwards velocity to -0.1f, or another small value, instead of 0. This means, the player will be forced down always, just by a really tiny amount. this way, the charactercontroller will always think it's grounded, and you will always jump when needed.