- Home /
Need to treat the input.gyro as a steering wheel on iPad
Hi all, I have been playing with the iPad gyro with some success but need someone to help me understand how to calculate the iPad to always point down a specific axis regardless of orientation.
I don't have too many issues with calculations on object rotations but I think I have a mental block when it comes to the iPad being the point of reference.
Ideally I want to point down the z regardless of where or how i am holding the device. I know it's simple, can someone give me a small kick? Am I thinking of this the wrong way? Do I need to 'unapply' the orientation to always remain at a specific rotation?
Answer by hellaeon · Feb 15, 2013 at 07:45 AM
In the end the gyro is way over kill for such a simple task. Turns out I can just use the Input.Acceleration values. This I believe ignores what axis you may be facing: // z of object pointing into screen
if (use_iphone)
{
acc = Input.acceleration * iPhone_turn_speed;
if (Mathf.Abs(acc.x) > acceleration_tolerance)
{
rot_z -= acc.x;
if (rot_z > angle_max)
rot_z = angle_max;
if (rot_z < -1 * angle_max)
rot_z = -1 * angle_max;
transform.rotation = Quaternion.AngleAxis(rot_z, Vector3.forward);
}
}
I found no need to normalize the input acceleration for my project, rather just take whatever away from a rotation value, which I can then confirm does not go outside the bounds I set.
Cheers