- Home /
Rope simulation - Double spring joint problem
Hello! I am trying to simulate rope physics with spring joints (As hinge joints gave me serious trouble), and in order to appropriately simulate that thick rope has a maximum bend, I have attatched spring joints at every other joint.
http://imgur.com/QkpBFCc <- Like so
But Unity doesn't seem to like this! The "rope" starts to jiggle and bounce everywhere. I suspect I am doing something awfully wrong, someplace, but I can't quite figure out where.
arrOfGameObjects is an array of instantiated prefabs.
for(int i = 0; i < maxCount; i++)
{
//The last should not have a spring attached
if(i < maxCount - 1)
{
SpringJoint spring = arrOfGameObjects[i].AddComponent<SpringJoint>();
spring.spring = springValue;
spring.damper = dampening;
spring.connectedBody = arrOfGameObjects[i + 1].rigidbody;
SpringDrawer drawer = arrOfGameObjects[i].AddComponent<SpringDrawer>();
drawer.target = arrOfGameObjects[i + 1].transform;
drawer.width = 0.1f;
drawer.Init();
}
if (i < maxCount - 2)
{
SpringJoint spring = arrOfGameObjects[i].AddComponent<SpringJoint>();
spring.spring = springValue;
spring.damper = dampening;
spring.connectedBody = arrOfGameObjects[i + 2].rigidbody;
}
}
Answer by Owen-Reynolds · Apr 20, 2014 at 06:23 AM
Springs spring -- a rope connected by a bunch of Spring Joints in a row, is a slinky. It should have crazy up&down bounces and waves running though it.
I'm guessing this is 2D? A hinge joint just needs tuning. Make sure it hinges in the correct direction, at the correct point, colliders not too far or close... . For a 3D rope, use a characterJoint. I don't think I've ever seen a good explanation of how to set all the numbers (swing axis2? I just leave it alone.)
I've been trying back and forth with the different joints, and none of them seem to produce stable results, other than the spring joint. The character joint sort of just wobbles, never really reaching a good resting position, and the configurable joint jiggles out of control, no matter the drag constraints I define.
It is in 3D.
All the joints work, if you can figure out how to set them up properly, which is tricky. I've made some ropy-things with 3 charJoints in a chain, which bounce around realistically. I've also made some horrid ones that twitch like they're on one of those hotel vibrating beds.
I'd like to have at least 10 joints in succession, if not more. Is there any tricks you can give, or a train of thought that I've missed in creating it?
I"m not sure the system can handle 10 in a row, even w/solver count or whatever jacked up. For charJoints, the orange arrow goes along the long axis of the limb (unlike hinges,) starting maybe just past the end, in the middle of the gap to the next collider. Not sure why it's so hard to find examples.
I just noticed the extra springs in your image. Eeew. CharJoints can limit bends all by themselves. Set it low, since Spring past 0 will let them exceed the limit.
Your answer
![](https://koobas.hobune.stream/wayback/20220613143119im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Rope Physics using Spring Joints 3 Answers
Making a Vibraating string. Need Help!! 0 Answers
Control the length of a Rope 0 Answers
Make a rope with Joints 1 Answer