Search Unity

[Fixed, sort of] Ragdoll Stability

Discussion in 'Physics' started by Ewanuk, Dec 16, 2014.

  1. Ewanuk

    Ewanuk

    Joined:
    Jul 9, 2011
    Posts:
    257
    upload_2014-12-16_13-8-25.png

    I've got two sets of ragdolls. One I just leave as is to test it (top-right of attached), it falls to the ground and behaves as expected when it collides w/ the floor.

    The other I activate when any limb collides with a solid surface (ignoring it's own limbs). The limbs are previously driven by animation and a parent above (controlling the root) is driven by a rigidbody (Think of someone snowboarding flying through the air and grabbing their board). When the limb collides with a surface, I:
    • Stop playback of the animation and disable the animation component
    • Ensure all the limbs are no longer kinematic
    • Unparent the ragdoll from it's parent rigidbody so the ragdoll would stop being driven by it
    The ragdoll then behaves erratically, joints oscillating across the above screen every frame. I have the solver iteration count set to max. None of the limbs collide with each other. I'm at a loss.

    Even more frustrating, when I pause the editor to go frame by frame to get a better look at what's breaking, it behaves as expected, the character joints bring the ragdoll back to a stable state.

    Any help?
     

    Attached Files:

  2. Ewanuk

    Ewanuk

    Joined:
    Jul 9, 2011
    Posts:
    257
    So far it looks like increasing the joint limits is helping. If I put all the limits to max it doesn't "explode", bit the ragdoll looks very broken. I'll have to live with it for now.
     
  3. Deleted User

    Deleted User

    Guest

    I am experiencing the same issues in Unity 5 beta - 14b. I am also struggling to find a solution as to why my character is "exploding". To clarify, what did you mean by increasing the joint limits to the max? Are you talking about "Low Twist Limit, High Twist Limit, Swing 1Limit, and Swing 2Limit". What were the "max" values you tried for those?

    Thanks!
     
  4. Ewanuk

    Ewanuk

    Joined:
    Jul 9, 2011
    Posts:
    257
    That's correct steampenny, I set those values to the max and it's doing the trick, but the doll doesn't look right since limbs and joints can bend in all directions.
     
  5. Valls

    Valls

    Joined:
    May 4, 2014
    Posts:
    3
    I had that issue too. I realized there were animated boxColliders/meshColliders in my scene whithout a kinematic rigidbody attached. Once I added the rigidbody to those prefabs and set it to kinematic the ragdolls worked again.
     
  6. Ewanuk

    Ewanuk

    Joined:
    Jul 9, 2011
    Posts:
    257
    Ah, I'll give that a try
     
  7. MortenSkaaning

    MortenSkaaning

    Joined:
    Jan 16, 2015
    Posts:
    120
  8. Zergling103

    Zergling103

    Joined:
    Aug 16, 2011
    Posts:
    392
    The new PhysX joints are very unstable - in 4.6, they were a lot more robust at resolving the constraints.

    I find it ridiculous that we'd need to use projection now whereas previously it was optional, or that we'd need to use 10-20 iterations per frame, whereas 6 was enough before. Even with these changes, the joints won't explode but the ragdoll will still twitch the hell out when you put it's joints under the slightest stress.

    Here is proof - side by side comparison demos: https://dl.dropboxusercontent.com/u/38666531/Physics Demos 6 Iter.zip

    http://forum.unity3d.com/threads/joints-in-unity-5-are-very-unstable-and-its-not-just-me.319084/
     
  9. Ewanuk

    Ewanuk

    Joined:
    Jul 9, 2011
    Posts:
    257
    This seemed to more or less fix the problem:
    • Ensure all rigidbody parts are the same mass (had the biggest impact by far, even mild deviations, like mass ratios of 1:1.5 caused major instability)
    • Turn on projection for all character joints (I used 0.5 for distance and 45 for angle)

    Changing solver iteration count did nothing apparent values of 7, 20, and 64 had no noticeable difference
     
    Claytonious and cm like this.
  10. lelis718

    lelis718

    Joined:
    Apr 20, 2014
    Posts:
    1
    In my case I have setted all ragdoll´s rigidbodies to isKinematic=true and the elasticity has gone, hope this helps someone to
     
  11. MortenSkaaning

    MortenSkaaning

    Joined:
    Jan 16, 2015
    Posts:
    120
    @leslie718, switching isKinematic on and off?
    (isKinematic is false)
    isKinematic=true;
    isKinematic=false;

    if isKinematic keeps being true then the dynamics won't move the bodies at all.
     
  12. Ewanuk

    Ewanuk

    Joined:
    Jul 9, 2011
    Posts:
    257


    Essential watching for Ragdolls (starts @ 26:45)
     
  13. MortenSkaaning

    MortenSkaaning

    Joined:
    Jan 16, 2015
    Posts:
    120
  14. Satyros

    Satyros

    Joined:
    Feb 8, 2015
    Posts:
    6
    Setting Projection to true has done the trick!
     
  15. bruntos

    bruntos

    Joined:
    Jun 3, 2014
    Posts:
    2
    Thanks for these tips, really helped me a lot.
     
  16. teleceratops

    teleceratops

    Joined:
    Oct 27, 2018
    Posts:
    3
    For me it was the large capsule collider used in my character controller! I was transitioning from an animated character to a ragdoll. This woks for me:
    First...
    Gather rigid bodies and colliders in the ragdoll, disable all ragdoll colliders
    On transition...
    For each ragdoll Rigidbody: set IsKinematic=false, set velocity and angular velocity to zero
    For each ragdoll collider: enable
    Disable character animator
    Disable character's capsule collider
    Set character's velocity to zero (optional)

    Thanks Morten for the links above.