CharacterController.isGrounded is way too inconsistent?

I had no idea I was having an issue with the standard isGrounded check from the standard Unity Character Controller until I broke down my project and code.

9262860--1296177--upload_2023-8-31_17-40-8.png

My project/code is showing isGrounded = true in this photo when my player is clearly very high up off the ground. It is making certain movements inconsistent and almost broken because my player gets stuck where they should not like on the edge of this cube object. Ground should only be detected if the very bottom of the capsule is touching it.

Is this just the limitation of the standard controller.isGrounded check or do I need to manually add code to adjust this to my preference? I have tested this using three different very simple scripts so I don’t believe it’s a code issue. All I use is isGrounded = controller.isGrounded;

CharacterController.isGrounded just checks if the bottom part of the capsule was intersecting with any collider the last time .Move() was called on it.

It’s very literal in that sense.

So in that image I can see just a bit of the capsules bottom cap is against the cube, so isGrounded makes sense to be true.

You can always combine it with other methods to get more accurate or specific results. It is of course, very simple and generalised.

I’m guessing that you are using broken example code that calls controller.Move() in two separate places each frames.

I wrote about this before: the Unity example code in the API no longer jumps reliably.

If you call .Move() twice in one single frame, the grounded check may fail.

I reported it to Unity via their docs feedback in October 2020. Apparently it is still broken:

Here is a work-around:

I recommend you also go to that same documentation page and ALSO report that the code is broken.

When you report it, you are welcome to link the above workaround. One day the docs might get fixed.

If you would prefer something more full-featured here is a super-basic starter prototype FPS based on Character Controller (BasicFPCC):

That one has run, walk, jump, slide, crouch… it’s crazy-nutty!!