How does the default character physics work?

There have been a few times where I wanted to create a custom character, and every time I tried implementing it I always came out confused and unsure of how I should make it.

So I tried researching how the default character worked but wasn’t able to find any satisfying answer, I know it uses some sort of physics because it is unanchored, but i have no idea how it’s kept upright…

Any help?

I believe it works as follows:

  1. There is some kind of torque (AlignOrientation?) that keeps the character upright. If the character tilts too far the switch to a falling state where that torque is disabled for a few seconds then re-enabled with some “i-frames” to allow the character to get back up without just falling again. It also points the character in the most recent lateral movement direction/
  2. There is a lateral force that quickly accelerates the character to walk speed when you press a movement key. When not pressing a key, there is no force. This force cannot be applied vertically, so the character can fall.
  3. When you jump, a brief impulse is applied upwards. It cannot be activated again until you are close to the ground. There are probably some i-frames after each jump to prevent very rapid “BLJ” style jumping.