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);
Hi
Why doesnât the Havok plugin have applyTorque/applyAngularImpulse functions? How do you implement them if simple things canât be achieved without workarounds?
It wonât work to simply convert the angle into a vector and apply the impulse to that vector!