Hi, I wanted to apply torque locally to my player. But PlayCanvas doesn’t seem to have an applyLocalTorque function. But it seems ammojs does support it.
m_linearSleepingThreshold = linear;
m_angularSleepingThreshold = angular;
void applyTorque(const btVector3& torque)
m_totalTorque += torque*m_angularFactor;
// XXX AMMO local addition to bullet
void applyLocalTorque(const btVector3& torque)
m_totalTorque += m_worldTransform.getBasis() * torque * m_angularFactor;
void applyForce(const btVector3& force, const btVector3& rel_pos)
I tried to understand how to call ammojs functions from PlayCanvas but I found it a bit complicated. This is what I used:
I would appreciate it if anyone can help me figure this out.
I think that method is available in the internal Ammo.js body object, you can find a reference to it like this:
Try it and let us know if that works.
Thanks for the reply.
Unfortunately, it doesn’t seem to be working.
This works fine:
But this doesn’t:
Chances are that it’s expecting an Ammo.btVector3 type.
this.player.rigidbody.body.applyLocalTorque(new Ammo.btVector3(0, 0, 5));
I recommend looking at the engine source for more examples on using Ammo directly:
A list of exposed functions are here:
@yaustar I think that is the latest IDL. Is it used by Playcanvas? Is there a place where one may check the bindings of the Ammo version used by PC?
Honestly, not sure which version we are tracking. If in doubt grab the latest from the Ammo repo.
Right, unfortunately it is not as easy, because the version that is used by Playcanvas is using a special feature (
Ammo.addFunction) which is not enabled in the default build, available in Ammo repository. One would need to download the sources, set up emscripten and build with a compilation flag that enables it.
@will Which version of Ammo are we using these days? AFAIK, we are not maintaining our own private fork.
Correct. We just use the latest build directly from the master ammo.js repo maintained by kripken.
Thank you for the response. So, I think the pre-built version in kripken’s repository is older than the latest IDL bindings file. Nevertheless, I downloaded the pre-built Ammo files from the build folder in the repository and added to Playcanvas project. Here is the result:
Odd, looking at the commit history on Ammo, it should be there
I think the way the callbacks are handled was changed. If you are referring to the addFunction commit for the test, then the test was changed: