distance joint problem

General discussion about Box2D tutorials
Post Reply
cristiab
Posts: 2
Joined: Thu Aug 28, 2014 7:27 pm

distance joint problem

Post by cristiab » Thu Aug 28, 2014 7:53 pm

Hi guys,

For almost 2 days I'm trying to create a bridge in box2d using b2distanceJoint and some squared bodies.

Basically I create 7 bodies, and each fixture has the shape of a square with 1 unit leg/side. All parameters for the bodies and fixtures are the default ones.

The first and the last bodies are static bodies, and the rest of the bodies are dynamic bodies. Each consecutive body is linked to the previous one through a distanceJoint. Each joint has the (0,0) anchor point value. The length in the distanceJoint between the bodies, is in my case about 2 units.

Until now I have in code the same setting I did in RUBE Editor (were everything seems to be OK), but, now is the funny part, the result is kicking my ass for two days: the distanceJoint length between the dynamic bodies exceed the length I set for the joints.

I can't find a solution as I don't understand the problem (why the distanceJoint length exceeds). All the progress I made in solving this, was by doing monkey tests (changing the settings and values, times and times again, without any logic, but to see the result), and I found that, if I disable the collisions for the dynamic bodies (by setting the category and mask filters to 0) and also I need to increasing the length up to 4 units for my 1 unit square fixtures, the result is the same with the one in RUBE and it's exactly what I wanted. But the big distance between bodies will not creating me a normal bridge but a ice floating bridge :).

I suppose I'm not the first or the last person that's hitting his head to the desk, the walls and the laptop's keyboard with this problem.

If there is anyone that can help me, and all the others like me, please send us a reply :).

Thanks guys,
Cristi

iforce2d
Site Admin
Posts: 860
Joined: Sat Dec 22, 2012 7:20 pm

Re: distance joint problem

Post by iforce2d » Fri Aug 29, 2014 10:19 am

If I understand what you're saying, this is just a general Box2D question? Might be better to try the box2d forums. Remember to give a little source code or something, so people can have a clue what you're doing.

If you're talking about a scene that you loaded into your game from a RUBE file, let us know what language and framework etc you are working with, so we can have a clue what you're doing.

cristiab
Posts: 2
Joined: Thu Aug 28, 2014 7:27 pm

Re: distance joint problem

Post by cristiab » Mon Sep 01, 2014 12:01 pm

Thanks for your reply.

Indeed the question is a general Box2D question with no relation to RUBE Editor, but the part where I tested my show cases.

I'll move my question to a Box2D forum.

Thanks,
Cristi

Post Reply