I have 2 circles that are colliding.
I want to weld them together when they collide. The code, within a beginContact function, is
WeldJointDef def = new WeldJointDef();
def.collideConnected=false;
Vector2 worldCoordsAnchorPoint = bodyA.getWorldPoint(new Vector2(0.0f,0.0f));
def.bodyA = bodyA;
def.bodyB = bodyB;
def.localAnchorA.set( def.bodyA.getLocalPoint(worldCoordsAnchorPoint) );
def.referenceAngle = def.bodyB.getAngle() - def.bodyA.getAngle();
def.initialize(def.bodyA, def.bodyB, worldCoordsAnchorPoint);
world.createJoint(def);
When the code runs, there is a c++ error, but it isn't very descriptive:
AL lib: (EE) alc_cleanup: 1 device not closed
Assertion failed!
Program: C:\Program Files\Java\jre7\bin\javaw.exe
File: /var/lib/jenkins/workspace/libgdx/extensions/gdx-box2d/gdx-box2d/jni/Box2D/Dynamics/b2World.cpp, Line 214
Expression: IsLocked() == false
How do I get the weld to work? Or can you not create weld joints on the fly in this way?