Search Unity

CharacterController.isGrounded: what collision checks are done?

Discussion in 'Scripting' started by vincentellis, May 30, 2017.

  1. vincentellis

    vincentellis

    Joined:
    Oct 21, 2013
    Posts:
    100
    What kind of collision logic is done in order to enable the isGrounded flag on the Unity CharacterController? Does it check for the ground? Does it check the normal of the surface below? How does it work?
     
  2. vincentellis

    vincentellis

    Joined:
    Oct 21, 2013
    Posts:
    100
  3. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It's based on the nVidia Character Controller, and uses raycasts for everything. It does not care what normals the surface has*, and will only report 'collisions' in the direction of Move as this will then cast rays.

    *If slope limit, then it will simply not move there, and is the case where the normals are actually checked against.

    There is also a confusing rigidbody based one that's lurking in standard assets, but I'm assuming you mean the built in raycast one.
     
  4. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,537
    As the documentation says:
    https://docs.unity3d.com/ScriptReference/CharacterController-isGrounded.html

    Basically if the last call to move adjusted the CharacterController in such a manner that it struck a surface on the lower sphere of the capsule, it's considered grounded.

    Not I also linked to the PhysX documentation in your other thread about CharacterController. If you have more questions, try keeping the threads consolidated.
     
    hippocoder likes this.
  5. Atto2O

    Atto2O

    Joined:
    Aug 19, 2018
    Posts:
    6
    Hi, with this "lower sphere of the capsule" do you mean collider cpasule?

    While jumping, my isGrounded pop on roof collision, and some times(really rare) on walls. Do you have any clue what can it be? or it's a normal performance?