Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved CharacterController getting hung up on anything overhead

Discussion in 'Physics' started by halfpasttense, Apr 16, 2021.

  1. halfpasttense

    halfpasttense

    Joined:
    May 30, 2020
    Posts:
    21
    I'm having an annoying issue with CharacterController where it seems to temporarily get hung up whenever the player tries to pass under almost anything that is within about 1 foot above the head. I've checked the clearance, even taking into account the skin width, and there is multiple inches of clearance. When trying to pass under something like this the CharacterController will return collisions for above and sides for a number of frames, until it finally lets it under. Sometimes it gets stuck for a long time, other times less than half a second. It will then continue to return collisions for above the whole time the character is under the thing, even though the top of the CharacterController collider is still multiple inches away from the collider above it.

    Anyone have any idea what could be going on with this, how to fix it, or how to work around it? I'd really like to avoid having to just greatly reduce the CharacterController height to way below the actual character height.

    The pictures below demonstrate the problem. In this position the character is actively trying to walk under, but the CharacterController is preventing the forward movement, even though it is nowhere near to colliding with the floor above. The skin width on it is currently 0.021. The CharacterController is just the large capsule collider around the entire character. All the other colliders you see are on different layers and are not set to collide with the scene geometry. The collider on the floor above is a mesh collider that exactly matches the rendered mesh.

    upload_2021-4-16_1-26-26.png upload_2021-4-16_1-25-3.png
     
  2. halfpasttense

    halfpasttense

    Joined:
    May 30, 2020
    Posts:
    21
    I thought maybe it might be caused by the floor above being a mesh collider, so I changed it to a BoxCollider but this did not change anything. It still gets hung up just the same. Oh and this is with Unity v2019.4.24f1.
     
  3. Vharz

    Vharz

    Joined:
    Jul 28, 2012
    Posts:
    25
    Noticed the same. Speaking from memory here, but I think I remember it having to do with step offset value. Not able to check it out to be sure ATM.
     
    TebogoWesi likes this.
  4. halfpasttense

    halfpasttense

    Joined:
    May 30, 2020
    Posts:
    21
    You're absolutely right. If I set the Step Offset to 0 this behavior completely goes away. Of course now my character is unable to go up any stairs so this isn't exactly a good solution. Did you find any good workarounds for this?

    I can kind of rationalize why this behavior even exists. It's probably to guard against the character simultaneously stepping up on something and then hitting something above, but there's got to be a better way to implement this without having such a massive and annoying unintended behavior.
     
  5. halfpasttense

    halfpasttense

    Joined:
    May 30, 2020
    Posts:
    21
    Vharz likes this.