Havok, how to apply torque

Is there a way with Havok to apply torque ?

There is body.applyForce for applying a force affecting position, but how do I do the same for rotation?

Looking for something like NVIDIA(R) PhysX(R) SDK 3.4 API Reference: PxRigidBody Class Reference or Unity - Scripting API: Rigidbody.AddTorque

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.

Hello! What kind of twitching are you seeing? Can you share a playground?

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.

Wondering how the Havok / render update relates and if there is any interpolation on the render side, e.g. similar to Unity: Unity - Scripting API: Rigidbody.interpolation

Looks like the “twitching” is actually coming from the FollowCamera. Using another simple TargetCamera just parented to the PhysicsBody looks much more smooth.

Anyone here figured out how to do that? It actually don’t have a applyTorque function.

@eoin is this something we can add?

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()));