I am in PlayCanvas and for the first time I'm making a 3d game. I tried to make a simple movement script but, with no errors in the code that I can see, it is not working.
I made this script:
var movement = pc.createScript('movement');
movement.attributes.add('speed', {type: 'number'});
movement.prototype.initialize = function() {
console.log("Movement Activated")
};
movement.prototype.setMotion = function(dt) {
// PC.KEY_W =>W
//PC.KEY_TAB => TAB
if (this.app.keyboard.isPressed(pc.KEY_W)){
this.entity.rigidbody.applyForce(
0,
0,
1
);
}
};
movement.prototype.update = function(dt) {
this.setMotion();
};
and it is definitely attached to the entity:
but when I open the launch tab which lets me see what the game would be like for a player when I hit W nothing happens. If there are any errors please let me know.