I am making a third person sonic game and when I use this.entity.right.clone for movement it works perfectly but when I use this.entity.forward.clone the character goes up and down instead of forwards and backwards. The controls of the game are arrow keys to turn and WASD to move. This is the code
var Sonicmovement = pc.createScript('sonicmovement');
// initialize code called once per entity
Sonicmovement.prototype.initialize = function() {
};
// update code called every frame
Sonicmovement.prototype.update = function(dt) {
if(this.app.keyboard.isPressed(pc.KEY_W)){
var impulse = this.entity.forward.clone();
impulse.scale(1);
this.entity.rigidbody.applyImpulse(impulse);
}
if(this.app.keyboard.isPressed(pc.KEY_S)){
var impulse = this.entity.forward.clone();
impulse.scale(-1);
this.entity.rigidbody.applyImpulse(impulse);
}
if(this.app.keyboard.isPressed(pc.KEY_A)){
var impulse = this.entity.right.clone();
impulse.scale(1);
this.entity.rigidbody.applyImpulse(impulse);
}
if(this.app.keyboard.isPressed(pc.KEY_D)){
var impulse = this.entity.right.clone();
impulse.scale(-1);
this.entity.rigidbody.applyImpulse(impulse);
}
if(this.app.keyboard.isPressed(pc.KEY_RIGHT)){
this.entity.rigidbody.applyTorque(0,-2,0)
}
if(this.app.keyboard.isPressed(pc.KEY_LEFT)){
this.entity.rigidbody.applyTorque(0,2,0)
}
};
And this is the project link: Sonic