I know there is body.setAngularVelocity but that seems to introduce non interpolated behavior and weird twitching, so guessing this is not the optimal way.
What I’m seeing is “twitching” with a follow camera targeting my player, when making the players physicsbody turn. Will try isolating this in a playground.
Looks like the “twitching” is actually coming from the FollowCamera. Using another simple TargetCamera just parented to the PhysicsBody looks much more smooth.
Oh, I’m surprised the plugin doesn’t have an applyAngularImpulse - definitely something we should add. In the meantime, something like this should do the trick:
var body = ...;
var torqueWorld = ...;
var massProps = body.getMassProperties();
var worldFromInertia = massProps.inertiaOrientation.multiply(body.transformNode.absoluteRotationQuaternion);
var inertiaFromWorld = worldFromInertia.conjugate();
var impLocal = torqueWorld.applyRotationQuaternion(inertiaFromWorld);
var impWorld = impLocal.multiply(massProps.inertia).applyRotationQuaternion(worldFromInertia);
var newAV = body.getAngularVelocity().add(impWorld.scale(scene.getPhysicsEngine().getTimeStep()));
body.setAngularVelocity(newAV);