- Home /
pitch camera up and down...
I have to be doing something wrong here but i just cant work it out..
Camera.main.transform.RotateAround(xAxis, Input.touches[touchNum].deltaPosition.y * Time.deltaTime);
xAxis being (1,0,0).
this line of code should track a particular touch's up and down movement and rotate in the yz plane around the x-axis but it is rolling the camera instead (around the z-axis)
trying the same code with (0,0,1) is pitching the camera however there is also some unexpected roll...
The same call using (0,1,0) yaws the camera as expected.
I cant understand whats going on here.. any ideas?
One issue is that you are using a undocumented version of RotateAround(). If I remember correctly, this one uses radians. Switch to the three parameter version. Or if you are trying to do an Angle/Axis rotation, switch to the Angle/Axis version of Rotate().
Answer by gheeler · Jul 11, 2013 at 03:02 PM
even using rotate it was acting weird. i just calculated my desired angle and set it myself
Vector3 rotation = new Vector3(Camera.main.transform.eulerAngles.x + Input.touches[touchNum].deltaPosition.y * Time.deltaTime,
Camera.main.transform.eulerAngles.y + Input.touches[touchNum].deltaPosition.x * Time.deltaTime, 0);
Camera.main.transform.localEulerAngles = rotation;