var box = pc.createSript('wasd');
//initialize code called once per entity
wasd.prototype.initialize = function() {
this.torque = 7;
this.app.keyboard.on(pc.EVENT_KEYDOWN, this.onKeyDown, this);
};
wasd.prototype.onKeyDown = function (event) {
event.event.preventDefault();
};
//update called every frame
wasd.prototype.update = function(dt){
//update player's position
this.playerPos = this.entity.getLocalPosition();
var app = this.app;
};
//keyboard controlls
if(app.keyboard.isPressed(ps.input.KEY_LEFT)){
this.entity.translateLocal(-0.1,0,0);
}
if(app.keyboard.isPressed(ps.input.KEY_RIGHT)){
this.entity.transtateLocal(0.1,0,0);
}
if(app.keyboard.isPressed(ps.input.KEY_UP)){
this.entity.transtateLocal(0,0.1,0);
}
if(app.keyboard.isPressed(ps.input.KEY_RIGHT)){
this.entity.transtateLocal(-0,0.1,0);
}
You have spelled ‘script’ wrong in createScript.
2 Likes