Assign an object rotation along a single axis from other object's rotation.
Hello guys! This is a question:
I have a two view modes in my game - Free Camera and FirstPersonController. I have an UI button to change between the two modes. I want to the view not to change the position while switching, eg. Fps camera and Free Camera have the same position, and the Fps look the same way the Camera was looking. For position simply copying the transform.position works fine. But if i just copy all rotations from Camera to the FPS, it makes FPS acts weird: in case you switch the view while Camera was looking, for example, down, the FPS will be oriented as the Camera was, like, not vertical, but with some angle to the ground, like some leaning tower of Pisa :)
I can't come out with solution for this, cause i can not completely understand how the rotations works in Unity. It would be perfect if this is a way to copy just the "y" component of Camera rotation, but as i understood, this is not possible? Maybe i can in come way orient the FPS vertical after translation rotations from Camera? Would really appreciate any help! Thanks!