Add Rotation from parent to Quaternion Child

I’ve added a input to my cameras rotation, which is a child of the players object (standard fps setup, nothing fancy):

mainCam.transform.rotation = Quaternion.Euler(clampedRotation,transform.rotation.y, transform.rotation.z);

works fine. The problem is, that my camera is no longer rotating with the y axis of the parent, the camera is basically just locked and is looking forward, even though the player itself still rotates when input is added.

Any ideas?

1 Answer

1

Was able to fix it. I’ve had to use transform.eulerAngles.y instead of transform.rotation.y

    mainCam.transform.rotation = Quaternion.Euler(clampedRotation, transform.eulerAngles.y, transform.rotation.z);