Add rotation on moving 3D entity


I tried applying torqueImpulse on my 3d entity but it doesn’t seem to work.

var IcrmWalkOg = pc.createScript('icrmWalkOg');
var CanMove = true;
// initialize code called once per entity
IcrmWalkOg.prototype.initialize = function() {
    this.entity.collision.on("collisionstart",this.contact,this);
    this.torque = 90;
};

// update code called every frame
IcrmWalkOg.prototype.update = function(dt) {
    if (CanMove == true){
    this.entity.rigidbody.applyForce(2,0,0);
    } else {
        this.entity.rigidbody.applyForce(-2,0,0);
    }   
};

IcrmWalkOg.prototype.contact = function(result){
    if (result.other.name == "Lollipop4"){
        CanMove = true;
        this.entity.animation.play("icrm-ani-og.glb");
        // this.entity.rotateLocal(0,-180,0);
        this.entity.rigidbody.angularDamping = 0;
        this.entity.rigidbody.applyTorqueImpulse(0,-this.torque,0);

    } else if (result.other.name == "KingdomWall4"){
        CanMove = false;
        this.entity.animation.play("icrm-ani-og.glb");
        // this.entity.rotateLocal(0,-180,0);
        this.entity.rigidbody.angularDamping = 0;
        this.entity.rigidbody.applyTorqueImpulse(0,this.torque,0);
    }
};

Here’s the script I used for most characters ^^^

PlayCanvas 3D HTML5 Game Engine [proj link]