Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question What is the point of CharacterController.SkinWidth

Discussion in 'Physics' started by QtTx, Sep 11, 2021.

  1. QtTx

    QtTx

    Joined:
    Aug 20, 2021
    Posts:
    16
    Hi. I have read the documentation on CharacterController, and it briefly mentions that skin width helps reduce jitter and the chances of character getting stuck. Can someone elaborate? I am looking for a more in depth explanation. Like, in what specific scenarios would a character jitter/get stuck if a single capsule was used, and how having an additional smaller capsule (which I assume is what SkinWidth translates into) solves those problems. Thanks.
     
  2. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    460
    As long as I know skin width let the character controller "penetrate" into colliders. The character could jitter if for example, having a diameter of 1 (radious of 0.5) will try to go through a space of 1 meter. With the skin width the character will kinda "penetrate" a bit into the colliders so it wont do strange things.

    All if this is what I think it does, I'm not sure if my info is 100% correct. Correct me if I'm wrong.
     
  3. BakeMyCake

    BakeMyCake

    Joined:
    May 8, 2017
    Posts:
    175
    Mention in the manual: https://docs.unity3d.com/Manual/class-CharacterController.html
    Mention in the script reference: https://docs.unity3d.com/ScriptReference/CharacterController-skinWidth.html

    Regarding this bit:
    Coordinates in Unity are floats, and floats have varying precision depending on the value being stored:
    https://blog.demofox.org/2017/11/21/floating-point-precision/
    It isn't as bad on its' own, but when you have multiple floats and you add them up the imprecision gets more pronounced.

    Imagine you have a capsule in slight contact with the ground and moving parallel to it. Sometimes it can report as being slightly inside the ground and sometimes slightly above it. I guess the way Unity deals with it is by allowing distance related calculations to operate using a "close enough" range.

    But that's only one reason, there may be more.