Two things immediately pop out:
-
don’t use FixedUpdate() unless you’re doing Physics. CharacterController is not physics. Use Update().
-
don’t call the .Move() method twice because that causes issues with ground detection.
Beyond that, I suggest reorganizing things to make a nice top-down update loop rather than leaping in and out of stuff. Basically, do this:
- read inputs
- process inputs to decide motion(s)
- move CharacterController accordingly
- set animation as per any decisions made above.
You’re welcome to see how I refactored the broken sample Unity3D code here:
If you’re just looking for a functioning controller, here’s a good start:
It’s first person but could easily be adapted to be third person, and in any case the same concepts apply.
2 Likes