Joints in Unity become unstable when stretched

Hello! I am having a issue with joints in Unity. I tried Unity 2019, 2020 and 2021 and all version result in ragdolls flying apart when arms are slightly stretched.

I’ve tried many suggestions on the forums such as enabling projection and lowering value to 0.01, changing physics timesetep up/down, disabling preprocessing and nothing really works and ragdolls are still flying apart from slight stretching of the arms.

How can I overcome this issue? I can’t find any solutions for allowing ragdolls to strectch, nor can I find any workable solution for locking the joints without forces going to 10^+14 if the arm is pulled slightly.

The only solution I have come up with is to interpolate a target along a line projected from the chest to the hand and clamp the distance, which works! But custom solutions like this are not portable and only work for my particular case.

I am wondering why joints do not have a maximum force value to clamp the stretching forces? I have been working on this one problem for a week and still have found no solution to allow stretching of joints without producing wild singularities and infinite force.

Any help would be great! :slight_smile:

Are you using Hinge Joints? I used that for simulating a cord that had a skinned mesh. What’s odd is that I get no instability or joint breaks if the ends are attached to a kinematic RigidBody or just an ArticulationBody with a Fixed Joint. Maybe try that? Also try changing the stiffness and damping values of the joints.

Is there anything I can do? I am still trying to figure out how to make ragdolls not wildly shake when arm is slightly stretched.

Is there a joint system available that is not Unity built-in? Or can i use IK as a ragdoll?

Are there any joints other than physicX or Havok engine that I can use in Unity?

Performance is not a issue - stability is critical!!

As suggested by leebissessar5: have you tried articulations?

I did try articulations but my project is 2019, also when I attempted creating a ragdoll with articulations the results were mechanical looking and I was unable to figure out how to clamp rotation limits and apply dampening or spring forces like configurable joints? From my understanding articulations is a solver for automation and robotics. I couldn’t find any mention about using articulations for ragdoll physics. If it’s possible that’s awesome, unfortunately articulations is not compatible with my project’s game engine version.

I have written a library now that prevents ragdolls from being stretch by using interpolation along the joint chain to limit the target to a maximum radius which seems to work, however has taken nearly two pages of code and now my game runs many simultaneous linear equations resulting in substantial additional processing just to avoid the singularities due to joints not clamping physics forces.

Articulations are 2020 and up, as per the manual.

Articulated joints have rotation limits (set motion to “limited”, then specify limits), friction, damping, etc. just like configurable joints:
https://docs.unity3d.com/Manual/class-ArticulationBody.html#joint-anchor-properties

That’s because 99% of the time regular joints are enough for ragdolls. Literally all games I’ve ever played or worked in used regular joints and they do their job fine, but if you need the extra accuracy/robustness articulated bodies offer you (for a moderate performance hit), ragdolls are as good an use case as robotics: they’re small, tree-like joint structures with no loops in the hierarchy, so a perfect fit for articulations.

Regular joints take multiple, individual rigidbodies and constrain their motion by applying impulses than attempting to remove DOFs (degrees of freedom). On the other hand, articulated bodies are a single body that has only the required DOFs by construction, so no need to “remove” them at runtime and no chance the engine may fail in doing so. The downside is that applying forces/impulses to an articulated body is more expensive, since they have to be propagated to all joints in the articulated body.

This all sounds rather strange, tbh. I’ve used joints in the past and had no stretching issues whatsoever, as long as the joint chain was reasonably short (up to 10 joints). Even in extreme cases, increasing the amount of solver iterations did the trick.

Unless you’re using a kinematic object to pull the rigidbody limbs apart, or forcing the position of limbs - which would result in essentially an infinite force being applied to the joints - any forces you apply to the limbs should be balanced out by the corrective impulses applied by joints and prevent further pulling/stretching.

There should be no need to “clamp physics forces”, because forces of equal magnitude and opposite direction just cancel each other out. If they’re not behaving like this, it can only mean the forces you’re applying to the ragdoll are huge compared to the ones the joints can reasonably apply to keep stable.