- Home /
Non-Springy Configurable Joint
I'm using configurable joint to connect two rigidbodies. My code is :
ConfigurableJoint joint = parent.AddComponent<ConfigurableJoint>();
joint.anchor = new Vector3(0, 0, 0);
joint.xMotion = ConfigurableJointMotion.Locked;
joint.yMotion = ConfigurableJointMotion.Locked;
joint.zMotion = ConfigurableJointMotion.Locked;
joint.angularXMotion = ConfigurableJointMotion.Locked;
joint.angularYMotion = ConfigurableJointMotion.Locked;
joint.angularZMotion = ConfigurableJointMotion.Locked;
joint.targetPosition = new Vector3(0, 0, 0);
joint.connectedBody = child.rigidbody;
This joint just behaves like a spring joint. I want to make it less springy or totally fixed.(I know the fixed joint but later i'll free some of the angular and linear motions)
Answer by Vectrex · May 20, 2010 at 05:16 PM
You can try a combination of these
a) Set a higher physics framerate. In 'Edit/Project settings/Time/Fixed timestep" set this to a smaller value. This will increase stability and 'strength' while also being potentially a lot slower. 'FixedUpdate' will be called more often also. So be careful
b) Set the physics body iterations to a higher value. In 'Edit/Project settings/Physics/Solver Iteration Count" to something higher. This causes bodies to be more accurate with joints and in general. It helps with 'sponginess' on collisions too I think. 'FixedUpdate' will not be effected by this setting. All jointed bodies I think take on the highest connected bodies iteration count. This also can slow things slow a lot so keep an eye on the profiler. This is a global setting, but you can also selectively set body iterations individually in code. eg rigidBody.solverIterationCount = 10;
Thanks Vectrex!, your answer should be ticked as valid really and go straight in the documentation as the Edit/Project settings/Time/Fixed timestep is exactly what is needed to tweak when all the rest of the physics settings are good ( like solver iteration), thanks again!! my complex rig is now truly 'Perfect'.
Furthermore on that matter, I found that on mac I could increase the solver iteration count without real slow down on the physic simulation WHILE on windows ( at least on the machine I tested) going over 40 slow down the physics big time
Answer by duck · Apr 03, 2010 at 10:06 PM
As far as I'm aware, there will always be some springyness, even in fixed joints and config joints which have all locks applied. This seems to be an inherent symptom and limitation of the type of physics computation that PhysX uses.
You could try reducing the mass of one of the objects (whichever is not having forces applied), if this fits with your scenario.
However, I think it may be that the only way to ensure two objects are perfectly 'locked' together, would be to parent one to the other, and remove the rigidbody component of the child - therefore forming a Compound Collider. Only certain types of colliders can do this, however.
(see the section headed "Compound Colliders" on this manual page)
I could achieve a very solid chain of joints when solver iteration and time step settings is right.
Answer by Cynicalized · Apr 03, 2010 at 10:40 PM
Thanks for answer. I've tried to reduce the mass with no luck.
I'm using coumpound colliders for totally fixed bodies. But i don't want to totally fix the configurablejoint. All i want to do is to create a less springy behaviour on locked motion axises. I've tested All-Locked Configurable Joint(ALCJ) vs. spring joint vs. fixed joint. ALCJ feels nearly same as spring joint. But fixed joint looks rock solid.
I think the configurable joint is a base for all other joints and i can produce all other joints by configuring it right. Am i wrong?
btw avoid using answers to post comments. Use 'add comment' button
@s$$anonymous$$diworkz: you woke this 1.5 years old question to post that 3 words as answer?... I've converted it into a comment.
sorry it was a bit of a joke, i'll keep it to myself in future .....
Would have been funnier if you waited another 1.5 years to reply.
Answer by BillyBobBeavis · Dec 10, 2018 at 01:11 PM
I was trying to figure this out for quite some time. The only solution I could find to get the effect I wanted was to create reciprocal configurable joints for each object I connected. Meaning if I want to connect objects B and A then B will need a joint with A as it's connected body and A will need a joint with B as it's connected body. Then, I set the five Drive and Angular Drive Position Springs on both joints to 9999 or higher while keeping their Position Dampers at 0. The greater the difference between the Position Springs and Dampers the more solid the connection becomes. I would guess it's an intensive solution but the connection is sweet.
I just figured out that lowering masses and forces makes joints more solid in proportion to the reduction. This should be obvious but apparently it's not since I have not seen anyone else mention it.
Also, try changing "free" motion to "limited". It applies the limits, but leave all the limits at 0. That's likely a better solution than the first one I mentioned and easier too. I hadn't tried this before.
Answer by Augis1980 · Mar 17, 2020 at 01:50 PM
If all objects in the chain are more or less similar mass, then it should'ne be springyu (with 0 values in all bounciness etc, and Motion locked, angular limited) , but if one of your objects is way heavier, you will have that wierd effect. So just change mass of all objects to similar.
Your answer
Follow this Question
Related Questions
2D 360 degress platformer example needed 0 Answers
Raycast stops working after ~40 seconds when target has Rigidbody 2 Answers
Detailed terrain mesh collision 1 Answer
help me blow my balloon.... 1 Answer
Help with optimize code 1 Answer