Like to know this one myself. Thought it would be easier than what I’ve just come up with.
Which is..
Using the constraints demo code
Just use linear factor to lock the rigidbody, then unlock that axis when you want to move it.
p2pARR = [];
var rb:AWPRigidBody = new AWPRigidBody(new AWPSphereShape(), null, 1)
rb.position = new Vector3D( -1300, 1500, 0);
rb.linearFactor = new Vector3D(0,0,0);
physicsWorld.addRigidBody(rb);
for (var i : int = 0; i < 6; i++ ) {
mesh = new Sphere(material, 100);
_view.scene.addChild(mesh);
prevBody = currBody;
currBody = new AWPRigidBody(sphereShape, mesh, 2);
currBody.position = new Vector3D(-1500 - (200 * i), 1500, 0);
physicsWorld.addRigidBody(currBody);
if (i == 0) {
//p2p = new AWPPoint2PointConstraint(currBody, new Vector3D(100, 0, 0));
p2p = new AWPPoint2PointConstraint(currBody, new Vector3D(100, 0, 0), rb, new Vector3D(0,-100,0));
physicsWorld.addConstraint(p2p);
p2pARR.push(p2p);
} else {
p2p = new AWPPoint2PointConstraint(prevBody, new Vector3D(-100, 0, 0), currBody, new Vector3D(100, 0, 0));
physicsWorld.addConstraint(p2p);
p2pARR.push(p2p);
}
}
Then you can do something like
//onKeyDown
AWPPoint2PointConstraint(p2pARR[0]).rigidBodyB.linearVelocity = new Vector3D(1,0,0)
AWPPoint2PointConstraint(p2pARR[0]).rigidBodyB.linearFactor = new Vector3D(1, 0, 0);
Works, but must be an easier way?