Search Unity

Rigidbody stuck in midair but colliders are not even touching

Discussion in '2D' started by Manny Calavera, Jul 21, 2014.

  1. Manny Calavera

    Manny Calavera

    Joined:
    Oct 19, 2011
    Posts:
    205
    Hi,

    Once in a while my character stops in midair while approaching a platform. The colliders of the character and the platform are not even touching. There are no other colliders or scripts around these game objects.

    This used to happen very frequently when the platforms were BoxCollider2Ds. In order to work around this problem I ended up replacing those colliders with PolygonCollider2Ds. That helped reducing these occurrences but sometimes the character still gets stuck as you can see in the attached screenshot. I have also tried increasing the default physics position and velocity steps by 10 fold. That didn't help either.

    RigidbodyStuck.PNG

    Is anyone experiencing this kind of behavior? Any clues on how to prevent or detect these anomalies?
     
  2. Manny Calavera

    Manny Calavera

    Joined:
    Oct 19, 2011
    Posts:
    205
    Some more observations and screenshots...

    I noticed that if the rigidbody is in this hanging state and I go back to the rigidbody properties and unckeck 'Fixed Angle' then the rigidbody tips over and gets out of that hanging state. Perhaps the 'fixed angle' logic is compensating the force from the platform and yielding a resultant == 0?

    In any case, in order to make sure this is not a bug in my code I went back to Unity's 2D Platform sample from the asset store, moved the platform to the right, jumped enough times against the corner and voilà..

    It hangs in there by physx magic:
    RigidbodyStuck-Sample.PNG

    After that I decreased the circle collider radius from 0.3 to 0.1 (that's what I have in my game, 0.1) and repeated the tests... Soon enough it hangs in midair again:

    RigidbodyStuck-Sample02.PNG

    Notice how it's not even touching anything around it... It's just floating there.. And if no force is applied it will remain there forever.
     
    Soumikbhat likes this.