I need to attach my MouseJoint always at the center of a body.
As you can see:

The mousejoint is attached at the mouse click location, not in the center.
How do I force it to stay at the center of a body?
here is the code I'm using to create the joint:
As you can see:

The mousejoint is attached at the mouse click location, not in the center.
How do I force it to stay at the center of a body?
here is the code I'm using to create the joint:
Code:
public function updateMouseDef():void {
var _mouseJointDef:b2MouseJointDef;
_mouseJointDef=new b2MouseJointDef();
_mouseJointDef.body1= w.GetGroundBody();
_mouseJointDef.body2 = _obj.body; // the draggable object
_mouseJointDef.target.Set(_mouseX/30, _mouseY/30);
_mouseJointDef.maxForce=3000;
_mouseJointDef.timeStep = timeStep;
_mouseJointDef.dampingRatio = mouseDampingRatio; // mouseDampingRatio is a random number btw 0 to 5.
if (_mouseJoint) {
w.DestroyJoint(_mouseJoint);
}
_mouseJoint = w.CreateJoint(_mouseJointDef) as b2MouseJoint;
}
var _mouseJointDef:b2MouseJointDef;
_mouseJointDef=new b2MouseJointDef();
_mouseJointDef.body1= w.GetGroundBody();
_mouseJointDef.body2 = _obj.body; // the draggable object
_mouseJointDef.target.Set(_mouseX/30, _mouseY/30);
_mouseJointDef.maxForce=3000;
_mouseJointDef.timeStep = timeStep;
_mouseJointDef.dampingRatio = mouseDampingRatio; // mouseDampingRatio is a random number btw 0 to 5.
if (_mouseJoint) {
w.DestroyJoint(_mouseJoint);
}
_mouseJoint = w.CreateJoint(_mouseJointDef) as b2MouseJoint;
}