Advertisement
dermetfan

Box2D breakable joints

Dec 22nd, 2013
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. private final Array<Joint> tmpJoints = new Array<Joint>();
  2. private float timestep = 1 / 60f, maxReactionForceLen2 = 1000, maxReactionTorque = 1;
  3.  
  4. @Override
  5. public void render(float delta) {
  6.     world.getJoints(tmpJoints);
  7.     for(Joint joint : tmpJoints)
  8.         if(joint.getReactionForce(1 / timestep).len2() > maxReactionForceLen2 ||
  9.         joint.getReactionTorque(1 / timestep) > maxReactionTorque)
  10.             world.destroyJoint(joint);
  11.     world.step(timestep, 8, 3);
  12.     // ...
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement