CharacterController.skinWidth and vertical displacement

I'm mostly unfamiliar with CharacterController, so I was wondering if anyone here could enlighten me.

Characters using CharacterController are floating above the ground at the height of SkinWidth. From the Unity documentation, I wouldn't have expected that - it reads:

"Two colliders can penetrate each other as deep as their Skin Width."

So I'd interpret it as quite the opposite - the leeway that it has before repelling.

Other pages referring to the parameter on PhysX confirm that

"The skin allows the objects to penetrate each other, at the width of the skin. "

So I'm wondering why I would get it to actually repel from the ground (or box/plane collider below it) at that height. The behavior is the same on 2.6 and the 3 betas, so I imagine this is expected, but can anyone elaborate?

EDIT: Yes, the skin width will add a buffer around the character's collider.

If your character is standing still on a platform, the buffer won't be penetrating the platform's collider. This will cause the character to "float" if you haven't adjusted the collider height to account for skin width.

The skin width only comes into play when motion results in collider penetration. It doesn't mean the colliders will always penetrate to that depth.

Is there an example of WHY you need skin width please to get a better understanding of why you’d need it at all? Thanks.

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;