[SOLVED] How to apply torque?

I’m looking for a way to apply torque to a dynamic body

var DynamicBody = pc.createScript(‘dynamicBody’);

// initialize code called once per entity
DynamicBody.prototype.initialize = function() {

this.torque = 7;
this.app.keyboard.on(pc.EVENT_KEYDOWN, this.onKeyDown, this);

};

DynamicBody.prototype.onKeyDown = function (event) {
event.event.preventDefault();
};

// update code called every frame
DynamicBody.prototype.update = function(dt) {
//update player’s position

this.playerPos = this.entity.getLocalPosition();

var app = this.app;

//keyboard controls and applying forces and moments.
//if (app.keyboard.isPressed(pc.KEY_LEFT) ) {
    this.entity.rigidbody.applyImpulse(-1, 0, 0);
{
    this.entity.rigidbody.applyTorque(0, -this.torque, 0);
}
if (app.keyboard.isPressed(pc.KEY_W) ) {
    this.entity.rigidbody.applyTorque(-this.torque, 0, 0);
}
if (app.keyboard.isPressed(pc.KEY_S) ) {
    this.entity.rigidbody.applyTorque(this.torque, 0, 0);
}
if (app.keyboard.isPressed(pc.KEY_F) ) {
    this.entity.rigidbody.applyForce(0, 9.8, 0);
}

// Keeping the cube on screen - cube moves off of one screen edge then appears from the opposite edge.

};

DynamicBody.prototype.reset = function () {
this.entity.rigidbody.teleport(0, 2, 0);
this.entity.rigidbody.linearVelocity = pc.Vec3.ZERO;
this.entity.rigidbody.angularVelocity = pc.Vec3.ZERO;
};

// swap method called for script hot-reloading
// inherit your script state here
// DynamicBody.prototype.swap = function(old) { };

// to learn more about script anatomy, please read:
// http://developer.playcanvas.com/en/user-manual/scripting/

What is that failing? Thanks in advance

Solved,. I had added a rigid body, but involuntarily I had deactivated it. :joy: