Wonder why there is the “Solution” answer while we have no solution here - how to make the character goes back to the ground? At least visually. In the NVidia PhysX docs it tells
“When rendering the character’s volume for debug purpose, remember to expand the volume by the size of this skin to get accurate debug visualization.”
But why for debug purposes only? Isn’t it, that you need your character looks like standing on the ground instead of levitating almost ALWAYS, not just in debug process?
So, as for me, by creating or initializing your character, you need to calculate the factor for the visual model’s scale to adjust the model according to skin width to compensate this “levitation effect”. For this you need to separate your visual model from the object, to which the CharacterController component is attached. For example, the following simple structure
Now you can scale the visual (mesh) without scaling the character controller.
Calculating the skin scaling factor for the visual is something like this
var skinFactor = (characterController.skinWidth * 2) / characterController.height + 1;
Double skin width - because we count the effect of skin not only from above, but from the whole length along each axis. Skin is added along each axis from both sides of the character - so, we count it two times.
“+1” - because we need not the absolute factor, but relative to the original size, which is logically 100% or just 1.
(Actually it depends on the parent’s transform.scale, but we count it as 1 here, relative to the child’s transform. And when calculating the final scale for the child, Unity multiplies all actual scales throughout the game object’s tree structure.)
Now we need to multiply the visual model’s scale to this factor
var visualModelTransform = parentTransform.Find("VisualModel");
visualModelTransform.localScale *= skinFactor;