Search Unity

How can i prevent ragdolls from stretching and spazzing out?

Discussion in 'Physics' started by Nanako, May 26, 2015.

  1. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    I've made a ragdoll teddybear. I used the ragdoll wizard a little initially to see how it works, but it wouldn't take an armature with only 7 bones, so i ultimately made this myself, with colliders, rigidbodies, and character joints, on each part.

    As long as i move this little guy around slowly, and don't get him caught on things, he's fine;



    But if i move him too fast, or swing him around in a way that part (not all) of him hits an object, bad things happen.



    My best guess at what's happening here, is that high forces are sending the limb rigidbodies flying, and they get caught on something in the scene, preventing them from coming back.

    But i don't understand HOW this can happen. The character joints have a breakforce set to infinity, so surely that should prevent them from going any distance from their starting point, no matter how much force they're under?

    The right leg in this case flew about 100m and got stuck behind a little hill in the distance.

    Probably relevant, here's the full inspector readout for that right leg (most of these values are just defaults)

     
  2. Robert-HGG

    Robert-HGG

    Joined:
    May 27, 2015
    Posts:
    10
    I am struggling with the same issue for days. I've tried everything and there is no fix other than limiting ragdoll speed!

    Ragdolls are broken and extremely unstable in Unity 5.
     
  3. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    I've found a solution which seems to work perfectly now. Enable projection on the character joints.

    default settings just magically made the problem go away.
     
  4. MaiJingNan

    MaiJingNan

    Joined:
    Jul 24, 2016
    Posts:
    1
    thanks Nanako,your help work for me
     
  5. wesleywh

    wesleywh

    Joined:
    Jun 8, 2014
    Posts:
    19
    Tried this and it worked like a charm for me. Thanks for the post!
     
  6. sdclark79

    sdclark79

    Joined:
    Feb 6, 2017
    Posts:
    21
    I could be wrong, but I'm pretty sure this is a collision issue. I've had a similar issue with ragdolls, and the issue ended up being resolved by working out layer collisions in Edit->Project Settings->Physics
     
    cokelekdeniz likes this.
  7. FuzzyShan

    FuzzyShan

    Joined:
    Jul 30, 2012
    Posts:
    182
    None of these works in high speed collision impact, setting max depentration velocity helps, but it would cause some other issues, such as ignore collision impact.
     
  8. Plystire

    Plystire

    Joined:
    Oct 30, 2016
    Posts:
    142
    Ragdolls don't normally behave the best when paired with high velocity.
     
    SparrowGS likes this.
  9. HOEB

    HOEB

    Joined:
    Mar 31, 2017
    Posts:
    1
    Thanks Nanako. It worked fine for me.
     
  10. Jasmin1347

    Jasmin1347

    Joined:
    Jan 24, 2018
    Posts:
    2
    Thanks Nanako. It working fine.:)
     
  11. TheGameLearner

    TheGameLearner

    Joined:
    Feb 10, 2018
    Posts:
    20
    Thanks @nanako.693001, I was able to use your enabling option.... saved me tons of work.
     
  12. NathanJSmith

    NathanJSmith

    Joined:
    May 11, 2018
    Posts:
    57
    TheGameLearner likes this.
  13. joeyether40

    joeyether40

    Joined:
    Jan 26, 2018
    Posts:
    20
    How do you enable character joints . I am also having this stretching issue with my character
     
  14. Wothanar

    Wothanar

    Joined:
    Sep 2, 2016
    Posts:
    122
    thank you so much it worked for me
     
  15. joeyether40

    joeyether40

    Joined:
    Jan 26, 2018
    Posts:
    20
    How did you get this to work? I do not see where to enable projection
     
  16. TheGameLearner

    TheGameLearner

    Joined:
    Feb 10, 2018
    Posts:
    20
    titch_stewart likes this.
  17. joeyether40

    joeyether40

    Joined:
    Jan 26, 2018
    Posts:
    20
    i was using Configurable joints and that joint did not have that setting. I switched to character joint and used that and now no stretching ty
     
  18. Hoorza

    Hoorza

    Joined:
    May 8, 2016
    Posts:
    45
    You are a legend. Works like a charm. So far. Need to test the collisions now. Cheerio
     
  19. Alguasil

    Alguasil

    Joined:
    Jan 26, 2017
    Posts:
    7
    Uou, that is what I was looking for so long... Thank you very much!
     
  20. mjc33

    mjc33

    Joined:
    Oct 9, 2019
    Posts:
    26
    5 years later and @Nanako solution still works great with the 2020 alpha, I was having issues where unity was crashing because my ragdoll was flying out of bounds/at too high velocities due to spaghettification glitches, this fully fixed it
     
  21. alenushkamoscow

    alenushkamoscow

    Joined:
    Jan 6, 2019
    Posts:
    5
    Works for me in 2019.3.7f1) Thank you very much!
     
  22. Short_Barrel_Works

    Short_Barrel_Works

    Joined:
    Sep 25, 2018
    Posts:
    2
    @Nanako solution worked like a charm, but needs a litlle bit tweaking for my purpose

    However, In my case streching still occured a little bit, althought it isn't as bad as before.
    so, if you really-really need to eliminate streching at all cost, don't forget to set the Projection Distance to 0.01 or lower.

    That's how i deal with my streched ragdoll's neck
     
  23. Luteranos

    Luteranos

    Joined:
    Nov 2, 2015
    Posts:
    1
    @Nanako thanks man, some days later I have found your solution. So simple and the still the best aproach.
     
  24. azeem_ehsan

    azeem_ehsan

    Joined:
    Mar 5, 2022
    Posts:
    5
    Brother This Solution Works the Best at High Speed in 2022. And Bundle of thanks to you .. INSHALAH.. May Allah Bless you with Success..
     
  25. MorganYT

    MorganYT

    Joined:
    Jul 29, 2017
    Posts:
    31
    I set defaultSolverIterations and defaultSolverVelocityIterations to 30 and it helped at high speeds. But the question remains is it optimized?... EDIT: it helped but not completely.
     
  26. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    715
    Nothing seems to be working and when the ragdoll arm stretches the entire chain starts flipping out. I have tried all suggestions in this thread. Even using character joints still results in ragdoll flipping out when the arm is stretched slightly. Is there any solution?
     
    Last edited: Jan 21, 2023
  27. eliteforcevn

    eliteforcevn

    Joined:
    Oct 25, 2018
    Posts:
    47
    thanks work perfect
     
  28. Cloudwalker_

    Cloudwalker_

    Joined:
    Jan 3, 2014
    Posts:
    140
    Physx is pretty stable in simulation. If you're having joint stretch then you're applying way too much force to the joints. Projection is not the solution.
     
    lacas8282 likes this.
  29. unity_A71C7D7460C20CAEA54C

    unity_A71C7D7460C20CAEA54C

    Joined:
    Feb 15, 2023
    Posts:
    2
    Thanks nanako works not perfectly but something is better than nothing
     
  30. unity_A71C7D7460C20CAEA54C

    unity_A71C7D7460C20CAEA54C

    Joined:
    Feb 15, 2023
    Posts:
    2
  31. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    715
    This does not apply to my application, and you give no solution. Simply asking user not to stretch the ragdoll is not a viable solution and does not answer the question. Physx is good but "stable in simulation" is pretty vague.

    Thanks, I read that article the very first day I noticed the issue. Nothing mentioned in the document solves the joint singularity infinite force issues unfortunately.

    Only solution I can find is to use linear functions to project the target coordinates and limit the radius, which is working but is not ideal and CPU intensive!

    --

    P.S. Please don't lock this thread because of some disagreements. ragdoll stretching glitch in Unity seems to be a ongoing issue and more discussion/solutions are needed.
     
    Last edited: Mar 23, 2023