I have a helicopter in my game, I want the camera to always look at the back of the helicopter but I can't do it. When the helicopter rotates I cant make the camera rotate with the helicopter. Here is the image of the rotation of the helicopter and camera.This is what I want even the helicopter rotates. But this is what happened \
Camera initiliazion : const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
function cameraUpdate(camera) {
camera.position.x = movingObject.x + 20
camera.position.y = movingObject.y + 20;
camera.position.z = movingObject.z;
camera.lookAt(movingObject.position);}
This function called in my render loop. movingObject is my helicopter. The rotation code of the helicopter is in my inputController function which is called in the render loop. The rotation snippet is below.
if (input.rotClk === true) {
moveableObj.rotatation.y += -0.05;
}
I try camera.rotation.y += -0.05 and It did not work.
question from:https://stackoverflow.com/questions/65646553/three-js-rotate-the-camera-when-the-object-rotate