Box2D random crash when adding joints
- by user46624
I'm currently working on a project which uses Box2D, when the player uses a certain key it should anchor to the ground. For that I use a weld joint, but when I add the joint the game will sometimes crash, it has a 1/10 change to crash.
The error I recieve:
Showing the controller
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 11
at org.jbox2d.dynamics.Island.add(Island.java:577)
at org.jbox2d.dynamics.World.solve(World.java:1073)
at org.jbox2d.dynamics.World.step(World.java:598)
The code for adding the joints:
WeldJointDef def = new WeldJointDef();
def.initialize(body, anchoredObject.body, body.getWorldCenter());
weldJoint = (WeldJoint) world.createJoint(def);
I still get the error if I synchronize it