I attach to the player(camera) physics body. I have nice working forwand and backward but lft and right always faild in some way.
I dont want kinematic like ussually controls object containe. I wanna my graphics to follow my physics body.
Here is most important code:
if (this.moveForward == true) {
// WORKS PERFECT IN ANY DIRECTION
this.pos.copy(this.raycaster.ray.direction);
this.pos.multiplyScalar(12);
this.playerBody.userData.physicsBody.setLinearVelocity(
new Ammo.btVector3(this.pos.x,this.pos.y,this.pos.z));
} else if (this.moveBackward == true) {
// WORKS PERFECT IN ANY DIRECTION
this.pos.copy(this.raycaster.ray.direction);
this.pos.multiplyScalar(12);
this.playerBody.userData.physicsBody.setLinearVelocity(
new Ammo.btVector3(-this.pos.x,this.pos.y,-this.pos.z));
} else if (this.moveLeft == true) {
// NOT WORKS PERFECT IN ANY DIRECTION !!!!
this.pos.copy(this.raycaster.ray.direction);
this.pos.multiplyScalar(12);
this.playerBody.userData.physicsBody.setLinearVelocity(
new Ammo.btVector3(this.pos.x, 0, this.pos.y));
} else if (this.moveRight == true) {
// NOT WORKS PERFECT IN ANY DIRECTION !!!!
this.pos.copy(this.raycaster.ray.direction);
this.pos.multiplyScalar(12);
this.playerBody.userData.physicsBody.setLinearVelocity(
new Ammo.btVector3(-this.pos.y, 0, -this.pos.x));
}
I try to combine x,y,z also with -x,-y,-z in different variant but no success.
How can i modify this.raycaster.ray.direction for example angle for Y axion +90 or -90
and make work just like forwand and backward....
Any suggestion ?
i make clone of exist ray.direction vector then i apply new angle with
applyAxisAngle. For left -90 for right 90 .Now i have player who walk in all directions.