- Home /
Updating Camera rotation by the change rotation of something else
I am trying to update my camera rotation based on data received from the IPad gyro.
I should note that I have been working with Euler rotations because to this point I have been unable to wrap my head around Quaternion rotational math.
The camera starts with non-zero rotation based on the users position relative to a real world location. I am using the IPads GPS component to calculate what this rotation should be.
The Gyro rotation always starts at (0,0,0) regardless of the users orientation.
What I want to happens is for the Gyro rotation delta to be applied to the camera rotation so that if the gyro were to rotate 10 degrees around the x axis and the camera started with a 90 degree rotation the camera would have a 100 degree rotation.
It seems like a really simple concept but I have so far failed to achieve the desired result with every attempt.
Here is my current code:
void Update()
{
Camera.main.transform.Rotate(m_previousRotation - m_current_GyroRotation);
m_previousRotation = m_current_GyroRotation;
}
Any help or ideas would be greatly appreciated, thank you!