Bulletphysics (ammo.js) - How Would You Go About Applying Force To An Object?
To clarify - ammo.js is a port of Bullet Physics using mscripten I have a character (essentially a block) that needs to be pushed with force. I have tried (I think) all of the meth
Solution 1:
Due to the fact that ammo.js is an emscripten port, you have to use its native datatypes to talk to it...
So for setting velocity you'd need to body.setLinearVelocity(new Ammo.btVector3(1,0,0));
Same goes for applyForce and applyImpulse.
In my code, I usually make a set of temporary btVector3s, and use them throughout the file, in order to reduce the overhead of allocation and garbage collection..
var tbv30 = newAmmo.btVector3();
functionsetBodyVelocity(body,x,y,z){
tbv30.setValue(x,y,z);
body.setLinearVelocity(tbv30);
}
good luck :D
Post a Comment for "Bulletphysics (ammo.js) - How Would You Go About Applying Force To An Object?"