Weld joint in box2dWeb-2.1.a.3.js library

A simple example of how to make a weld joint in box2dWeb-2.1.a.3.js library.
// create a weld joint between the bodies
	       
   weldJoint = new b2WeldJointDef();
   weldJoint.bodyA = bodyDef1;
   weldJoint.bodyB = bodyDef2;
	            
// connect the bodies using the local coordinates
	       
   weldJoint.localAnchorA = new b2Vec2(-0.5, -0.5);
   weldJoint.localAnchorB = new b2Vec2(0.5, 0.5);
	           
// specify the angle between bodies
	       
   weldJoint.referenceAngle = 0 * Math.PI / 3;
	            
// add the weld joint to the box2dWeb world
	       
   world.CreateJoint(weldJoint);

Responses

0 Replies