Hello!
I’m trying to implement dragging of objects with different masses (like in Half-Life 2, Viscera Cleanup Detail, etc.). So far I have a dragger with Rigidbody and ConfigurableJoint on a player’s child. It kinda works but it has some flaws.
So how it should be:
- It shouldn’t rotate midair, but should rotate when it touches surfaces or else if needed.
- If object clings on something, it should act like it’s on spring. I read docs and I tried to play with parameters but had no success. It just psychotically jitters (see video). Before ConfigurableJoint I was using SpringJoint and it was like I want, but problem with SpringJoint was that object was rotating and flying around like crazy.
- If player drops object while moving or rotating, object should save inertia. With SpringJoint it was like that, now it just falls down (see video).
I’ve also added Linear Limit, because without it objects were jittering midair but now objects are weirdly swaying (see video).
I apply these parameters to ConfigurableJoint:
cj.autoConfigureConnectedAnchor = false;
cj.anchor = cj.axis = cj.secondaryAxis = Vector3.zero;
cj.connectedAnchor = hit.rigidbody.centerOfMass;
cj.xMotion = cj.yMotion = cj.zMotion = cj.angularXMotion = cj.angularYMotion = cj.angularZMotion = ConfigurableJointMotion.Limited;
SoftJointLimit linearLimit = cj.linearLimit;
linearLimit.limit = draggerLinearLimit;
cj.linearLimit = linearLimit;
cj.breakForce = draggerBreakForce;
cj.connectedBody = hit.rigidbody;