I am trying to use the iPhones gyro to implement a shake feature. I particularly care about the direction of the shake.
What I'm finding is "Input.acceleration" doesn't return a acceleration at all but an value corresponding to the tilt of the device.
If you leave the device still but not level , you always get a reading. Hence, if I prop the device up you will find that either Input.acceleration.x or Input.acceleration.y comes back a consistent large value.
A cut down example of the code looks something like this:
This is fine if I want a tilting type of control (above works quite well for that) but I'm after acceleration.
Acceleration events I dont think will help me either.
asked May 13 '12 at 02:17 PM
Now I've come to the acceptance that acceleration isnt acceleration at all but just the current tilt, the solution was pitfully simple. Acceleration is just the difference in tilt since the last reading.
So the code looks something like this:
Now when I tilt the device I get an initial force in the direction I tilted but the force doesnt persist if I leave the device tilted at an angle.
answered May 19 '12 at 11:25 AM