PathManager Revolute Joints not holding together? [SOLVED]

Topics: Developer Forum, User Forum
Apr 16, 2013 at 12:23 AM
I made a scarf for a my game using the PathManager system,
and the tip of the scarf can attach itself to other bodies.

The problem is, when it's attached to a body, and I move my character away
the joints don't hold together (holding the character back), and just stretch out in a weird way.

Here's a quick video I made to show what happens:
http://www.youtube.com/watch?v=r7KvSP4jA_0&

I hope someone can help,
thank you.
Apr 16, 2013 at 3:07 AM
You need to use the rope joint. I recently ran into the same problem. I kept the revolute joints for drawing the rope, but when connected I add a rope joint to prevent the revolute joint stretching.

You can see an example in my game under development here:
http://www.youtube.com/watch?v=Imw1tfzxjaE

Hope that helps,
Mike.
Apr 16, 2013 at 5:57 AM
Okay great, good to see someone has had similar problems.

Hang in a bit longer though please :P

Since there's no AttachBodiesWithRopeJoint method, I did this:


for (int i = 0; i < scarfBodies.Count; i++)
        {
            if (i != scarfBodies.Count - 1)
            {

                RopeJoint rj = new RopeJoint(scarfBodies[i], scarfBodies[i + 1], new Vector2(0.05f, 0f), new Vector2(-0.05f, 0f));
                rj.MaxLength = 0.1f;

                world.AddJoint(rj);
            }
            scarfBodies[i].CollisionCategories = Category.Cat4;
            scarfBodies[i].CollidesWith = Category.Cat1;
        }

And still similar results :(

Anything I'm missing?
Apr 16, 2013 at 3:19 PM
You only want one rope joint that should connect your scarf anchor (I'm guessing at the neck) and the body the scarf is attaching too. So, based on your video, leave your original scarf code in place. Just add logic that when you determine that the scarf should attach to the block body, add 1 new rope joint that attaches the neck to the block. The rope joint is basically invisible -- it's just used to prevent the RevoluteJoints in the scarf from stretching apart.

Hopefully that makes sense.

Good luck, let me know how it turns out.
Mike.
Apr 16, 2013 at 10:13 PM
aha I got it working!

Great, I see what you mean now.
Thank you very much for your help! :)