I have a character model whose movement is controlled through WASD. I have also added a walking animation FBX. But when I press any movement key the model just sticks to the ground whilst animating and moving in that particular direction. The orientation is getting glitchy.
It seems to have been caused by this
Quaternion modifying block of code, which I’ve used to turn the character in the direction of the pressed key (wasd).
let angleYCameraDirection = Math.atan2( this.camera.position.x - this.model.position.x, this.camera.position.z - this.model.position.z ); // diagonal movement angle offset let directionOffset = this.directionOffset(keysPressed); this.rotationQuaternion.setFromAxisAngle( this.rotateAngle, angleYCameraDirection + directionOffset ); this.model.quaternion.slerp(this.rotationQuaternion, 0.1); this.model.updateMatrixWorld();
How can I fix this?