Circle get snagged in Edge

Topics: User Forum
Sep 5, 2010 at 10:20 AM


Firstly, i uploaded a video to youtube to show whats going on:

Trying to get the basic shape of a car with this setup:
I have two circle fixtures (1f radius) with a distancejoint between.
Then i have one rectangle fixture above with two distancejoints to each circle fixture

I then have two static edge fixtures in a cross (just to have something to "drive" on), and the problem is that the tires gets snagged if i have "too much" speed.

Is there some way i can fix this, or is it some kind of bug?

Sep 5, 2010 at 1:52 PM

Look at the EdgeTest demo.

The edges in that demo are setup to use "Adjacent" edges meaning it trys to smooth things out at the seams

Not sure why what you have doesn't work, but you might get better results doing things like shown in the demo.


Here is the relavent code

 public EdgeTest()
                Body ground = BodyFactory.CreateBody(World);

                Vector2 v1 = new Vector2(-10.0f, 0.0f);
                Vector2 v2 = new Vector2(-7.0f, -1.0f);
                Vector2 v3 = new Vector2(-4.0f, 0.0f);
                Vector2 v4 = new Vector2(0.0f, 0.0f);
                Vector2 v5 = new Vector2(4.0f, 0.0f);
                Vector2 v6 = new Vector2(7.0f, 1.0f);
                Vector2 v7 = new Vector2(10.0f, 0.0f);

                EdgeShape shape = new EdgeShape();

                shape.Set(v1, v2);
                //shape._index1 = 0;
                //shape._index2 = 1;
                shape.HasVertex3 = true;
                shape.Vertex3 = v3;

                shape.Set(v2, v3);
                //shape._index1 = 1;
                //shape._index2 = 2;
                shape.HasVertex0 = true;
                shape.HasVertex3 = true;
                shape.Vertex0 = v1;
                shape.Vertex3 = v4;

                shape.Set(v3, v4);
                //shape._index1 = 2;
                //shape._index2 = 3;
                shape.HasVertex0 = true;
                shape.HasVertex3 = true;
                shape.Vertex0 = v2;
                shape.Vertex3 = v5;

                shape.Set(v4, v5);
                //shape._index1 = 3;
                //shape._index2 = 4;
                shape.HasVertex0 = true;
                shape.HasVertex3 = true;
                shape.Vertex0 = v3;
                shape.Vertex3 = v6;

                shape.Set(v5, v6);
                //shape._index1 = 4;
                //shape._index2 = 5;
                shape.HasVertex0 = true;
                shape.HasVertex3 = true;
                shape.Vertex0 = v4;
                shape.Vertex3 = v7;

                shape.Set(v6, v7);
                //shape._index1 = 5;
                //shape._index2 = 6;
                shape.HasVertex0 = true;
                shape.Vertex0 = v5;

Sep 5, 2010 at 2:24 PM

Thank you for the suggestions, however, im experiencing the same even with this method. Any other ideas?

Sep 5, 2010 at 2:30 PM

Actually, hold that a sec... gonna try a bit more...

Sep 5, 2010 at 3:47 PM

Don't do the X thing.  Hook the edges up end to end.

Sep 5, 2010 at 4:16 PM


I tried it now, and it still snags it :
I made the edges end to end with the method you provided now (from EdgeTest demo).

Its not snagging as much, but still it does. I also tried to scale everything down a bit.

To run the car, im applying torque to the tires, does that matter?

Sooo... any other ideas?

Sep 5, 2010 at 6:37 PM

I'm really not sure why this is still happening.  The only thing I can think of is the edgeshapes have a bug. Possibly one was introduced during the port? Not sure.

You might try posting this question and video to the Box2D forums themselves and see if anyone has any insight.

Those forums are here: 

You should explain you are using a port of the engine and ask if this behavior should be expected or not.

-Jeff Weber


Sep 6, 2010 at 7:57 AM

Well, ive posted there now, and hoping someone will have an answer.

I have noticed that this does not happen if i remove the top rectangle body on the "car" and just using the circles for tires.
This is very odd...

Sep 7, 2010 at 8:15 AM

This can happen sometimes when CCD is enabled. Edge info is not evaluated inside the CCD solver if I remember correctly. You can disable CCD by editing Settings.cs and set ContinuousPhysics to false.