Attempting to make 2d rope physics

In my attempts to make 2d rope I’ve tried doing what a lot of people recommend, make it more like a chain of gameobjects with rigidbody and joint. I’ve also added colliders so that it interacts with the environment. What I dont understand is why the joints act springy. Doesn’t matter if I use distance or hinge joints. If I have a distance joint connecting two bodies together at a distance of 1, why is it that that distance can be greater than 1 during any frame? Dont understand that. To make it less spring it’s helped to increase the number of position iterations in the physics, but its still not perfect.

I’d recommend reading up on how Hinge Joints work. I actually started using my very first hinge joint yesterday, and this doc is all you need to know: Unity - Manual: Hinge Joint component reference

Thanks. I’ve actually tried hinge joints, but in my version of unity I didn’t see the spring option. I wonder if that was added in a recent release? I’m going to upgrade and make sure Use Spring is disabled to see if that fixes my issue.

Nevermind I was looking at the 3d hinge joint. HingeJoint2D doesn’t have that option to disable the spring effect. :frowning:

1 Like

So… use the 3D hinge joint?

But my game is 2d. 3D and 2d physics don’t interact with eachother I thought…

I’m talking about this: https://docs.unity3d.com/Manual/class-HingeJoint.html

It doesn’t say 3D anywhere so it should work.

It’s under the 3D physics reference section. All of the physics stuff is 3d unless specified as 2d. And the two physics engines don’t interact with eachother.

2 Likes

If you’re creating a deep hierarchy of joints to form a rope/chain then I’d recommend that you additionally add a DistanceJoint2D with its MaxDistanceOnly set to true that connects the start/end of the rope/chain. This way, the structure will never exceed a certain distance (the length of the rope/chain). This stops the stretching you’re seeing.

When the MaxDistanceOnly is set to false then we use a b2DistanceJoint whereas when it’s set to true we use a b2RopeJoint behind the scenes.

5 Likes