Box2D random crash when adding joints

Posted by user46624 on Game Development See other posts from Game Development or by user46624
Published on 2014-06-01T18:07:26Z Indexed on 2014/06/01 22:00 UTC
Read the original article Hit count: 201

Filed under:
|

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

© Game Development or respective owner

Related posts about java

Related posts about box2d