FirstPersonMovement.prototype.update = function(dt) {
// If a camera isn't assigned from the Editor, create one
if (!this.camera) {
this._createCamera();
}
.........
}
Why are we checking if a camera exits in the update loop? Wouldn’t it be better (performance-wise) to only check for it once when the script initializes?
Also,
var x = 0;
var z = 0;
// Use W-A-S-D keys to move player
// Check for key presses
if (app.keyboard.isPressed(pc.KEY_A) || app.keyboard.isPressed(pc.KEY_Q)) {
x -= right.x;
z -= right.z;
}
Why are we doing
x -= right.x;
instead of
x = -right.x;