1.the project editor scene :https://playcanvas.com/editor/scene/607445
2.the game rule is add force by click right arrow button.raycast new pivot point by click mouse button left.
3.the question is:I use the Ammo.js physics Hinge joint,I want to change the Ammo.btVector3 on update . so the player can move by swing.
the key part of code :
Hinge2.prototype.initialize = function(app) {
var ownerPos = this.entity.getPosition();
pivotPos = this.linePivot.getPosition();
var relativeVector3 = new pc.Vec3();
relativeVector3.sub2(pivotPos,ownerPos);
//console.log(relativeVector3);
//Physic Joint
var pivot = new Ammo.btVector3(relativeVector3.x,relativeVector3.y,relativeVector3.z);
var pcq = new pc.Quat().setFromAxisAngle(pc.Vec3.FORWARD, -90);
var q = new Ammo.btQuaternion(pcq.x, pcq.y, pcq.z, pcq.w);
ammoBtT = new Ammo.btTransform();
ammoBtT.setIdentity();
ammoBtT.setRotation(q);
ammoBtT.setOrigin(pivot);
var joint = new Ammo.btHingeConstraint(this.entity.rigidbody.body, ammoBtT,true);
joint.setLimit(-Math.PI/2, Math.PI/2, 0.9, 0.3, 1);
this.app.systems.rigidbody.dynamicsWorld.addConstraint(joint);
this.app.systems.rigidbody.dynamicsWorld.
// never sleep
this.entity.rigidbody.body.setActivationState(pc.RIGIDBODY_DISABLE_DEACTIVATION);
};
// update code called every frame
Hinge2.prototype.update = function(dt) {
//Set physics
};
Please help me the hinge joint update question,more thanks.