While playing with the locomotion system, I think I found a bug. It doesn’t occurs in all cases and is related to MonoBehaviour.Update execution order of 2 scripts:
- NormalCharacterMotor.cs → NormalCharacterMotor.Update() calls UpdateFacingDirection() and UpdateVelocity()
- PlatformCharacterController.cs → PlatformCharacterController.Update set motor.desiredMovementDirection
Note: I use the Locomotion System from the 3rd Person Shooter demo, but in your case, motor.desiredMovementDirection could be set by another Update function like in WanderingAICharacterController.cs …etc.
My understanding is that desiredMovementDirection must be set before UpdateFacingDirection() is called. With the official script, the order of execution is undetermined (2 Update functions called by the Unity engine). For a character controlled by the player, the direction can be adjusted constantly, so a bad order of execution result in a constant jitter of the character.
I have solved the problem by the use of the ExecutionOrderBehaviour class. In my program the NormalCharacterMotor and PlatformCharacterController classes inherit the ExecutionOrderBehaviour class. The 2 Update() functions were replaced by UpdateCustom(). The priority 0 was set to PlatformCharacterController, and 1 to NormalCharacterMotor.
When inversing the priority the bug is clearly visible. A cube can be added in top of the character to show the bug, it is more visible on sharp edge than on rounded meshes.