Unfortunately this script is based upon defective sample code still hosted today on Unity’s website.
The “tell” for me is line 67 and line 71 above where controller.Move()
is called… twice.
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!!
Not only that, but germane to your original question… pretty sure you can set the camera height however you like in these ones… Give it a try…